public class HTTPHeaderUtility extends Object
LinkHeader
, AcceptHeader
, etc.Modifier and Type | Field and Description |
---|---|
protected static String |
httpQuotedStringPattern
The text for a
Pattern matching an HTTP
quoted-string . |
protected static String |
httpTokenPattern
Matches an HTTP
token , which consists of one or
more of any CHAR except CTL or
separator . |
protected static org.apache.log4j.Logger |
log
The
Logger for HTTP header operations, including
parsing and serialization. |
protected static Pattern |
m_p1
Pattern used to match the type/subtype of a MIME expression.
|
protected static Pattern |
m_p2
Pattern used to match the optional parameters of a MIME
expression.
|
protected static String |
qs
The text for a
Pattern matching an HTTP
quoted-string . |
protected static String |
tok
Matches an HTTP
token , which consists of one or
more of any CHAR except CTL or
separator . |
Constructor and Description |
---|
HTTPHeaderUtility() |
Modifier and Type | Method and Description |
---|---|
static String |
combineHeaders(Enumeration values,
String defaultValue)
HTTP permits headers whose grammar is a comma delimited list to
be specified multiple times in an HTTP request.
|
protected static void |
init()
Initialization for shared
Pattern object that matches
valid MIME type expressions. |
static boolean |
isHttpCtlChar(char ch)
Returns true iff the character is an HTTP
CTL
character. |
static boolean |
isHttpSeparatorChar(char ch)
Returns true iff the character is an HTTP
separator character. |
static boolean |
isHttpToken(String token)
Returns true iff the
String obeys the syntax rules
for an HTTP token . |
static String |
quoteString(String value,
boolean force)
Returns the MIME type parameter value as either an HTTP
token or HTTP quoted-string depending
on whether or not it contains any characters that need to be
escaped. |
static String[] |
splitCommaList(String value)
Splits out the elements for an HTTP header value whose grammar
is a comma delimited list.
|
static String |
unquoteString(String value)
If the value is an HTTP
quoted-string then we
strip of the quote characters now and translate any escaped
characters into themselves, e.g., '\"' => '"'. |
protected static final org.apache.log4j.Logger log
Logger
for HTTP header operations, including
parsing and serialization. The Logger
is named for
this class. It should be used by all derived classes.protected static final String httpTokenPattern
token
, which consists of one or
more of any CHAR except CTL
or
separator
.protected static final String httpQuotedStringPattern
Pattern
matching an HTTP
quoted-string
.From HTTP/1.1:
A string of text is parsed as a single word if it is quoted using double-quote marks.
The backslash character '\' MAY be used as a single-character quoting mechanism only within quoted-string and comment constructs.
quoted-string = ( <"> *(qdtext | quoted-pair ) <"> ) qdtext =Note: This pattern text uses a non-capturing group to encapsulate the choice between a legal character (TEXT) and an escaped character (quoted-pair) within the context of the quoted-string. Any quoted-pair sequences must be reversed by the consumer of the matched group.> quoted-pair = "\" CHAR TEXT =
protected static final String tok
token
, which consists of one or
more of any CHAR except CTL
or
separator
.protected static final String qs
Pattern
matching an HTTP
quoted-string
.From HTTP/1.1:
A string of text is parsed as a single word if it is quoted using double-quote marks.
The backslash character '\' MAY be used as a single-character quoting mechanism only within quoted-string and comment constructs.
quoted-string = ( <"> *(qdtext | quoted-pair ) <"> ) qdtext =Note: This pattern text uses a non-capturing group to encapsulate the choice between a legal character (TEXT) and an escaped character (quoted-pair) within the context of the quoted-string. Any quoted-pair sequences must be reversed by the consumer of the matched group.> quoted-pair = "\" CHAR TEXT =
protected static Pattern m_p1
m_p2
.
protected static Pattern m_p2
m_p1
. The different
matching groups are:public static boolean isHttpCtlChar(char ch)
CTL
character.public static boolean isHttpSeparatorChar(char ch)
separator
character.public static boolean isHttpToken(String token)
String
obeys the syntax rules
for an HTTP token
.protected static void init()
Pattern
object that matches
valid MIME type expressions.public static String quoteString(String value, boolean force)
token
or HTTP quoted-string
depending
on whether or not it contains any characters that need to be
escaped.force
- When true the returned value is always a
quoted-string
.public static String unquoteString(String value) throws IllegalArgumentException
quoted-string
then we
strip of the quote characters now and translate any escaped
characters into themselves, e.g., '\"' => '"'. Otherwise
returns value.IllegalArgumentException
- If the value is a malformed
quoted string. For example, no closing quote character or no
character after an escape character.IllegalArgumentException
public static String combineHeaders(Enumeration values, String defaultValue)
String
containing a comma-delimited list that preserves the
order in which the header values were specified.values
- E.g., as returned by javax.servlet.http#getHeaders( String name )
.defaultValue
- IFF enum is an empty enumeration,
then this value is returned to the caller.Copyright © 2006–2019 SYSTAP, LLC DBA Blazegraph. All rights reserved.