Skip to content

[Informative] net-http 0.7.0 indirectly breaks HTTParty - default content-type removed. #826

@danlo

Description

@danlo

Greetings,

The new version of net-http 0.7.0 breaks HTTParty indirectly. Here is the releases change log: https://github.com/ruby/net-http/releases

Default Content-Type Removed

The default behavior of automatically setting the Content-Type header to application/x-www-form-urlencoded for requests with a body (e.g., POST, PUT) when the header was not explicitly set has been removed.

For us we found out about this for the below code:

      response = HTTParty.post(
        'https://www.google.com/recaptcha/api/siteverify',
        body: encoded
      )

In this case, google was expecting: 'Content-Type: application/x-www-form-urlencoded'

Changing our code to this fixed the issue:

      response = HTTParty.post(
        'https://www.google.com/recaptcha/api/siteverify',
        headers: { 'Content-Type' => 'application/x-www-form-urlencoded' },
        body: encoded
      )

No action is requested, this is just to inform you.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions