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
Cached responses are including the Content-Length header, and if that value does not match the actual content length, then things break.
The actual content length may differ in the case of a jsonp request, where the callback id may not be the same number of characters as the value that was cached.
A quick monkey patch does the trick:
# i.e add to spec_helper.rb
Billy::ProxyConnection.send(:define_method, :send_response) do |response|
res = EM::DelegatedHttpResponse.new(self)
res.status = response[:status]
res.headers = response[:headers]
res.headers.delete("Content-Length")
res.content = response[:content]
res.send_response
end
would you like a PR with this solution?
FYI I thought about simply not caching the Content-Length but that seems like a bad idea for a couple of reasons.
This problem may exist in caches that are out there in the wild, and so the above solution works in spite of that.
It just feels better to write a the Content-Length if request_headers was asked for, and then blow it away when stubbing the request.
The text was updated successfully, but these errors were encountered:
@catmando I see that @jaydorsey made a monkey patch in his puffing-billy fork, but no PR was ever submitted. If either of you submit a PR, I'd be happy to accept it.
This is the problem behind #142
Cached responses are including the Content-Length header, and if that value does not match the actual content length, then things break.
The actual content length may differ in the case of a jsonp request, where the callback id may not be the same number of characters as the value that was cached.
A quick monkey patch does the trick:
would you like a PR with this solution?
FYI I thought about simply not caching the Content-Length but that seems like a bad idea for a couple of reasons.
This problem may exist in caches that are out there in the wild, and so the above solution works in spite of that.
It just feels better to write a the Content-Length if request_headers was asked for, and then blow it away when stubbing the request.
The text was updated successfully, but these errors were encountered: