Uploaded image for project: 'HttpComponents HttpClient'
  1. HttpComponents HttpClient
  2. HTTPCLIENT-1975

Error handling double url-encoded forward slashes

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Minor
    • Resolution: Duplicate
    • 4.5.7
    • None
    • None
    • None

    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();
      }

       

      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://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.

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              markwoon Mark Woon
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: