http-parser
http-parser copied to clipboard
url: treat empty port as default
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 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 http_parser? The former is faster and verifiable, and is already used in the latest Node.js.
Interesting...! Thanks for the pointer @indutny. I’ll take a look, particularly since I’m interested in pausing in my on_headers_complete callback. Would you happen to know offhand if llhttp fixes #97 or if that’s still an issue?
@nodejs/http, ping.
@nodejs/http