Skip to content

Commit

Permalink
fix(fetch): remove the Blob-based Content-Type header setting to matc…
Browse files Browse the repository at this point in the history
…h xhr behavior;
  • Loading branch information
DigitalBrainJS committed Apr 28, 2024
1 parent 30f66fd commit f4b9f16
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions lib/adapters/fetch.js
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,8 @@ export default async (config) => {

let contentTypeHeader;

if ((utils.isFormData(data) || utils.isBlob(data)) && (contentTypeHeader = _request.headers.get('content-type'))) {
headers.setContentType(contentTypeHeader, true)
if (utils.isFormData(data) && (contentTypeHeader = _request.headers.get('content-type'))) {
headers.setContentType(contentTypeHeader)
}

data = trackStream(_request.body, DEFAULT_CHUNK_SIZE, fetchProgressDecorator(
Expand Down
4 changes: 2 additions & 2 deletions lib/helpers/resolveConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export default (config) => {

newConfig.headers = headers = AxiosHeaders.from(headers);

newConfig.url = buildURL(buildFullPath(newConfig.baseURL, newConfig.url), config.params, config.paramsSerializer)
newConfig.url = buildURL(buildFullPath(newConfig.baseURL, newConfig.url), config.params, config.paramsSerializer);

// HTTP basic authentication
if (auth) {
Expand All @@ -27,7 +27,7 @@ export default (config) => {

if (utils.isFormData(data)) {
if (platform.hasStandardBrowserEnv || platform.hasStandardBrowserWebWorkerEnv) {
headers.setContentType(false); // Let the browser set it
headers.setContentType(undefined); // Let the browser set it
} else if ((contentType = headers.getContentType()) !== false) {
// fix semicolon duplication issue for ReactNative FormData implementation
const [type, ...tokens] = contentType ? contentType.split(';').map(token => token.trim()).filter(Boolean) : [];
Expand Down

0 comments on commit f4b9f16

Please sign in to comment.