-
Notifications
You must be signed in to change notification settings - Fork 12
Add WARC-Cipher-Suite and WARC-Protocol #50
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
04293f6
0f0deb5
9dbdf4b
91b4921
dfd346e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -286,6 +286,59 @@ func testFileRevisitVailidity(t *testing.T, path string, originalTime string, or | |
| } | ||
| } | ||
|
|
||
| // testFileTLSHeaders validates that WARC-Cipher-Suite and WARC-Protocol headers are present | ||
| // for request and response records when the connection was made over TLS. | ||
| func testFileTLSHeaders(t *testing.T, path string) { | ||
| file, err := os.Open(path) | ||
| if err != nil { | ||
| t.Fatalf("failed to open %q: %v", path, err) | ||
| } | ||
| defer file.Close() | ||
|
|
||
| t.Logf("checking 'WARC-Cipher-Suite' and 'WARC-Protocol' on %q", path) | ||
|
|
||
| reader, err := NewReader(file) | ||
| if err != nil { | ||
| t.Fatalf("warc.NewReader failed for %q: %v", path, err) | ||
| } | ||
|
|
||
| for { | ||
| record, err := reader.ReadRecord() | ||
| if err != nil { | ||
| if err == io.EOF { | ||
| break | ||
| } | ||
| t.Fatalf("warc.ReadRecord failed: %v", err) | ||
| break | ||
| } | ||
|
|
||
| recordType := record.Header.Get("WARC-Type") | ||
| if recordType == "request" || recordType == "response" { | ||
| cipherSuite := record.Header.Get("WARC-Cipher-Suite") | ||
| protocol := record.Header.Get("WARC-Protocol") | ||
|
|
||
| if cipherSuite == "" { | ||
| t.Errorf("WARC-Cipher-Suite header missing for %s record", recordType) | ||
| } else { | ||
| t.Logf("WARC-Cipher-Suite: %s", cipherSuite) | ||
| } | ||
|
|
||
| if protocol == "" { | ||
| t.Errorf("WARC-Protocol header missing for %s record", recordType) | ||
| } else if !strings.HasPrefix(protocol, "tls/") { | ||
| t.Errorf("WARC-Protocol should start with 'tls/' for HTTPS, got: %s", protocol) | ||
|
Comment on lines
+328
to
+329
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If the WARC-Protocol value is Given that we define |
||
| } else { | ||
| t.Logf("WARC-Protocol: %s", protocol) | ||
| } | ||
| } | ||
|
|
||
| err = record.Content.Close() | ||
| if err != nil { | ||
| t.Fatalf("failed to close record content: %v", err) | ||
| } | ||
| } | ||
| } | ||
|
|
||
| func testFileEarlyEOF(t *testing.T, path string) { | ||
| file, err := os.Open(path) | ||
| if err != nil { | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In addition to writing a WARC-Protocol value for the encryption used, it could be nice to add support for which HTTP verison was archived to have feature parity with wget-lua:
Not a request for right now, but noted all the same