开发者

Rails: HTTP version for response

If someone POSTs to my Rails application with HTTP version 1.0 like this:

POST /update HTTP/1.0

How do I send an HTTP version 1.0 response like this:

HTTP/1.0 200 OK

I'm using Ruby on Rails 3. Rails responses always seem to be HTTP versio开发者_运维知识库n 1.1, but if the client sends a request with HTTP version 1.0 I want to respond with HTTP version 1.0.


If you want your controller to build Header-only responses, you can use the head method. Example:

head :bad_request

Would produce the following header:

HTTP/1.1 400 Bad Request
Connection: close
Date: Sun, 24 Jan 2010 12:15:53 GMT
Transfer-Encoding: chunked
Content-Type: text/html; charset=utf-8
X-Runtime: 0.013483
Set-Cookie: _blog_session=...snip...; path=/; HttpOnly
Cache-Control: no-cache

More information

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜