Join GitHub today
GitHub is home to over 20 million developers working together to host and review code, manage projects, and build software together.
Split redirect middleware (in HTTP & meta-refresh variants) [was: IOError: "Not a gzipped file"] #78
This avoids the IOError "Not a gzipped file" when the website returns
After the fix:
I think the issue is httpcompression middleware not handling the invalid declared compressed body, also by switching the order of the middlewares it will miss meta redirects in compressed bodies. And moving redirect middleware also brings some issues with cookie handling set by redirect responses.
The proposed patch is just a workaround that hides the real issue with badly declared bodies not handled correctly by httpcompression middleware.
As the issue also affects non-redirects, what about leaving the body as-is if httpcompression middleware fails to decompress it (maybe logging a warning) and handling the redirection as we normally do.
Another option is to split redirection middleware, one based on response status and hooked before httpcompression and another post httpcompression only handling meta redirects.
I still prefer first option that is general enough to fix the issue for non-redirects.
I have reverted the redirect middleware order and added tests for gzipped meta redirection. Although I'm not sure about leaving the body compressed if it fails, I think there could be more errors (ie. connection drop) that could make fail the decompression and leaving the body as is could produce misbehavior in other components.
Adding more tests for the middlewares integration could help us to identify the best solution.
This comment has been minimized.
This comment has been minimized.Show comment Hide comment
I have checked Firefox and Chrome behavior for 200, 301 and 302 response status with
Both browsers shows an error for status 200 about undecodeable body content, and both redirects to
I think we should mimic this as much as possible, possible options:
I prefer 1, it looks as the most clean approach to me