为什么我在heroku上托管的瘦ruby网站上获得400 Bad Request标头

时间:2013-03-20 09:26:26

标签: ruby-on-rails curl heroku thin

我照顾www.lesscss.org。来源是https://github.com/cloudhead/lesscss.org

这是一个瘦Web应用程序,可以在heroku上运行。在浏览器中访问网站很好。

我们有一个卷曲的错误-I lesscss.org提供400请求 - https://github.com/cloudhead/less.js/issues/1232

它确实

$ curl -I lesscss.org
HTTP/1.1 400 Bad Request
Server: nginx
Date: Tue, 19 Mar 2013 01:15:50 GMT
Connection: close

我做了很多搜索,但没有找到原因或如何纠正上述原因..不应该是302重定向还是200 ok?

[编辑]

使用详细选项

$ curl -Iv http://www.lesscss.org
* About to connect() to www.lesscss.org port 80 (#0)
*   Trying 107.21.106.77...
* 0x8001f140 is at send pipe head!
* STATE: CONNECT => WAITCONNECT handle 0x80057408; line 1032 (connection #0)
* Connected to www.lesscss.org (107.21.106.77) port 80 (#0)
* STATE: WAITCONNECT => DO handle 0x80057408; line 1151 (connection #0)
> HEAD / HTTP/1.1
> User-Agent: curl/7.29.0
> Host: www.lesscss.org
> Accept: */*
>
* STATE: DO => DO_DONE handle 0x80057408; line 1236 (connection #0)
* STATE: DO_DONE => WAITPERFORM handle 0x80057408; line 1352 (connection #0)
* STATE: WAITPERFORM => PERFORM handle 0x80057408; line 1363 (connection #0)
* HTTP 1.1 or later with persistent connection, pipelining supported
< HTTP/1.1 400 Bad Request
HTTP/1.1 400 Bad Request
< Server: nginx
Server: nginx
< Date: Wed, 20 Mar 2013 09:34:37 GMT
Date: Wed, 20 Mar 2013 09:34:37 GMT
< Connection: keep-alive
Connection: keep-alive

<
* STATE: PERFORM => DONE handle 0x80057408; line 1533 (connection #0)
* Connection #0 to host www.lesscss.org left intact
* Expire cleared

2 个答案:

答案 0 :(得分:2)

您正在使用的toto引擎中包含this line

return [400, {}, []] unless @request.get?

所以任何不是get的东西都会产生400.Toto可能会允许通过头部请求(如果需要的话,可以与Rack :: Head结合使用,以便将请求主体放在地板上)

答案 1 :(得分:0)

使用-I您正在发出HEAD个请求,而不是GET。删除-I标志,它将起作用。您可以看到它如何与-v标志一起使用:

curl -Iv lesscss.org