Skip to content
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

Curl hangs on 204: No-Content with Transfer-Encoding: chunked #3968

Closed
omarroth opened this issue May 30, 2019 · 2 comments

Comments

Projects
None yet
2 participants
@omarroth
Copy link

commented May 30, 2019

I did this

Ran curl http://localhost:8080 -trace - against minimal example:

from http.server import HTTPServer, BaseHTTPRequestHandler

class HTTPRequestHandler(BaseHTTPRequestHandler):
    def do_GET(self):
        self.send_response(204)
        self.send_header('Connection', 'keep-alive')
        self.send_header('Transfer-Encoding', 'chunked')
        # self.send_header('Content-Length', '0')
        self.end_headers()

httpd = HTTPServer(('localhost', 8080), HTTPRequestHandler)
httpd.serve_forever()

I expected the following

Expected curl to terminate, instead hangs permanently or until exited.

Similar issue described in https://serverfault.com/q/870072 from 2017, although doesn't appear to have been reported.

As an important note testing with #3702 the above works as expected. Since the mentioned PR appears to be fixing a different issue I think it's still important to mention here, but please let me know if this should be closed in favor of #3702.

curl/libcurl version

curl 7.64.1 (x86_64-pc-linux-gnu) libcurl/7.64.1 OpenSSL/1.1.1b zlib/1.2.11 libidn2/2.1.1 libpsl/0.20.2 (+libidn2/2.1.1) libssh2/1.8.2 nghttp2/1.36.0
Release-Date: 2019-03-27
Protocols: dict file ftp ftps gopher http https imap imaps pop3 pop3s rtsp scp sftp smb smbs smtp smtps telnet tftp 
Features: AsynchDNS GSS-API HTTP2 HTTPS-proxy IDN IPv6 Kerberos Largefile libz NTLM NTLM_WB PSL SPNEGO SSL TLS-SRP UnixSockets

operating system

$ uname -srv
Linux 5.1.5-arch1-2-ARCH #1 SMP PREEMPT Mon May 27 03:37:39 UTC 2019
@bagder

This comment has been minimized.

Copy link
Member

commented May 31, 2019

it appears #3702 fixes this

Can you try it and see that it actually does fix it for you?

@bagder bagder added the HTTP label May 31, 2019

@omarroth

This comment has been minimized.

Copy link
Author

commented May 31, 2019

Yep, I checked before opening this, testing with #3702 works as expected. Sorry for not being clear.

bagder added a commit that referenced this issue Jun 2, 2019

http: don't parse body-related headers bodyless responses
Responses with status codes 1xx, 204 or 304 don't have a response body. For
these, don't parse these headers:

- Content-Encoding
- Content-Length
- Content-Range
- Last-Modified
- Transfer-Encoding

This change ensures that HTTP/2 upgrades work even if a
"Content-Length: 0" or a "Transfer-Encoding: chunked" header is present.

Co-authored-by: Daniel Stenberg
Closes #3702
Fixes #3968

@bagder bagder closed this in 2e5ceb3 Jun 2, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.