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

Request method is not being preserved on 307 and 308 redirects #432

Merged
merged 1 commit into from Sep 21, 2015

Conversation

jpb
Copy link
Contributor

@jpb jpb commented Sep 16, 2015

Tested on master:

➜  httparty git:(master) cat redirect.rb
require 'sinatra'

post '/redirect-307' do
  redirect '/target', 307
end

post '/target' do
  'Target'
end
➜  httparty git:(master) ruby -Ilib -rhttparty -e 'HTTParty.post "http://localhost:4567/redirect-307"'
➜  httparty git:(master) ruby redirect.rb
Puma 2.11.3 starting...
* Min threads: 0, max threads: 16
* Environment: development
* Listening on tcp://localhost:4567
== Sinatra/1.4.5 has taken the stage on 4567 for development with backup from Puma
127.0.0.1 - - [16/Sep/2015:14:22:02 -0700] "POST /redirect-307 HTTP/1.1" 307 - 0.0048
127.0.0.1 - - [16/Sep/2015:14:22:02 -0700] "GET /target HTTP/1.1" 404 443 0.0017
^C== Sinatra has ended his set (crowd applauds)

Net:HTTTP status codes should always be handled as strings. Net::HTTPReponse#new will pass through whatever you give it as the code, although a real Net::HTTPResponse status code is always a string.

http://docs.ruby-lang.org/en/2.0.0/Net/HTTPResponse.html#attribute-i-code.

On this branch:

➜  httparty git:(307-308-redirect-status-codes) ruby redirect.rbPuma 2.11.3 starting...
* Min threads: 0, max threads: 16
* Environment: development
* Listening on tcp://localhost:4567
== Sinatra/1.4.5 has taken the stage on 4567 for development with backup from Puma
127.0.0.1 - - [16/Sep/2015:14:24:36 -0700] "POST /redirect-307 HTTP/1.1" 307 - 0.0037
127.0.0.1 - - [16/Sep/2015:14:24:36 -0700] "POST /target HTTP/1.1" 200 6 0.0013
^C== Sinatra has ended his set (crowd applauds)
➜  httparty git:(307-308-redirect-status-codes) ruby -Ilib -rhttparty -e 'HTTParty.post "http://localhost:4567/redirect-307"'

`Net::HTTPReponse#new` will pass through whatever you give it as the
`code`, although a real `Net::HTTPResponse` status code is always a string.

http://docs.ruby-lang.org/en/2.0.0/Net/HTTPResponse.html#attribute-i-code.
jnunemaker pushed a commit that referenced this pull request Sep 21, 2015
Request method is not being preserved on 307 and 308 redirects
@jnunemaker jnunemaker merged commit 1fcea09 into jnunemaker:master Sep 21, 2015
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.

None yet

2 participants