You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@hc.apache.org by "Varun Nandi (JIRA)" <ji...@apache.org> on 2019/04/23 23:59:00 UTC

[jira] [Updated] (HTTPCLIENT-1986) URIBuilder isPathEmpty method doesn't check if encodedPath is empty

     [ https://issues.apache.org/jira/browse/HTTPCLIENT-1986?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Varun Nandi updated HTTPCLIENT-1986:
------------------------------------
    Description: 
A new method isPathEmpty() is added to URIBuilder recently. The method checks if encodedPath  is null but doesn't check if encodedPath is an empty string. This method is used in [URIUtils.rewriteURI method|[https://github.com/apache/httpcomponents-client/blob/4.5.x/httpclient/src/main/java/org/apache/http/client/utils/URIUtils.java#L229-L231]] . When normalization is enabled, URIBuilder#setPathSegments will make encodedPath as null and so uribuilder.isPathEmpty() resolves to true [here|[https://github.com/apache/httpcomponents-client/blob/4.5.x/httpclient/src/main/java/org/apache/http/client/utils/URIUtils.java#L229]]. 

But when normalization is disabled, uribuilder.isPathEmpty() is evaluated to false and the final built URI will not contain a forward slash. This cause API calls to fail in my application.

Check the linked PR. It added a unit test that failed before this change is made.

  was:
A new method isPathEmpty() is added to URIBuilder recently. The method checks if encodedPath  is null but doesn't check if encodedPath is an empty string. This method is used in [URIUtils.rewriteURI method|[https://github.com/apache/httpcomponents-client/blob/4.5.x/httpclient/src/main/java/org/apache/http/client/utils/URIUtils.java#L229-L231]]. When normalization is enabled, URIBuilder#setPathSegments will make encodedPath as null and so uribuilder.isPathEmpty() resolves to true [here|[https://github.com/apache/httpcomponents-client/blob/4.5.x/httpclient/src/main/java/org/apache/http/client/utils/URIUtils.java#L229]]. 

But when normalization is disabled, uribuilder.isPathEmpty() is evaluated to false and the final built URI will not contain a forward slash. This cause API calls to fail in my application.

Check the linked PR. It added a unit test that failed before this change is made.


> URIBuilder isPathEmpty method doesn't check if encodedPath is empty
> -------------------------------------------------------------------
>
>                 Key: HTTPCLIENT-1986
>                 URL: https://issues.apache.org/jira/browse/HTTPCLIENT-1986
>             Project: HttpComponents HttpClient
>          Issue Type: Bug
>    Affects Versions: 4.5.8
>            Reporter: Varun Nandi
>            Priority: Major
>              Labels: Bug, pull-request-available
>             Fix For: 4.5.9
>
>
> A new method isPathEmpty() is added to URIBuilder recently. The method checks if encodedPath  is null but doesn't check if encodedPath is an empty string. This method is used in [URIUtils.rewriteURI method|[https://github.com/apache/httpcomponents-client/blob/4.5.x/httpclient/src/main/java/org/apache/http/client/utils/URIUtils.java#L229-L231]] . When normalization is enabled, URIBuilder#setPathSegments will make encodedPath as null and so uribuilder.isPathEmpty() resolves to true [here|[https://github.com/apache/httpcomponents-client/blob/4.5.x/httpclient/src/main/java/org/apache/http/client/utils/URIUtils.java#L229]]. 
> But when normalization is disabled, uribuilder.isPathEmpty() is evaluated to false and the final built URI will not contain a forward slash. This cause API calls to fail in my application.
> Check the linked PR. It added a unit test that failed before this change is made.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org
For additional commands, e-mail: dev-help@hc.apache.org