Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Always set CONTENT_TYPE for non-GET requests #223

Merged
merged 3 commits into from
Mar 27, 2018

Commits on Mar 9, 2018

  1. Always set CONTENT_TYPE for non-GET requests

    ...even when no parameters are provided (or the provided parameters are `nil`)
    
    The long story:
    
    - #132 changed the behavior for HTTP DELETE requests to behave like GET: put the parameters in the query string, and don't set the Content-Type. This change was merged in d016695
    - This broke `rack-test` for certain people, which was highlighted in #200. Arguably, the change incorporated in d016695 was too brutal.
    - #212 tried to sort it out, by not setting Content-Type if params are nil, and also reverting the change to put DELETE parameters in the query string. The first part of this (params being nil) caused issues for certain people.
    
    So this PR now tries to once and for all sort this out by:
    
    - Always setting `env['CONTENT_TYPE']`, even when params are `nil`.
    - Adding more tests for how `CONTENT_TYPE` and `CONTENT_LENGTH` should behave; some of this does not come from us, but from Rack upstream.
    - Settles with the discussion in #220: if you are using `DELETE` and must use query params, put them manually in there like this: `delete '/foo?bar=baz'`. Arguably not very clean, but better than changing back and forth. `params` are overloaded in rack 0.x and will be so in 1.0 also. I am thinking that we should go with the excellent suggestion provided by @malacalypse in #200 to use dedicated `body` and `params` parameters in the long run (and probably use keyword parameters instead, but that's definitely a 2.x feature since it breaks all existing usage.) For now, I think we'll live with the ugliness.
    
    I encourage everyone to give this a try before we merge, to ensure we don't have to revert once more.
    perlun committed Mar 9, 2018
    Configuration menu
    Copy the full SHA
    f80a2c1 View commit details
    Browse the repository at this point in the history

Commits on Mar 10, 2018

  1. Configuration menu
    Copy the full SHA
    ad1ecf7 View commit details
    Browse the repository at this point in the history

Commits on Mar 12, 2018

  1. Configuration menu
    Copy the full SHA
    d7164e5 View commit details
    Browse the repository at this point in the history