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
After upgrading to websockets 14, websockets.connect is raising the exception NotImplementedError: transfer codings aren't supported in a scenario that previously raised InvalidStatusCode (503). I was expecting it to change to InvalidStatus, which would have been fine, but even if I catch the NotImplementedError, there is no way to extract an error code from it. The issue arises when my server, in response to the websocket upgrade request returns a 503 error, with transfer-encoding: chunked and then a short error message in the body. While it could be argued that this particular message could just use Content-Length rather than chunked encoding, this does seem like a regression on the part of websockets.
The entire back and forth looks something like this.
Request (sent with websockets 14.1):
This is happening because the legacy implementation didn't even attempt to read the HTTP response body. I added that functionality in the standard case but not in the chunked encoding case.
I believe that #1549 will wrap that error in an InvalidMessage, which is closer to what you want. However, it still doesn't give you the HTTP error code, because websockets parses the entire request first and only then starts the opening handshake logic.
I could make an argument for skipping the body rather than crashing in this case. Let me think about it.
Thanks! I guess I'll go with the legacy code for now. For the record, though, I don't really care about the message body in this case, and I don't mind altering my code, I just need some way to figure out the error code.
After upgrading to websockets 14, websockets.connect is raising the exception
NotImplementedError: transfer codings aren't supported
in a scenario that previously raised InvalidStatusCode (503). I was expecting it to change to InvalidStatus, which would have been fine, but even if I catch the NotImplementedError, there is no way to extract an error code from it. The issue arises when my server, in response to the websocket upgrade request returns a 503 error, withtransfer-encoding: chunked
and then a short error message in the body. While it could be argued that this particular message could just use Content-Length rather than chunked encoding, this does seem like a regression on the part of websockets.The entire back and forth looks something like this.
Request (sent with websockets 14.1):
Response:
The text was updated successfully, but these errors were encountered: