java.lang.Object
org.apache.jena.fuseki.system.ConNeg

public class ConNeg extends Object

Content negotiation is a mechanism defined in the HTTP specification that makes it possible to serve different versions of a document (or more generally, a resource representation) at the same URI, so that user agents can specify which version fit their capabilities the best.

ConNeg is used in Fuseki to help matching the content media type requested by the user, against the list of offered media types.

See Also:
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static org.apache.jena.atlas.web.MediaType
    chooseCharset(jakarta.servlet.http.HttpServletRequest httpRequest, org.apache.jena.atlas.web.AcceptList myPrefs, org.apache.jena.atlas.web.MediaType defaultMediaType)
    Chooses the charset by using the Accept-Charset HTTP header.
    static org.apache.jena.atlas.web.MediaType
    chooseContentType(jakarta.servlet.http.HttpServletRequest httpRequest, org.apache.jena.atlas.web.AcceptList myPrefs, org.apache.jena.atlas.web.MediaType defaultMediaType)
    Choose the content media type by extracting the Accept HTTP header from the HTTP request and choosing (see choose(String, AcceptList, MediaType)) a content media type that matches the header.
    static String
    match(String headerString, String mediaRangeStr)
    Match a single media type against a header string.
    static org.apache.jena.atlas.web.MediaType
    match(String headerString, org.apache.jena.atlas.web.AcceptList offerList)
    Creates a AcceptList with the given HTTP header string and uses the AcceptList.match(MediaType) method to decide which media type matches the HTTP header string.
    static org.apache.jena.atlas.web.MediaType
    parse(String contentType)
    Parses the content type.

    Methods inherited from class java.lang.Object

    equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • ConNeg

      public ConNeg()
  • Method Details

    • parse

      public static org.apache.jena.atlas.web.MediaType parse(String contentType)
      Parses the content type. It splits the string by semi-colon and finds the other features such as the "q" quality factor. For a complete documentation on how the parsing happens, see http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.1.
      Parameters:
      contentType - content type string
      Returns:
      parsed media type
    • match

      public static org.apache.jena.atlas.web.MediaType match(String headerString, org.apache.jena.atlas.web.AcceptList offerList)

      Creates a AcceptList with the given HTTP header string and uses the AcceptList.match(MediaType) method to decide which media type matches the HTTP header string.

      The q quality factor is used to decide which choice is the best match.

      Parameters:
      headerString - HTTP header string
      offerList - accept list
      Returns:
      matched media type
    • match

      public static String match(String headerString, String mediaRangeStr)
      Match a single media type against a header string.
      Parameters:
      headerString - HTTP header string
      mediaRangeStr - Semi-colon separated list of media types
      Returns:
      the matched media type or null if there was no match
    • chooseCharset

      public static org.apache.jena.atlas.web.MediaType chooseCharset(jakarta.servlet.http.HttpServletRequest httpRequest, org.apache.jena.atlas.web.AcceptList myPrefs, org.apache.jena.atlas.web.MediaType defaultMediaType)

      Chooses the charset by using the Accept-Charset HTTP header.

      See choose(String, AcceptList, MediaType).

      Parameters:
      httpRequest - HTTP request
      myPrefs - accept list
      defaultMediaType - default media type
      Returns:
      media type chosen
    • chooseContentType

      public static org.apache.jena.atlas.web.MediaType chooseContentType(jakarta.servlet.http.HttpServletRequest httpRequest, org.apache.jena.atlas.web.AcceptList myPrefs, org.apache.jena.atlas.web.MediaType defaultMediaType)

      Choose the content media type by extracting the Accept HTTP header from the HTTP request and choosing (see choose(String, AcceptList, MediaType)) a content media type that matches the header.

      Parameters:
      httpRequest - HTTP request
      myPrefs - accept list
      defaultMediaType - default media type
      Returns:
      media type chosen