You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@hc.apache.org by "Mark Woon (JIRA)" <ji...@apache.org> on 2019/03/26 02:50:00 UTC

[jira] [Updated] (HTTPCLIENT-1975) Error handling double url-encoded forward slashes

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

Mark Woon updated HTTPCLIENT-1975:
----------------------------------
    Description: 
There seems to be a bug when a path has two url-encoded forward slashes.

The following fails with a 404:

{{      try {}}
{{         String fetchUrl = "http://data.bioontology.org/ontologies/SNOMEDCT/classes/http%3A%2F%2Fpurl.bioontology.org%2Fontology%2FSNOMEDCT%2F48015001/mappings";}}
{{         try (CloseableHttpClient httpClient = HttpClients.createDefault()) {}}
{{           HttpUriRequest request = RequestBuilder.get()}}
{{               .addParameter("apikey", "my-api-key")}}
{{               .setUri(fetchUrl)}}
{{               .build();}}

{{           try (CloseableHttpResponse httpResponse = httpClient.execute(request)) {}}}}
{{             if (httpResponse.getStatusLine().getStatusCode() != 200) {}}
{{               throw new Exception("Request to " + fetchUrl + " did not succeed with code " + httpResponse.getStatusLine().getStatusCode());}}
{{             }}}
{{            System.out.println("got it");}}
{{       } catch (Exception ex) {}}
{{         ex.printStackTrace();}}
{{       }}}

 

Due to invalid api key, the expected response is 401.  However, it's getting a 404. 

When running with debug logging, I see:

{{[org.apache.http.headers] : http-outgoing-0 >> GET /ontologies/SNOMEDCT/classes/http:/purl.bioontology.org/ontology/SNOMEDCT/48015001/mappings?apikey=foo HTTP/1.1}}

{{It should instead be getting: /ontologies/SNOMEDCT/classes/http:/*{color:#d04437}/{color}*purl.bioontology.org/ontology/SNOMEDCT/48015001/mappings?apikey=foo}}

(2 slashes after http: instead of 1)

 

This worked just fine in 4.5.6.

 

Updated - edited formating.

  was:
There seems to be a bug when a path has two url-encoded forward slashes.

The following fails with a 404:

{{      try {}}
{{         String fetchUrl = "http://data.bioontology.org/ontologies/SNOMEDCT/classes/http%3A%2F%2Fpurl.bioontology.org%2Fontology%2FSNOMEDCT%2F48015001/mappings";}}
{{         try (CloseableHttpClient httpClient = HttpClients.createDefault()) {}}
{{           HttpUriRequest request = RequestBuilder.get()}}
{{               .addParameter("apikey", "my-api-key")}}
{{               .setUri(fetchUrl)}}
{{               .build();}}
{{  }}
{{           try (CloseableHttpResponse httpResponse = httpClient.execute(request)) {}}
{{             if (httpResponse.getStatusLine().getStatusCode() != 200)}}{{{               throw new Exception("Request to " + fetchUrl + " did not succeed with code " + httpResponse.getStatusLine().getStatusCode());             }}}{{ }}
{{            System.out.println("got it");}}
{{           }}}
{{         }}}
{{  }}
{{       } catch (Exception ex)}}{{{}}

{{         ex.printStackTrace();}}

{{       }}}

 

Due to invalid api key, the expected response is 401.  However, it's getting a 404. 

When running with debug logging, I see:

{{[org.apache.http.headers] : http-outgoing-0 >> GET /ontologies/SNOMEDCT/classes/http:/purl.bioontology.org/ontology/SNOMEDCT/48015001/mappings?apikey=foo HTTP/1.1}}

{{It should instead be getting: /ontologies/SNOMEDCT/classes/http:/*{color:#d04437}/{color}*purl.bioontology.org/ontology/SNOMEDCT/48015001/mappings?apikey=foo}}

(2 slashes after http: instead of 1)

 

This worked just fine in 4.5.6.

 


> Error handling double url-encoded forward slashes
> -------------------------------------------------
>
>                 Key: HTTPCLIENT-1975
>                 URL: https://issues.apache.org/jira/browse/HTTPCLIENT-1975
>             Project: HttpComponents HttpClient
>          Issue Type: Bug
>    Affects Versions: 4.5.7
>            Reporter: Mark Woon
>            Priority: Critical
>
> There seems to be a bug when a path has two url-encoded forward slashes.
> The following fails with a 404:
> {{      try {}}
> {{         String fetchUrl = "http://data.bioontology.org/ontologies/SNOMEDCT/classes/http%3A%2F%2Fpurl.bioontology.org%2Fontology%2FSNOMEDCT%2F48015001/mappings";}}
> {{         try (CloseableHttpClient httpClient = HttpClients.createDefault()) {}}
> {{           HttpUriRequest request = RequestBuilder.get()}}
> {{               .addParameter("apikey", "my-api-key")}}
> {{               .setUri(fetchUrl)}}
> {{               .build();}}
> {{           try (CloseableHttpResponse httpResponse = httpClient.execute(request)) {}}}}
> {{             if (httpResponse.getStatusLine().getStatusCode() != 200) {}}
> {{               throw new Exception("Request to " + fetchUrl + " did not succeed with code " + httpResponse.getStatusLine().getStatusCode());}}
> {{             }}}
> {{            System.out.println("got it");}}
> {{       } catch (Exception ex) {}}
> {{         ex.printStackTrace();}}
> {{       }}}
>  
> Due to invalid api key, the expected response is 401.  However, it's getting a 404. 
> When running with debug logging, I see:
> {{[org.apache.http.headers] : http-outgoing-0 >> GET /ontologies/SNOMEDCT/classes/http:/purl.bioontology.org/ontology/SNOMEDCT/48015001/mappings?apikey=foo HTTP/1.1}}
> {{It should instead be getting: /ontologies/SNOMEDCT/classes/http:/*{color:#d04437}/{color}*purl.bioontology.org/ontology/SNOMEDCT/48015001/mappings?apikey=foo}}
> (2 slashes after http: instead of 1)
>  
> This worked just fine in 4.5.6.
>  
> Updated - edited formating.



--
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