Skip to content

feat(http): automatically set request Content-Type header based on body type #2903

@jeffbcross

Description

@jeffbcross

This is specific to the XhrBackend implementation, based on request body types for which it doesn't automatically set Content-Type headers.

When forming "write" requests inside of http.request, the "Content-Type" header should be set for certain request body types that the user agent doesn't implicitly set, using the body extraction steps described here: https://fetch.spec.whatwg.org/#concept-bodyinit-extract

  • JSON -> application/json
  • URLSearchParams -> application/x-www-form-urlencoded;charset=UTF-8
  • Blob -> If blob has set "type" property, set to its value

This should also be documented.

Will leave FormData up to the user-agent, so it can set the appropriate boundary.

Metadata

Metadata

Assignees

No one assigned

    Labels

    effort1: hoursfeatureLabel used to distinguish feature request from other issues

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions