You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@hc.apache.org by GitBox <gi...@apache.org> on 2021/04/11 17:09:40 UTC
[GitHub] [httpcomponents-core] ok2c commented on a change in pull request #282: Improved parsing and formatting of URI components
ok2c commented on a change in pull request #282:
URL: https://github.com/apache/httpcomponents-core/pull/282#discussion_r611218097
##########
File path: httpcore5/src/main/java/org/apache/hc/core5/net/URIAuthority.java
##########
@@ -87,23 +64,8 @@ static URIAuthority parse(final CharSequence s, final Tokenizer.Cursor cursor) t
//Rewind
cursor.updatePos(initPos);
}
- final String hostName = tokenizer.parseContent(s, cursor, PORT_SEPARATORS);
- String portText = null;
- if (!cursor.atEnd() && s.charAt(cursor.getPos()) == ':') {
- cursor.updatePos(cursor.getPos() + 1);
- portText = tokenizer.parseContent(s, cursor, TERMINATORS);
- }
- final int port;
- if (!TextUtils.isBlank(portText)) {
- try {
- port = Integer.parseInt(portText);
- } catch (final NumberFormatException ex) {
- throw createException(s, cursor, "Authority port is invalid");
- }
- } else {
- port = -1;
- }
- return new URIAuthority(userInfo, hostName.toLowerCase(Locale.ROOT), port, true);
+ final Host host = Host.parse(s, cursor);
+ return new URIAuthority(userInfo, host.getHostName(), host.getPort());
Review comment:
@michael-o I am not sure I understand what you mean. Why does not `URIAuthority` extend `Host`?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org
For additional commands, e-mail: dev-help@hc.apache.org