From 85aff44e00e836eda618d4f1cf013bce38b3fd44 Mon Sep 17 00:00:00 2001 From: Garrett D'Amore Date: Sun, 17 Nov 2024 18:23:17 -0800 Subject: URL u_port should be a number not a string. The idea here is to reduce the dynamic allocations used for URLs, and also the back and forth with parsing begin strings and port numbers. We always resolve to a port number, and this is easier for everyone. The real goal in the long term is to eliminate dynamic allocation of the URL fields altogether, but that requires a little more work. This is a step in the right direction. --- docs/ref/api/url.md | 22 +++++++++++----------- docs/ref/migrate/nng1.md | 7 +++++++ 2 files changed, 18 insertions(+), 11 deletions(-) (limited to 'docs/ref') diff --git a/docs/ref/api/url.md b/docs/ref/api/url.md index 6c104854..0928180e 100644 --- a/docs/ref/api/url.md +++ b/docs/ref/api/url.md @@ -12,16 +12,16 @@ that are not part of the IETF standards. ```c typedef struct nng_url { - char *u_rawurl; - char *u_scheme; - char *u_userinfo; - char *u_host; - char *u_hostname; - char *u_port; - char *u_path; - char *u_query; - char *u_fragment; - char *u_requri; + char *u_rawurl; + const char *u_scheme; + char *u_userinfo; + char *u_host; + char *u_hostname; + uint16_t u_port; + char *u_path; + char *u_query; + char *u_fragment; + char *u_requri; } nng_url; ``` @@ -37,7 +37,7 @@ The fields of an `nng_url` object are as follows: - `u_userinfo`: This username and password if supplied in the URL string. Will be `NULL` when not present. - `u_host`: The full host part of the URL, including the port if present (separated by a colon.) - `u_hostname`: The name of the host, and may be the empty string in some cases. -- `u_port`: The port. May be empty if irrelevant or not specified. +- `u_port`: The port. May be zero if irrelevant or not specified. - `u_path`: The path, typically used with HTTP or WebSockets. Will be empty string if not specified. - `u_query`: The query info (typically following `?` in the URL.) Will be `NULL` if not present. - `u_fragment`: This is used for specifying an anchor, the part after `#` in a URL. Will be `NULL` if not present. diff --git a/docs/ref/migrate/nng1.md b/docs/ref/migrate/nng1.md index d3440fe4..b7ddea33 100644 --- a/docs/ref/migrate/nng1.md +++ b/docs/ref/migrate/nng1.md @@ -160,4 +160,11 @@ A number of the [statistics][statistic] functions take, or return, `const nng_st of plain `nng_stat *`. The ABI has not changed, but it may be necessary to declare certain methods variables `const` to avoid warnings about misuse of `const`. +## Url Structure Members + +The details of [`nng_url`] have changed as follows: + +- `u_port` is no longer a string, but a `uint16_t` +- `u_scheme` is a const char \* + {{#include ../xref.md}} -- cgit v1.2.3-70-g09d2