本文介绍了POST请求神秘地变成GET请求的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个使用Unicorn和nginx的Rails 4.1应用程序.但是以某种方式/神秘地我的POST请求变成了GET请求.这是请求标头:

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.

更新:我提出了一个新问题. POST请求变成GET请求

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

推荐答案

这是因为Status Code:301 Moved Permanently只需避免重写即可更新表单操作URL或ajax请求URL. (这是浏览器的默认行为,即使用GET重新请求301个查询,找到后会添加指向源信息的链接)

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)

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

不是默认值,但是是错误的.我认为,如果ajax请求,可能会常见"

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

这篇关于POST请求神秘地变成GET请求的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-31 17:35