public class ContentTypeNegotiator extends Object
Modifier and Type | Class and Description |
---|---|
protected class |
ContentTypeNegotiator.VariantSpec |
Modifier | Constructor and Description |
---|---|
protected |
ContentTypeNegotiator() |
Modifier and Type | Method and Description |
---|---|
protected void |
addUserAgentOverride(Pattern userAgentString,
String originalAcceptHeader,
String newAcceptHeader)
Overrides the Accept header for certain user agents.
|
protected ContentTypeNegotiator.VariantSpec |
addVariant(String mediaType) |
MediaRangeSpec |
getBestMatch(String accept)
Returns the
MediaRangeSpec
associated to the given accept type. |
MediaRangeSpec |
getBestMatch(String accept,
String userAgent)
Returns the
MediaRangeSpec
associated to the given accept type and userAgent. |
protected void |
setDefaultAccept(String accept)
Sets an Accept header to be used as the default if a client does
not send an Accept header, or if the Accept header cannot be parsed.
|
public MediaRangeSpec getBestMatch(String accept)
MediaRangeSpec
associated to the given accept type.accept
- a provided accept typeMediaRangeSpec
associated to the accept parameterpublic MediaRangeSpec getBestMatch(String accept, String userAgent)
MediaRangeSpec
associated to the given accept type and userAgent.accept
- a provided accept typeuserAgent
- use agent associated with the requestMediaRangeSpec
associated to the given accept type and userAgent.protected ContentTypeNegotiator.VariantSpec addVariant(String mediaType)
protected void setDefaultAccept(String accept)
accept
- a default accept typeprotected void addUserAgentOverride(Pattern userAgentString, String originalAcceptHeader, String newAcceptHeader)
userAgentString
- A pattern to be matched against the User-Agent header;
null means regardless of User-AgentoriginalAcceptHeader
- Only override the Accept header if the user agent
sends this header; null means always overridenewAcceptHeader
- The Accept header to be used insteadCopyright © 2010–2019 The Apache Software Foundation. All rights reserved.