Skip to content

stripContentType

reference
1 min readUpdated

Kind: Function

Source: atloria-monorepo/packages/ui-core/src/components/api-explorer/multipart.ts

Remove any Content-Type header, whoever set it.

THE upload bug, and the reason this is a named function used at every send path rather than a line inside one of them: multipart/form-data is meaningless without the boundary= token, and only the thing serializing the body knows the boundary it chose. Setting the header by hand — or leaving behind the application/json default this panel seeds for ordinary requests — hands the server a body it cannot parse and an error message that blames the file. Case-insensitive because header maps are, and readers type content-type.

Signature

ts
function stripContentType(headers: Record<string, string>): Record<string, string>

Parameters

NameType
headersRecord<string, string>

Returns: Record<string, string>

Was this page helpful?

Download as PDF