Generate a Content-Length if none given #133

cgriego opened this Issue Sep 15, 2011 · 2 comments

2 participants


Turns out ActiveResource now requires a Content-Length header for it to update a model instance after creating or updating a record. None of our mocks were setting this, and it's a real pain to have to set this on each mock instance. Webmock should be able to fill in this header from the response body size if the header wasn't provided.


I understand the problem. Not sure whether adding Content-Length header by WebMock would be correct though.
If the http client library adds this header, then corresponding webmock adapter should definitely replicate this behaviour and should indeed add this header.
On the other side, if http server doesn't return this header for some reason, then webmock shouldn't do it either.
I can imagine people testing scenarios where content length is not returned (but maybe it's very unlikely)

Maybe it should be a configurable option in WebMock. I would be definitely keen on adding some kind of global settings for all request stubs to improve tests readability.


I didn't get any more requests for this feature. I'm happy to accept pull request if one finds reasonable solution.

@bblimke bblimke closed this Jan 22, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment