Skip to content

feat. Req: ability to suppress default content-type #596

Open

Description

@ityonemo

I have been mocking a (poorly written) HTTP request by a coworker and after a lot of debugging found that the request was failing to emit a content-type header, it might be nice to suppress the default content-type with an option or by pre-setting it to the atom undefined.

Activity

  1. benoitc commented on Apr 17, 2020

    @benoitc
    Owner

    in which case you don't want to send a content-type header ?

  2. joeapearson commented on Dec 17, 2020

    @joeapearson

    I came across this need too when implementing a call to make this request: https://docs.microsoft.com/en-us/rest/api/storageservices/create-container

    It's an HTTP PUT with no body specified, so (I assume) a Content-Type header is not appropriate in this context.

    As it happens, MS Azure doesn't seem to care about the default application/octet-stream that is added so I was able to work around easily. I did however end up spending an hour or two of hunting around while I tried to figure out where it was coming from :).

  3. paulo-ferraz-oliveira commented on Dec 19, 2020

    @paulo-ferraz-oliveira
    Contributor

    Some context... RFC 2616 states "The presence of a message-body in a request is signaled by the inclusion of a Content-Length or Transfer-Encoding header field in the request's message-headers. [...] if the request method does not include defined semantics for an entity-body, then the message-body SHOULD be ignored when handling the request.", so I guess what hackney could do is suppress content-type, by default, if no body is present in the request (i.e. if content-length =:= 0). (this would prevent an option being required). Some care might also be required for transfer-encoding (I mainly found references to chunked in the source).

  4. joeapearson commented on Dec 22, 2020

    @joeapearson

    @paulo-ferraz-oliveira thanks. Suppressing content-type as you describe sounds sensible and would work for my particular use case.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions