Skip to content

Commit

Permalink
fix: identity CIDs use contentTypeParser
Browse files Browse the repository at this point in the history
  • Loading branch information
SgtPooki committed Apr 10, 2024
1 parent f59e862 commit 864e810
Showing 1 changed file with 4 additions and 9 deletions.
13 changes: 4 additions & 9 deletions packages/verified-fetch/src/verified-fetch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -423,18 +423,13 @@ export class VerifiedFetch {
// if the user has specified an `Accept` header that corresponds to a raw
// type, honour that header, so for example they don't request
// `application/vnd.ipld.raw` but get `application/octet-stream`
const overriddenContentType = getOverridenRawContentType({ headers: options?.headers, accept })
if (overriddenContentType != null) {
response.headers.set('content-type', overriddenContentType)
} else {
await this.setContentType(result, path, response)
}
await this.setContentType(result, path, response, getOverridenRawContentType({ headers: options?.headers, accept }))

return response
}

private async setContentType (bytes: Uint8Array, path: string, response: Response): Promise<void> {
let contentType = 'application/octet-stream'
private async setContentType (bytes: Uint8Array, path: string, response: Response, defaultContentType = 'application/octet-stream'): Promise<void> {
let contentType: string | undefined

if (this.contentTypeParser != null) {
try {
Expand All @@ -456,7 +451,7 @@ export class VerifiedFetch {
}
}
this.log.trace('setting content type to "%s"', contentType)
response.headers.set('content-type', contentType)
response.headers.set('content-type', contentType ?? defaultContentType)
}

/**
Expand Down

0 comments on commit 864e810

Please sign in to comment.