Uploaded image for project: 'Apache Jena'
  1. Apache Jena
  2. JENA-1263

Configure HTTP client to follow 303 redirects

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • Jena 3.1.1
    • Jena 3.2.0
    • ARQ
    • None

    Description

      When calling RDFDataMgr.read(Model model, String uri), the underlying HTTP client does not appear to follow 303 redirects. For example:

      Model m = createDefaultModel();
      RDFDataMgr.read(m, "http://purl.org/dc/terms/");
      
      org.apache.jena.riot.RiotException: Failed to determine the content type: (URI=http://purl.org/dc/terms/ : stream=text/html)
      

      A work-around is to add a static block with a custom HTTP client like so:

      static {
          HttpOp.setDefaultHttpClient(
                  HttpClientBuilder.create().setRedirectStrategy(
                          new LaxRedirectStrategy()).build());
      }
      

      By default the Apache HTTP client follows 301 and 302 redirects (but not 303 redirects), but the W3C recommends using 303 redirects for publishing RDF vocabularies (https://www.w3.org/TR/swbp-vocab-pub/), which is what the Dublin Core vocabularies use.

      This sort of redirect handling worked previously, e.g. Jena 3.1.0; it would be convenient if the underlying HTTP client simply followed the 303 redirects.

      Attachments

        Issue Links

          Activity

            People

              ajs6f Adam Soroka
              acoburn Aaron Coburn
              Votes:
              0 Vote for this issue
              Watchers:
              5 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: