New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
StringStubbingResource.render() pukes when request has headers #259
Comments
I think you're getting tripped up by a weird asymmetry in the Lines 296 to 298 in 2d28bf5
At this point Lines 316 to 318 in 2d28bf5
Now I can't defend any of this. The type mismatch is surprising API design and reassigning (This would have passed silently before twisted/twisted#999. The changes in that PR have found an amazing number of bugs.) |
(Thank you @markrwilliams for braving that spec and making it all work) |
Yes, absolutely. We should do the same with |
I have some code following the example in the docs for
treq.testing.RequestSequence
and I find that if the response tuple includes any headers, it causes an exception which shows none my my code in the traceback:After looking at
treq/testing.py:317
, I can see the problem, which is that in line293
the code creates a dict calledheaders
from the keys and values returned byrequest.requestHeaders.getAllRawHeaders()
. Note that the values in this case are lists ofbytes
.Then back in line
317
, there's a call torequest.setHeader(k, v)
, wherek
andv
are the keys and values kept inheaders
. Butrequest.setHeader()
expects values to bebytes
, not lists.I think the code should call
request.responseHeaders.setRawHeaders(k, v)
instead.The text was updated successfully, but these errors were encountered: