You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@hc.apache.org by "Marco Bungart (Jira)" <ji...@apache.org> on 2024/01/15 15:03:00 UTC
[jira] [Updated] (HTTPCORE-763) Behaviour of BasicHttpRequest wrt. path is inconsistent
[ https://issues.apache.org/jira/browse/HTTPCORE-763?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Marco Bungart updated HTTPCORE-763:
-----------------------------------
Description:
The [Setter for {{path}} in {{BasicHttpRequest}}|https://github.com/apache/httpcomponents-core/blob/26b3bc6d6dc56587afdb12d84361009d55a5197f/httpcore5/src/main/java/org/apache/hc/core5/http/message/BasicHttpRequest.java#L210] checks whether the parameter {{path}} starts with two slashes and - if so - throws an {{IllegalArgumentException}} (through the call to [{{Args.check(...)}}|https://github.com/apache/httpcomponents-core/blob/26b3bc6d6dc56587afdb12d84361009d55a5197f/httpcore5/src/main/java/org/apache/hc/core5/util/Args.java#L39]. Similarly, method [{{setUri(...)}}|https://github.com/apache/httpcomponents-core/blob/26b3bc6d6dc56587afdb12d84361009d55a5197f/httpcore5/src/main/java/org/apache/hc/core5/http/message/BasicHttpRequest.java#L264] checks the raw path from tur {{URI}}.
This leads to inconsistent behaviour. A constructor call like:
{code:java}
new BasicHttpRequest("GET", "http", URIAuthority.create("google.com"), "//search/asdf?q=foobar");
{code}
works fine, while a constructor call like:
{code:java}
new BasicHttpRequest("GET", "http", URIAuthority.create("google.com"), "doesNotMatter")
.setPath("//search/asdf?q=foobar");
{code}
or
{code:java}
new BasicHttpRequest("GET", URI.create("https://www.google.com//search/asdf?q=foobar"));
{code}
throws an {{{}IllegalArgumentException{}}}.
The Class {{BasicHttpRequest}} was extended in [commit {{1614d5d}}|https://github.com/apache/httpcomponents-core/commit/1614d5d5a5de6f4faadff9ecb566982d56b65179] and is present since.
I think what should happen is that the path should only be checked for {{//}} if the {{authority}} is not set since [RFC 3986 in section 3|https://www.rfc-editor.org/rfc/rfc3986#section-3] specifies:
{code}
The scheme and path components are required, though the path may be
empty (no characters). When authority is present, the path must
either be empty or begin with a slash ("/") character. When
authority is not present, the path cannot begin with two slash
characters ("//").
{code}
was:
The [Setter for {{path}} in {{BasicHttpRequest}}|https://github.com/apache/httpcomponents-core/blob/26b3bc6d6dc56587afdb12d84361009d55a5197f/httpcore5/src/main/java/org/apache/hc/core5/http/message/BasicHttpRequest.java#L210] checks whether the parameter {{path}} starts with two slashes and - if so - throws an {{IllegalArgumentException}} (through the call to [{{Args.check(...)}}|https://github.com/apache/httpcomponents-core/blob/26b3bc6d6dc56587afdb12d84361009d55a5197f/httpcore5/src/main/java/org/apache/hc/core5/util/Args.java#L39]. Similarly, method [{{setUri(...)}}|https://github.com/apache/httpcomponents-core/blob/26b3bc6d6dc56587afdb12d84361009d55a5197f/httpcore5/src/main/java/org/apache/hc/core5/http/message/BasicHttpRequest.java#L264] checks the raw path from tur {{URI}}.
This leads to inconsistent behaviour. A constructor call like:
{code:java}
new BasicHttpRequest("GET", "http", URIAuthority.create("google.com"), "//search/asdf?q=foobar");
{code}
works fine, while a constructor call like:
{code:java}
new BasicHttpRequest("GET", "http", URIAuthority.create("google.com"), "doesNotMatter")
.setPath("//search/asdf?q=foobar");
{code}
or
{code:java}
new BasicHttpRequest("GET", URI.create("https://www.google.com//foo"));
{code}
throws an {{{}IllegalArgumentException{}}}.
The Class {{BasicHttpRequest}} was extended in [commit {{1614d5d}}|https://github.com/apache/httpcomponents-core/commit/1614d5d5a5de6f4faadff9ecb566982d56b65179] and is present since.
I think what should happen is that the path should only be checked for {{//}} if the {{authority}} is not set since [RFC 3986 in section 3|https://www.rfc-editor.org/rfc/rfc3986#section-3] specifies:
{code}
The scheme and path components are required, though the path may be
empty (no characters). When authority is present, the path must
either be empty or begin with a slash ("/") character. When
authority is not present, the path cannot begin with two slash
characters ("//").
{code}
> Behaviour of BasicHttpRequest wrt. path is inconsistent
> -------------------------------------------------------
>
> Key: HTTPCORE-763
> URL: https://issues.apache.org/jira/browse/HTTPCORE-763
> Project: HttpComponents HttpCore
> Issue Type: Bug
> Components: HttpCore
> Affects Versions: 5.1, 5.2, 5.3-alpha1
> Reporter: Marco Bungart
> Priority: Minor
>
> The [Setter for {{path}} in {{BasicHttpRequest}}|https://github.com/apache/httpcomponents-core/blob/26b3bc6d6dc56587afdb12d84361009d55a5197f/httpcore5/src/main/java/org/apache/hc/core5/http/message/BasicHttpRequest.java#L210] checks whether the parameter {{path}} starts with two slashes and - if so - throws an {{IllegalArgumentException}} (through the call to [{{Args.check(...)}}|https://github.com/apache/httpcomponents-core/blob/26b3bc6d6dc56587afdb12d84361009d55a5197f/httpcore5/src/main/java/org/apache/hc/core5/util/Args.java#L39]. Similarly, method [{{setUri(...)}}|https://github.com/apache/httpcomponents-core/blob/26b3bc6d6dc56587afdb12d84361009d55a5197f/httpcore5/src/main/java/org/apache/hc/core5/http/message/BasicHttpRequest.java#L264] checks the raw path from tur {{URI}}.
> This leads to inconsistent behaviour. A constructor call like:
> {code:java}
> new BasicHttpRequest("GET", "http", URIAuthority.create("google.com"), "//search/asdf?q=foobar");
> {code}
> works fine, while a constructor call like:
> {code:java}
> new BasicHttpRequest("GET", "http", URIAuthority.create("google.com"), "doesNotMatter")
> .setPath("//search/asdf?q=foobar");
> {code}
> or
> {code:java}
> new BasicHttpRequest("GET", URI.create("https://www.google.com//search/asdf?q=foobar"));
> {code}
> throws an {{{}IllegalArgumentException{}}}.
> The Class {{BasicHttpRequest}} was extended in [commit {{1614d5d}}|https://github.com/apache/httpcomponents-core/commit/1614d5d5a5de6f4faadff9ecb566982d56b65179] and is present since.
> I think what should happen is that the path should only be checked for {{//}} if the {{authority}} is not set since [RFC 3986 in section 3|https://www.rfc-editor.org/rfc/rfc3986#section-3] specifies:
> {code}
> The scheme and path components are required, though the path may be
> empty (no characters). When authority is present, the path must
> either be empty or begin with a slash ("/") character. When
> authority is not present, the path cannot begin with two slash
> characters ("//").
> {code}
--
This message was sent by Atlassian Jira
(v8.20.10#820010)
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org
For additional commands, e-mail: dev-help@hc.apache.org