You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In debugging vcr/vcr#245, I discovered that it is due to a bug in WebMock's excon adapter (reported there as bblimke/webmock#246). WebMock doesn't properly handle the case of a response_block being used; it assumes that response.body will have the response body (which isn't such a crazy assumption, really...), but excon's logic does not build up the body string on the response object when a response_block is used, presumably to avoid bloating memory by building up a string the client doesn't need since it's already handling it in the block.
It's an easy mistake to make, and it'd be nice if Excon surfaced the invalid use of response.body when the response block has been used. What do you think of either raising an error from response.body or returning an object from response.body that raises a clear error if any method is called on it? Either way, it would give the user a clear "you're using a response_block, so response.body isn't set; you shouldn't attempt to use it" message.
The text was updated successfully, but these errors were encountered:
@myronmarston - I can certainly see how this would be helpful and avoid confusion. I think that the current behavior of NOT filling in the body is still likely to be the right thing to do (it assumes you already used the body and so don't need it, avoids memory bloat, etc), but it can lead to confusing interactions which your proposal would certainly fix. My preference, I think, would be to have response.body itself return an error in this case. I'll try to find some time to experiment with this in the not-too-distant future. Thanks!
In debugging vcr/vcr#245, I discovered that it is due to a bug in WebMock's excon adapter (reported there as bblimke/webmock#246). WebMock doesn't properly handle the case of a
response_block
being used; it assumes thatresponse.body
will have the response body (which isn't such a crazy assumption, really...), but excon's logic does not build up the body string on the response object when a response_block is used, presumably to avoid bloating memory by building up a string the client doesn't need since it's already handling it in the block.It's an easy mistake to make, and it'd be nice if Excon surfaced the invalid use of
response.body
when the response block has been used. What do you think of either raising an error fromresponse.body
or returning an object fromresponse.body
that raises a clear error if any method is called on it? Either way, it would give the user a clear "you're using a response_block, so response.body isn't set; you shouldn't attempt to use it" message.The text was updated successfully, but these errors were encountered: