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.
| Constructor and Description |
|---|
ConNeg() |
| Modifier and Type | Method and Description |
|---|---|
static MediaType |
chooseCharset(javax.servlet.http.HttpServletRequest httpRequest,
AcceptList myPrefs,
MediaType defaultMediaType)
Chooses the charset by using the Accept-Charset HTTP header.
|
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. |
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. |
static String |
match(String headerString,
String mediaRangeStr)
Match a single media type against a header string.
|
static MediaType |
parse(String contentType)
Parses the content type.
|
public static MediaType parse(String contentType)
contentType - content type stringpublic 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.
headerString - HTTP header stringofferList - accept listpublic static String match(String headerString, String mediaRangeStr)
headerString - HTTP header stringmediaRangeStr - Semi-colon separated list of media typesnull if there was no matchpublic static MediaType chooseCharset(javax.servlet.http.HttpServletRequest httpRequest, AcceptList myPrefs, MediaType defaultMediaType)
Chooses the charset by using the Accept-Charset HTTP header.
httpRequest - HTTP requestmyPrefs - accept listdefaultMediaType - default media typepublic 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.
httpRequest - HTTP requestmyPrefs - accept listdefaultMediaType - default media typeLicenced under the Apache License, Version 2.0