Skip to content

common,server: handle bracketed IPv6 literals in URL authority - #25140

Merged
ngxson merged 2 commits into
ggml-org:masterfrom
ServeurpersoCom:server/rfc3986-ipv6-authority
Jun 30, 2026
Merged

ngxson merged 2 commits into
ggml-org:masterfrom
ServeurpersoCom:server/rfc3986-ipv6-authority

Conversation

@ServeurpersoCom

Copy link
Copy Markdown
Contributor

Overview

IPv6 hosts now show up correctly in the server logs: "http://[::1]:8080" instead of the broken "http://::1:8080". While at it, the same bracketing fix is applied wherever the server builds a URL or a Host header, so IPv6 upstreams in router mode behave too.

0.01.568.756 I srv  llama_server: model loaded
0.01.568.760 I srv  llama_server: listening on http://[::1]:18080

Additional information

Parse the [host]:port form (RFC 3986) and bracket IPv6 hosts when formatting a URL authority: listening log, proxy Host header, proxy log, client rebuild. The per-request remote_addr stays bare.

Fixes #25135

Requirements

Parse the [host]:port form (RFC 3986) and bracket IPv6 hosts when
formatting a URL authority: listening log, proxy Host header, proxy
log, client rebuild. The per-request remote_addr stays bare.
@ServeurpersoCom
ServeurpersoCom requested review from a team as code owners June 29, 2026 17:00
@ServeurpersoCom
ServeurpersoCom requested a review from ngxson June 29, 2026 17:01
Comment thread common/http.h
} else if (parts.scheme == "https") {
parts.port = 443;
} else {
throw std::runtime_error("unsupported URL scheme: " + parts.scheme);

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is wrong, it should throw an error if someone try, let's say for example, using rtsp:// protocol

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did that, but I think it's redundant with the check at the beginning of the function, where we already test whether we're using http(s): https://github.com/ggml-org/llama.cpp/blob/master/common/http.h#L23-L25 WDYT?

Address @ngxson review: keep the explicit reject in port resolution so
the block stays self-contained. Non-http(s) schemes still throw (also
gated at the top of common_http_parse_url).
@ngxson
ngxson merged commit 799fcc0 into ggml-org:master Jun 30, 2026
24 of 25 checks passed
@mutativesystems

Copy link
Copy Markdown

The IPv6 cult sends their sincere gratitude

turbo-tan pushed a commit to turbo-tan/llama.cpp-tq3 that referenced this pull request Jul 1, 2026
…org#25140)

* common,server: handle bracketed IPv6 literals in URL authority

Parse the [host]:port form (RFC 3986) and bracket IPv6 hosts when
formatting a URL authority: listening log, proxy Host header, proxy
log, client rebuild. The per-request remote_addr stays bare.

* common: restore unsupported scheme throw in url parser

Address @ngxson review: keep the explicit reject in port resolution so
the block stays self-contained. Non-http(s) schemes still throw (also
gated at the top of common_http_parse_url).
DFveloper pushed a commit to DFveloper/aikar-engine that referenced this pull request Jul 3, 2026
…org#25140)

* common,server: handle bracketed IPv6 literals in URL authority

Parse the [host]:port form (RFC 3986) and bracket IPv6 hosts when
formatting a URL authority: listening log, proxy Host header, proxy
log, client rebuild. The per-request remote_addr stays bare.

* common: restore unsupported scheme throw in url parser

Address @ngxson review: keep the explicit reject in port resolution so
the block stays self-contained. Non-http(s) schemes still throw (also
gated at the top of common_http_parse_url).
adrianhoehne pushed a commit to adrianhoehne/llama.cpp that referenced this pull request Jul 5, 2026
…org#25140)

* common,server: handle bracketed IPv6 literals in URL authority

Parse the [host]:port form (RFC 3986) and bracket IPv6 hosts when
formatting a URL authority: listening log, proxy Host header, proxy
log, client rebuild. The per-request remote_addr stays bare.

* common: restore unsupported scheme throw in url parser

Address @ngxson review: keep the explicit reject in port resolution so
the block stays self-contained. Non-http(s) schemes still throw (also
gated at the top of common_http_parse_url).
zommiommy pushed a commit to zommiommy/llama.cpp that referenced this pull request Aug 18, 2026
…org#25140)

* common,server: handle bracketed IPv6 literals in URL authority

Parse the [host]:port form (RFC 3986) and bracket IPv6 hosts when
formatting a URL authority: listening log, proxy Host header, proxy
log, client rebuild. The per-request remote_addr stays bare.

* common: restore unsupported scheme throw in url parser

Address @ngxson review: keep the explicit reject in port resolution so
the block stays self-contained. Non-http(s) schemes still throw (also
gated at the top of common_http_parse_url).
zbrad pushed a commit to zbrad/llama.cpp that referenced this pull request Sep 10, 2026
…org#25140)

* common,server: handle bracketed IPv6 literals in URL authority

Parse the [host]:port form (RFC 3986) and bracket IPv6 hosts when
formatting a URL authority: listening log, proxy Host header, proxy
log, client rebuild. The per-request remote_addr stays bare.

* common: restore unsupported scheme throw in url parser

Address @ngxson review: keep the explicit reject in port resolution so
the block stays self-contained. Non-http(s) schemes still throw (also
gated at the top of common_http_parse_url).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Misc. bug: log says http://::1:8080 instead of http://[::1]:8080

3 participants