Skip to content

Commit

Permalink
feat: add Server header with version
Browse files Browse the repository at this point in the history
  • Loading branch information
rvagg committed Aug 4, 2023
1 parent a00bdcb commit f693649
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 0 deletions.
1 change: 1 addition & 0 deletions pkg/internal/itest/http_fetch_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1068,6 +1068,7 @@ func TestHttpFetch(t *testing.T) {
req.NoError(err)
req.Failf("200 response code not received", "got code: %d, body: %s", resp.StatusCode, string(body))
}
req.Regexp(`^lassie/v\d+\.\d+\.\d+-\w+$`, resp.Header.Get("Server"))
req.Equal(fmt.Sprintf(`attachment; filename="%s.car"`, srcData[i].Root.String()), resp.Header.Get("Content-Disposition"))
req.Equal("none", resp.Header.Get("Accept-Ranges"))
req.Equal("public, max-age=29030400, immutable", resp.Header.Get("Cache-Control"))
Expand Down
2 changes: 2 additions & 0 deletions pkg/server/http/ipfs.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"net/http"
"strconv"

"github.com/filecoin-project/lassie/pkg/build"
"github.com/filecoin-project/lassie/pkg/retriever"
"github.com/filecoin-project/lassie/pkg/storage"
"github.com/filecoin-project/lassie/pkg/types"
Expand Down Expand Up @@ -147,6 +148,7 @@ func ipfsHandler(fetcher types.Fetcher, cfg HttpServerConfig) func(http.Response

carWriter.OnPut(func(int) {
// called once we start writing blocks into the CAR (on the first Put())
res.Header().Set("Server", build.UserAgent) // "lassie/vx.y.z-<git commit hash>"
res.Header().Set("Content-Disposition", fmt.Sprintf("attachment; filename=%q", fileName))
res.Header().Set("Accept-Ranges", ResponseAcceptRangesHeader)
res.Header().Set("Cache-Control", ResponseCacheControlHeader)
Expand Down

0 comments on commit f693649

Please sign in to comment.