Skip to content

Commit

Permalink
Write requests AFTER responses and upgrade to 1.21
Browse files Browse the repository at this point in the history
  • Loading branch information
CorentinB committed Aug 23, 2023
1 parent 6e5bb31 commit 2dd25be
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: '1.20'
go-version: '1.21'

- name: Build
run: go build -v ./...
Expand Down
7 changes: 7 additions & 0 deletions dialer.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"net"
"net/http"
"net/url"
"slices"
"strconv"
"strings"
"sync"
Expand Down Expand Up @@ -204,6 +205,12 @@ func (d *customDialer) writeWARCFromConnection(reqPipe, respPipe *io.PipeReader,
return
}

// Most Internet Archive tools expect requests to be AFTER responses
// in the WARC file. So we make sure that's the case.
if batch.Records[0].Header.Get("WARC-Type") != "response" {
slices.Reverse(batch.Records)
}

// Get the WARC-Target-URI value
var warcTargetURI = <-warcTargetURIChannel

Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/CorentinB/warc

go 1.20
go 1.21

require (
github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5
Expand Down

0 comments on commit 2dd25be

Please sign in to comment.