POST request mysteriously turn into GET request

2019-02-20 14:34发布

问题:

I have a Rails 4.1 application with unicorn and nginx. But somehow/mysteriously my POST request turn into GET request. Here is the request header:

Remote Address: <<IP>>
Request URL: <<URL>>
Request Method:POST
Status Code:301 Moved Permanently
Request Headersview source
Accept:text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8
Accept-Encoding:gzip,deflate,sdch
Accept-Language:en-US,en;q=0.8,ru;q=0.6,bg;q=0.4,mn;q=0.2,nb;q=0.2
Cache-Control:no-cache
Connection:keep-alive
Content-Length:14269
Content-Type:application/x-www-form-urlencoded
Cookie:<<COOKIES>>
Host:<<HOST>>
Origin:<<ORIGIN>>
Pragma:no-cache
Referer:<<REFERER>>
User-Agent:Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/35.0.1916.114 Safari/537.36
Form Dataview sourceview URL encoded
utf8:✓
authenticity_token:<<TOKEN>>
<< FORM DATA >>
Response Headersview source
Connection:keep-alive
Content-Length:184
Content-Type:text/html
Date:Wed, 04 Jun 2014 02:44:35 GMT
Location:<< REDIRECT LOCATION >>
Server:nginx/1.6.0

For security reason I hide some infos. In my development env everything working fine. Any idea? If you need more info let me know.

UPDATED: I created a new question. POST request turns into GET request

回答1:

It's because Status Code:301 Moved Permanently Just avoid that rewrite updating your form action URL or ajax request URL. (It's browser default behavior to re-request 301 anwswers with GET,I'll add a link to source info when I find it)

EDIT:

http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html

Not default, but erroneous. Maybe "common" if ajax request, I think