{"action":"created","issue":{"url":"https://api.github.com/repos/manastech/crystal/issues/1304","labels_url":"https://api.github.com/repos/manastech/crystal/issues/1304/labels{/name}","comments_url":"https://api.github.com/repos/manastech/crystal/issues/1304/comments","events_url":"https://api.github.com/repos/manastech/crystal/issues/1304/events","html_url":"https://github.com/manastech/crystal/pull/1304","id":103619915,"number":1304,"title":"Fix #1253 and disallow illegal bodies on HTTP Response","user":{"login":"lbguilherme","id":546954,"avatar_url":"https://avatars.githubusercontent.com/u/546954?v=3","gravatar_id":"","url":"https://api.github.com/users/lbguilherme","html_url":"https://github.com/lbguilherme","followers_url":"https://api.github.com/users/lbguilherme/followers","following_url":"https://api.github.com/users/lbguilherme/following{/other_user}","gists_url":"https://api.github.com/users/lbguilherme/gists{/gist_id}","starred_url":"https://api.github.com/users/lbguilherme/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lbguilherme/subscriptions","organizations_url":"https://api.github.com/users/lbguilherme/orgs","repos_url":"https://api.github.com/users/lbguilherme/repos","events_url":"https://api.github.com/users/lbguilherme/events{/privacy}","received_events_url":"https://api.github.com/users/lbguilherme/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":11,"created_at":"2015-08-28T00:06:16Z","updated_at":"2015-08-28T15:33:38Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/manastech/crystal/pulls/1304","html_url":"https://github.com/manastech/crystal/pull/1304","diff_url":"https://github.com/manastech/crystal/pull/1304.diff","patch_url":"https://github.com/manastech/crystal/pull/1304.patch"},"body":"As per [HTTP Spec, Section 7.2](http://www.w3.org/Protocols/HTTP/1.0/draft-ietf-http-spec.html#Entity-Body):\r\n\r\n> For response messages, whether or not an entity body is included with a message is dependent on both the request method and the response code. All responses to the HEAD request method must not include a body, even though the presence of entity header fields may lead one to believe they do. All 1xx (informational), 204 (no content), and 304 (not modified) responses must not include a body. All other responses must include an entity body or a Content-Length header field defined with a value of zero (0).\r\n\r\nEnsuring that a response to a HEAD request has no body is still user's responsibility.\r\nThe fix for #1253 is the last sentence."},"comment":{"url":"https://api.github.com/repos/manastech/crystal/issues/comments/135807846","html_url":"https://github.com/manastech/crystal/pull/1304#issuecomment-135807846","issue_url":"https://api.github.com/repos/manastech/crystal/issues/1304","id":135807846,"user":{"login":"asterite","id":209371,"avatar_url":"https://avatars.githubusercontent.com/u/209371?v=3","gravatar_id":"","url":"https://api.github.com/users/asterite","html_url":"https://github.com/asterite","followers_url":"https://api.github.com/users/asterite/followers","following_url":"https://api.github.com/users/asterite/following{/other_user}","gists_url":"https://api.github.com/users/asterite/gists{/gist_id}","starred_url":"https://api.github.com/users/asterite/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/asterite/subscriptions","organizations_url":"https://api.github.com/users/asterite/orgs","repos_url":"https://api.github.com/users/asterite/repos","events_url":"https://api.github.com/users/asterite/events{/privacy}","received_events_url":"https://api.github.com/users/asterite/received_events","type":"User","site_admin":false},"created_at":"2015-08-28T15:33:38Z","updated_at":"2015-08-28T15:33:38Z","body":"The problem is that the body's IO must be consumed before executing the next request. Try this:\r\n\r\n```crystal\r\nrequire \"http/client\"\r\n\r\nclient = HTTP::Client.new \"www.google.com\"\r\nresponse1 = client.get \"/\"\r\nresponse2 = client.get \"/\"\r\nputs response2.body\r\n``` \r\n\r\nI get `invalid Int32: http-equiv=\"content-type\" (ArgumentError)`.\r\n\r\nHowever, I think that one solution to this would be to have HTTP::Client store the last response. Before executing the next response it would consume the last one. The above would work (I just tried it) and we could always work with an IO.\r\n\r\n/cc @waj"}}