-
Notifications
You must be signed in to change notification settings - Fork 1.5k
url: treat empty port as default #483
base: main
Are you sure you want to change the base?
Conversation
When parsing URLs, treat an empty port (eg `http://hostname:/`) as if it were unspecified. RFC 3986 says: > URI producers and normalizers SHOULD omit the port component and its > ":" delimiter if port is empty or if its value would be the same as > that of the scheme's default. (Emphasis on the "SHOULD" is mine.) This indicates that URIs MAY be produced with an empty port and the `:` delimiter. Thus, we stop failing if we end host parsing at the port delimiter.
cc @nodejs/http : are we aware of any possible side effects that might happen in Node.js after landing this? |
@ethomson thank you for an excellent PR! The change looks great. It has to be considered in the context of Node.js too, however. Let's wait for @nodejs/http to get better understanding of interactions of this PR and Node core. |
As a side note, I wonder if libgit2 might be interested in using llhttp instead of |
@nodejs/http, ping. |
@nodejs/http |
@@ -2326,7 +2326,6 @@ http_parse_host(const char * buf, struct http_parser_url *u, int found_at) { | |||
case s_http_host_v6: | |||
case s_http_host_v6_zone_start: | |||
case s_http_host_v6_zone: | |||
case s_http_host_port_start: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This changes the behavior of http_parser_parse_url(is_connect=1)
in that it'll now allow CONNECT hostname:
as valid input, doesn't it?
When parsing URLs, treat an empty port (eg
http://hostname:/
) as if it were unspecified. RFC 3986 says:(Emphasis mine.) This indicates that URIs MAY be produced with an empty port and the
:
delimiter.Thus, we stop failing if we end host parsing at the port delimiter.