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 Details

    • ConNeg

      public ConNeg()
  • Method Details

    • parse

      public static 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 MediaType match(String headerString, 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 MediaType chooseCharset(javax.servlet.http.HttpServletRequest httpRequest, AcceptList myPrefs, 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 MediaType chooseContentType(javax.servlet.http.HttpServletRequest httpRequest, AcceptList myPrefs, 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