Repository navigation
common : end the URL authority at '?' so query-only URLs keep their query - #28866
Open
parveshsaini wants to merge 1 commit into
Open
parveshsaini wants to merge 1 commit into
parveshsaini wants to merge 1 commit into
Conversation
|
Hi @parveshsaini, thanks for your contribution! Per our contribution guidelines, the automated PR checker found the following issue(s) that need your attention:
Please note that maintainers reserve the right to make final decisions on PRs. If you believe there is a mistake, please comment below. |
ngxson
requested changes
Sep 21, 2026
Collaborator
There was a problem hiding this comment.
remove it
AGENTS.md explicitly says
Do NOT add a new file in
tests/*without maintainers' approval.
Author
There was a problem hiding this comment.
test file removed, rebased on master 👍
…uery common_http_parse_url() terminated the authority only at '/', so a URL with a query but no path (e.g. https://example.com?download=1) put the query into the host and reduced the path to '/'. Terminate the authority at the first '/' or '?' instead.
parveshsaini
force-pushed
the
parveshsaini/fix/http-query-only-url
branch
from
September 21, 2026 10:14
efd81c2 to
f14484d
Compare
This branch has not been deployed
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.
Fixes #28400
If a URL has a query string but no path, like
https://example.com?download=1,common_http_parse_url()gets the host wrong. It only looked for the first/to find where the host ends. RFC 3986 says?ends it too, so that URL came out ashost=example.com?download=1andpath=/.That broke two things.
common_http_client()builds thehttplib::Clientfrom that host, so it tried to connect to a name that doesn't exist. And the query string never made it into the request.The fix swaps the split to
rest.find_first_of("/?"), so the host now stops at whichever of/or?comes first. Everything after that, including the leading?, is kept as the request path.Hosts, ports, userinfo and bracketed IPv6 addresses parse the same as before. The only URLs that parse differently are the ones that used to end up with a
?inside the host.Since this parser is shared, the fix also applies to:
-mu/--model-urldownloads (common/download.cpp)common/hf-cache.cppI added
tests/test-http.cppas a regression test. It checks the scheme, host, port and path for the query-only URL. It fails onmasterand passes with this change.Requirements
Verification
I ran both checks in an
ubuntu:24.04Docker container.With the fix: full CMake build of the test target with
-DLLAMA_FATAL_WARNINGS=ON, then ran the test.All 261 targets built, with no warnings or errors.
Without the fix: I compiled the same
tests/test-http.cppagainstcommon/http.hfromupstream/master.What changed:
/or?comes first") right after the code.