Repository navigation
curl request snippet for a HEAD request hangs waiting for a response body - #1087
Merged
Merged
Conversation
Previously, the curl request snippet for a HEAD request used -X HEAD. This only changes the method name, so curl still waited for a response body that is never sent and the documented command hung until it timed out. -I is now used instead, which also includes the response headers in the output. Signed-off-by: chuuminggg <rorrxr@naver.com> See spring-projectsgh-1087
wilkinsona
force-pushed
the
curl-head-request
branch
from
November 13, 2026 08:46
f5b6d3f to
0b6536c
Compare
Member
|
Thanks again, @chuuminggg. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
For a
HEADrequest, the curl request snippet uses-X HEAD:$ curl 'http://localhost:8080/items' -i -X HEAD-Xonly changes the method name in the request. It doesn't change how curl handles the response, so curl still waits for the number of bytes in theContent-Lengthheader. A response to aHEADrequest has no body, so the documented command hangs until it times out. curl's documentation for-Xsays the same: "if you want to make a proper HEAD request, using -X HEAD does not suffice. You need to use the --head option." (-Iis the short form of--head.)I checked this with curl 8.16.0 against a local server that answers
HEADwithContent-Length: 13and no body:curl '…/foo' -i -u 'user:secret' -X HEAD -H 'Accept: application/json' --max-time 5curl: (28) Operation timed out after 5002 milliseconds with 0 out of 13 bytes receivedcurl '…/foo' -I -u 'user:secret' -H 'Accept: application/json' --max-time 5The server received the same request from both commands: method
HEAD, theAuthorizationheader, and theAcceptheader.This PR makes the snippet use
-Iinstead of-i -X HEADfor aHEADrequest.-Ialso includes the response headers in the output, so it replaces-ias well. The snippets for other methods are unchanged. The HTTPie snippet doesn't need a change, ashttp HEAD …already makes a properHEADrequest.