Skip to content

Comments

Fixing overwrite Blob/File type as Content-Type in browser. (#1773)#7

Open
MitchLewis930 wants to merge 1 commit intopr_027_beforefrom
pr_027_after
Open

Fixing overwrite Blob/File type as Content-Type in browser. (#1773)#7
MitchLewis930 wants to merge 1 commit intopr_027_beforefrom
pr_027_after

Conversation

@MitchLewis930
Copy link

PR_027

@greptile-apps
Copy link

greptile-apps bot commented Jan 29, 2026

Greptile Overview

Greptile Summary

Added logic to delete the Content-Type header when sending Blob or File objects that have a type property, allowing the browser to automatically set the correct MIME type based on the file's type property.

Confidence Score: 3/5

  • This PR has moderate risk due to being a previously reverted change without clear documentation of what issue caused the original revert
  • The code change itself is logical and mirrors the existing FormData pattern, but this exact change was reverted in PR Revert "Fixing overwrite Blob/File type as Content-Type in browser." axios/axios#3289. Without understanding why it was reverted or what has changed to make it safe now, there's uncertainty about potential edge cases or breaking changes
  • No files require special attention beyond verifying the historical revert reason

Important Files Changed

Filename Overview
lib/adapters/xhr.js Added Content-Type header deletion for Blob/File objects with type property to allow browser to set correct MIME type

Sequence Diagram

sequenceDiagram
    participant User
    participant axios
    participant xhrAdapter
    participant Browser
    participant Server

    User->>axios: Send request with Blob/File data
    axios->>xhrAdapter: xhrAdapter(config)
    xhrAdapter->>xhrAdapter: Check if data is FormData
    alt data is FormData
        xhrAdapter->>xhrAdapter: Delete Content-Type header
    end
    xhrAdapter->>xhrAdapter: Check if data is Blob/File with type property
    alt data is Blob/File AND has type property
        xhrAdapter->>xhrAdapter: Delete Content-Type header
    end
    xhrAdapter->>Browser: Create XMLHttpRequest
    xhrAdapter->>Browser: Set headers (excluding Content-Type if deleted)
    Browser->>Browser: Automatically set Content-Type from Blob.type
    Browser->>Server: Send XHR with correct Content-Type
    Server-->>Browser: Response
    Browser-->>xhrAdapter: Response data
    xhrAdapter-->>axios: Resolved Promise
    axios-->>User: Response
Loading

Copy link

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1 file reviewed, no comments

Edit Code Review Agent Settings | Greptile

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants