POST request mysteriously turn into GET request

自闭症网瘾萝莉.ら 提交于 2019-12-01 11:07:38

问题


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



来源:https://stackoverflow.com/questions/24028322/post-request-mysteriously-turn-into-get-request

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!