Closed SgtPooki closed 7 months ago
it looks like the incoming accept header is overriding things:
const incomingAcceptHeader = requestHeaders.get('accept');
if (incomingAcceptHeader != null) {
this.log('incoming accept header "%s"', incomingAcceptHeader);
}
const queryFormatMapping = queryFormatToAcceptHeader(query.format);
if (query.format != null) {
this.log('incoming query format "%s", mapped to %s', query.format, queryFormatMapping);
}
const acceptHeader = incomingAcceptHeader ?? queryFormatMapping;
From a browser request, this is automatically being set for me:
helia:verified-fetch incoming accept header "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8"
for a fetch request from the browser, this is also being set for me:
var resp = await fetch("http://helia-http-gateway.localhost/ipfs/bafkreialihlqnf5uwo4byh4n3cmwlntwqzxxs2fg5vanqdi3d7tb2l5xkm?format=dag-json")
var resp = await fetch("http://helia-http-gateway.localhost/ipfs/bafkreialihlqnf5uwo4byh4n3cmwlntwqzxxs2fg5vanqdi3d7tb2l5xkm?format=dag-json", {headers: {}})
// both result in: helia:verified-fetch incoming accept header "*/*"
curl also results in accept: */*
if I try var resp = await fetch("http://helia-http-gateway.localhost/ipfs/bafkreialihlqnf5uwo4byh4n3cmwlntwqzxxs2fg5vanqdi3d7tb2l5xkm?format=dag-json", {headers: { accept: undefined }})
I get
[helia] 2024-03-30T00:28:30.967Z helia-http-gateway:server fetching url "http://helia-http-gateway.localhost/ipfs/bafkreialihlqnf5uwo4byh4n3cmwlntwqzxxs2fg5vanqdi3d7tb2l5xkm?format=dag-json" with @helia/verified-fetch
[helia] 2024-03-30T00:28:30.967Z helia:verified-fetch fetch http://helia-http-gateway.localhost/ipfs/bafkreialihlqnf5uwo4byh4n3cmwlntwqzxxs2fg5vanqdi3d7tb2l5xkm?format=dag-json
[helia] 2024-03-30T00:28:30.967Z helia:verified-fetch incoming accept header "undefined"
[helia] 2024-03-30T00:28:30.967Z helia:verified-fetch incoming query format "dag-json", mapped to application/vnd.ipld.dag-json
[helia] 2024-03-30T00:28:30.967Z helia:verified-fetch output type undefined
[helia] 2024-03-30T00:28:30.968Z helia-http-gateway:server verified-fetch response not ok: 406
[helia] 2024-03-30T00:28:30.969Z helia-http-gateway:server:trace request destroyed for url "http://helia-http-gateway.localhost/ipfs/bafkreialihlqnf5uwo4byh4n3cmwlntwqzxxs2fg5vanqdi3d7tb2l5xkm?format=dag-json"
i'm doing some tests on https://github.com/ipfs/helia-http-gateway/pull/67/ and noticed one oddity. we're not converting dag-json properly? the content-type is being set, incorrectly, to
text/plain; charset=utf-8
We should be falling into the block similar to https://github.com/ipfs/helia-verified-fetch/blob/39bb14e0a7a8441ff0c323db15264435e0121b23/packages/verified-fetch/src/verified-fetch.ts#L243-L249 but it doesn't look like we have a path from
raw
todag-json
?requesting http://helia-http-gateway.localhost/ipfs/bafkreialihlqnf5uwo4byh4n3cmwlntwqzxxs2fg5vanqdi3d7tb2l5xkm?format=dag-json results in the following output from verified-fetch:
gateway conformance output is: