urldata: import port types and conn destination format

Convert more `int port` to `uint16_t` port types. Reshuffle ports in
connectdata to save some bytes. Change `conn->destination` format to

- make it more readable and thus usable in tracing
- add the IPv6 scope_id only when not default (global)
  and make it resemble more the textual format for IPv6
  (e.g. suffix '%<scope_id>')

Closes #20918
This commit is contained in:
Stefan Eissing 2026-03-13 13:34:46 +01:00 committed by Daniel Stenberg
parent dfadec7ec3
commit 9325eb5fc4
No known key found for this signature in database
GPG key ID: 5CC908FDB71E12C2
13 changed files with 54 additions and 66 deletions

View file

@ -1210,12 +1210,12 @@ CURLcode Curl_http_follow(struct Curl_easy *data, const char *newurl,
/* Clear auth if this redirects to a different port number or protocol,
unless permitted */
if(!data->set.allow_auth_to_other_hosts && (type != FOLLOW_FAKE)) {
int port;
uint16_t port;
bool clear = FALSE;
if(data->set.use_port && data->state.allow_port)
/* a custom port is used */
port = (int)data->set.use_port;
port = data->set.use_port;
else {
curl_off_t value;
char *portnum;
@ -1228,7 +1228,7 @@ CURLcode Curl_http_follow(struct Curl_easy *data, const char *newurl,
}
p = portnum;
curlx_str_number(&p, &value, 0xffff);
port = (int)value;
port = (uint16_t)value;
curlx_free(portnum);
}
if(port != data->info.conn_remote_port) {
@ -2969,7 +2969,7 @@ static CURLcode http_add_hd(struct Curl_easy *data,
#ifndef CURL_DISABLE_ALTSVC
case H1_HD_ALT_USED:
if(conn->bits.altused && !Curl_checkheaders(data, STRCONST("Alt-Used")))
result = curlx_dyn_addf(req, "Alt-Used: %s:%d\r\n",
result = curlx_dyn_addf(req, "Alt-Used: %s:%u\r\n",
conn->conn_to_host.name,
conn->conn_to_port);
break;