Skip to content

Commit

Permalink
send the attestation after the response body
Browse files Browse the repository at this point in the history
Signed-off-by: Miroslav Bajtoš <oss@bajtos.net>
  • Loading branch information
bajtos committed Aug 1, 2023
1 parent 68ded2c commit 5cf3fb9
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions httpipfs.go
Original file line number Diff line number Diff line change
Expand Up @@ -146,13 +146,10 @@ func (hi *HttpIpfs) ServeHTTP(res http.ResponseWriter, req *http.Request) {
logError(http.StatusInternalServerError, err)
return
}
res.Header().Set(
"X-Attestation",
fmt.Sprintf(
"\"%s.%s\"",
base64.StdEncoding.EncodeToString(b),
base64.StdEncoding.EncodeToString(sigSigned),
),
attestation := fmt.Sprintf(
"\"%s.%s\"",
base64.StdEncoding.EncodeToString(b),
base64.StdEncoding.EncodeToString(sigSigned),
)

bytesWrittenCh := make(chan struct{})
Expand All @@ -165,6 +162,7 @@ func (hi *HttpIpfs) ServeHTTP(res http.ResponseWriter, req *http.Request) {
res.Header().Set("Etag", etag(rootCid, path.String(), dagScope, includeDupes))
res.Header().Set("X-Content-Type-Options", "nosniff")
res.Header().Set("X-Ipfs-Path", "/"+datamodel.ParsePath(req.URL.Path).String())
res.Header().Add("Trailer", "X-Attestation")
close(bytesWrittenCh)
})

Expand All @@ -181,6 +179,8 @@ func (hi *HttpIpfs) ServeHTTP(res http.ResponseWriter, req *http.Request) {
}
logger.Debugw("error streaming CAR", "cid", rootCid, "err", err)
}

res.Header().Set("X-Attestation", attestation)
}

var _ io.Writer = (*ipfsResponseWriter)(nil)
Expand Down

0 comments on commit 5cf3fb9

Please sign in to comment.