{"action":"created","issue":{"url":"https://api.github.com/repos/cheald/manticore/issues/29","labels_url":"https://api.github.com/repos/cheald/manticore/issues/29/labels{/name}","comments_url":"https://api.github.com/repos/cheald/manticore/issues/29/comments","events_url":"https://api.github.com/repos/cheald/manticore/issues/29/events","html_url":"https://github.com/cheald/manticore/issues/29","id":102183093,"number":29,"title":"Stubbing Content-Length header without body","user":{"login":"mikeknep","id":2057981,"avatar_url":"https://avatars.githubusercontent.com/u/2057981?v=3","gravatar_id":"","url":"https://api.github.com/users/mikeknep","html_url":"https://github.com/mikeknep","followers_url":"https://api.github.com/users/mikeknep/followers","following_url":"https://api.github.com/users/mikeknep/following{/other_user}","gists_url":"https://api.github.com/users/mikeknep/gists{/gist_id}","starred_url":"https://api.github.com/users/mikeknep/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mikeknep/subscriptions","organizations_url":"https://api.github.com/users/mikeknep/orgs","repos_url":"https://api.github.com/users/mikeknep/repos","events_url":"https://api.github.com/users/mikeknep/events{/privacy}","received_events_url":"https://api.github.com/users/mikeknep/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-08-20T16:56:24Z","updated_at":"2015-08-20T17:05:38Z","closed_at":null,"body":"I've been working on adding a Manticore adapter to WebMock, for the benefit of both myself [and others](https://github.com/bblimke/webmock/issues/454). I have all their shared adapter specs passing except for one, which attempts to stub a request and expect specific headers back but no specified body:\r\n\r\n```ruby\r\nit \"should return response with declared headers\" do\r\n  stub_request(:get, \"www.example.com\").to_return(:headers => {\"Content-Length\" => \"8888\"})\r\n  response = http_request(:get, \"http://www.example.com/\")\r\n  expect(response.headers[\"Content-Length\"]).to eq(\"8888\")\r\nend\r\n```\r\n\r\nIt looks like this isn't possible in Manticore due to [this line](https://github.com/cheald/manticore/blob/ef3c352d60ca4b45b697a7a9753e2c9780e9cbf5/lib/manticore/stubbed_response.rb#L43)—a content-length header is added to a `StubbedResponse` only if a body is present, but in line 39 above, if a body is not provided it is set to an empty string. Thus the Content-Length header in the spec above will equal zero.\r\n\r\nThe Content-Length header [should be provided](http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.13), but is not absolutely required. Given this class is specifically for stubbing, any thoughts on removing this line? Or, can you think of any alternative(s)?\r\n\r\nFYI, you can see my work [here](https://github.com/bblimke/webmock/compare/master...mikeknep:manticore)."},"comment":{"url":"https://api.github.com/repos/cheald/manticore/issues/comments/133077798","html_url":"https://github.com/cheald/manticore/issues/29#issuecomment-133077798","issue_url":"https://api.github.com/repos/cheald/manticore/issues/29","id":133077798,"user":{"login":"cheald","id":9830,"avatar_url":"https://avatars.githubusercontent.com/u/9830?v=3","gravatar_id":"","url":"https://api.github.com/users/cheald","html_url":"https://github.com/cheald","followers_url":"https://api.github.com/users/cheald/followers","following_url":"https://api.github.com/users/cheald/following{/other_user}","gists_url":"https://api.github.com/users/cheald/gists{/gist_id}","starred_url":"https://api.github.com/users/cheald/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cheald/subscriptions","organizations_url":"https://api.github.com/users/cheald/orgs","repos_url":"https://api.github.com/users/cheald/repos","events_url":"https://api.github.com/users/cheald/events{/privacy}","received_events_url":"https://api.github.com/users/cheald/received_events","type":"User","site_admin":false},"created_at":"2015-08-20T17:05:38Z","updated_at":"2015-08-20T17:05:38Z","body":"Ah, good catch! I'm going to see if I can figure out why the body value is being defaulted. If there's a good reason for it, I'll just move it after the header setup; otherwise, I'll remove it."}}