-
Notifications
You must be signed in to change notification settings - Fork 18
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
HTTP 1.0 request might return empty response #77
Comments
Is there a response sent? How does the server behaves, is it closing the connection after sending a response, which Prax could act upon? |
Hey @ysbaddaden, I tried tackling this again, but to no avail. I’ll share my progress with you or whoever else may stumble upon this issue. I’ve added a failing test for this at: jacksonrayhamilton@5ba56b9 I also committing a change to ProxyMiddleware#proxy to try to send the response body, plus some tracing code, here: jacksonrayhamilton@9d7e084 I’m compiling Prax from the above tracing commit and running it from the prax.cr directory like so:
If I send an HTTP 1.1 request with cURL, it works:
With the same server instance still running, if I send an HTTP 1.0 request afterwards, then that works too:
My tracing code created these logs from the last 2 requests:
However, if I restart the server, and then make an HTTP 1.0 request first, then cURL gets stuck:
Meanwhile, the tracing code produces very similar logs to the “1: 1.1, 2: 1.0” scenario:
After hanging for a few minutes, I cancel the cURL request. With the same (second) server instance still running, if I make another HTTP 1.0 request, then that one goes through:
And the following is appended to the logs:
So… yeah. Pretty odd. The code in Prax sure seems to write all the bytes of the response body when the very first request is an HTTP 1.0 request. It calls Say that I run
If I send a cURL request straight to that Rack server, it works on the first try:
I guess it’s not the server’s fault, seems to be Prax’s (or maybe Crystal’s). Not sure where to go with this at this point though. |
I think this is Prax' fault. It may get confused somewhere. I assume the Rack server is properly closing the connection since we get an EOF. Maybe Prax doesn't properly closes the client socket (despite saying so), or doesn't flush for some reason? |
Or something in the HTTP parser, in the fallback to |
If I send an HTTP 1.0 request, according to specification, I can expect the server to automatically close the connection at the end unless both the client and server send
Connection: keep-alive
.If my server’s response does not include
Transfer-Encoding: chunked
and it does not have aContent-Length
and it does not includeConnection: close
, then an HTTP 1.0 request will erroneously be blank due to this line:prax.cr/src/prax/middlewares/proxy_middleware.cr
Line 37 in e9cd772
How do we fix this? I’ve tried this:
However, for the very first request I send to a Rack server, it hangs forever even after the server starts. The second request goes through. (???) Any ideas?
The text was updated successfully, but these errors were encountered: