public class HeaderUtils extends Object
Modifier and Type | Method and Description |
---|---|
static void |
addEntityHeaders(Representation entity,
Series<Header> headers)
Adds the entity headers based on the
Representation to the
Series . |
static void |
addExtensionHeaders(Series<Header> existingHeaders,
Series<Header> additionalHeaders)
Adds extension headers if they are non-standard headers.
|
static void |
addGeneralHeaders(Message message,
Series<Header> headers)
|
static void |
addHeader(String headerName,
String headerValue,
Series<Header> headers)
Adds a header to the given list.
|
static void |
addNotModifiedEntityHeaders(Representation entity,
Series<Header> headers)
Adds the entity headers based on the
Representation to the
Series when a 304 (Not Modified) status is returned. |
static void |
addRequestHeaders(Request request,
Series<Header> headers)
|
static void |
addResponseHeaders(Response response,
Series<Header> headers)
|
static void |
copyExtensionHeaders(Series<Header> headers,
Response response)
Copies extension headers into a response.
|
static void |
copyResponseTransportHeaders(Series<Header> headers,
Response response)
Copies headers into a response.
|
static Representation |
extractEntityHeaders(Iterable<Header> headers,
Representation representation)
Extracts entity headers and updates a given representation or create an
empty one when at least one entity header is present.
|
static long |
getContentLength(Series<Header> headers)
Returns the content length of the request entity if know,
Representation.UNKNOWN_SIZE otherwise. |
static boolean |
isAlpha(int character)
Indicates if the given character is alphabetical (a-z or A-Z).
|
static boolean |
isAsciiChar(int character)
Indicates if the given character is in ASCII range.
|
static boolean |
isCarriageReturn(int character)
Indicates if the given character is a carriage return.
|
static boolean |
isChunkedEncoding(Series<Header> headers)
Indicates if the entity is chunked.
|
static boolean |
isComma(int character)
Indicates if the given character is a comma, the character used as header
value separator.
|
static boolean |
isCommentText(int character)
Indicates if the given character is a comment text.
|
static boolean |
isConnectionClose(Series<Header> headers)
Indicates if the connection must be closed.
|
static boolean |
isControlChar(int character)
Indicates if the given character is a control character.
|
static boolean |
isDigit(int character)
Indicates if the given character is a digit (0-9).
|
static boolean |
isDoubleQuote(int character)
Indicates if the given character is a double quote.
|
static boolean |
isHorizontalTab(int character)
Indicates if the given character is an horizontal tab.
|
static boolean |
isLatin1Char(int character)
Indicates if the given character is in ISO Latin 1 (8859-1) range.
|
static boolean |
isLinearWhiteSpace(int character)
Indicates if the given character is a value separator.
|
static boolean |
isLineFeed(int character)
Indicates if the given character is a line feed.
|
static boolean |
isLowerCase(int character)
Indicates if the given character is lower case (a-z).
|
static boolean |
isQuoteCharacter(int character)
Indicates if the given character marks the start of a quoted pair.
|
static boolean |
isQuotedText(int character)
Indicates if the given character is a quoted text.
|
static boolean |
isSemiColon(int character)
Indicates if the given character is a semicolon, the character used as
header parameter separator.
|
static boolean |
isSeparator(int character)
Indicates if the given character is a separator.
|
static boolean |
isSpace(int character)
Indicates if the given character is a space.
|
static boolean |
isText(int character)
Indicates if the given character is textual (ISO Latin 1 and not a
control character).
|
static boolean |
isToken(CharSequence token)
Indicates if the token is valid.
Only contains valid token characters. |
static boolean |
isTokenChar(int character)
Indicates if the given character is a token character (text and not a
separator).
|
static boolean |
isUpperCase(int character)
Indicates if the given character is upper case (A-Z).
|
static void |
writeCRLF(OutputStream os)
Writes a new line.
|
static void |
writeHeaderLine(Header header,
OutputStream os)
Writes a header line.
|
public static void addEntityHeaders(Representation entity, Series<Header> headers)
Representation
to the
Series
.entity
- The source entity Representation
.headers
- The target headers Series
.public static void addExtensionHeaders(Series<Header> existingHeaders, Series<Header> additionalHeaders)
existingHeaders
- The headers to update.additionalHeaders
- The headers to add.public static void addHeader(String headerName, String headerValue, Series<Header> headers)
headerName
- The header name.headerValue
- The header value.headers
- The headers list.public static void addNotModifiedEntityHeaders(Representation entity, Series<Header> headers)
Representation
to the
Series
when a 304 (Not Modified) status is returned.entity
- The source entity Representation
.headers
- The target headers Series
.public static void copyExtensionHeaders(Series<Header> headers, Response response)
headers
- The headers to copy.response
- The response to update.public static void copyResponseTransportHeaders(Series<Header> headers, Response response)
headers
- The headers to copy.response
- The response to update.public static Representation extractEntityHeaders(Iterable<Header> headers, Representation representation) throws NumberFormatException
headers
- The headers to copy.representation
- The representation to update or null.NumberFormatException
copyResponseTransportHeaders(Series, Response)
public static long getContentLength(Series<Header> headers)
Representation.UNKNOWN_SIZE
otherwise.public static boolean isAlpha(int character)
character
- The character to test.public static boolean isAsciiChar(int character)
character
- The character to test.public static boolean isCarriageReturn(int character)
character
- The character to test.public static boolean isChunkedEncoding(Series<Header> headers)
public static boolean isComma(int character)
character
- The character to test.public static boolean isCommentText(int character)
isText(int)
returns true and the character is not '(' or ')'.character
- The character to test.public static boolean isConnectionClose(Series<Header> headers)
headers
- The headers to test.public static boolean isControlChar(int character)
character
- The character to test.public static boolean isDigit(int character)
character
- The character to test.public static boolean isDoubleQuote(int character)
character
- The character to test.public static boolean isHorizontalTab(int character)
character
- The character to test.public static boolean isLatin1Char(int character)
character
- The character to test.public static boolean isLinearWhiteSpace(int character)
character
- The character to test.public static boolean isLineFeed(int character)
character
- The character to test.public static boolean isLowerCase(int character)
character
- The character to test.public static boolean isQuoteCharacter(int character)
character
- The character to test.public static boolean isQuotedText(int character)
isText(int)
returns true and isDoubleQuote(int)
returns
false.character
- The character to test.public static boolean isSemiColon(int character)
character
- The character to test.public static boolean isSeparator(int character)
character
- The character to test.public static boolean isSpace(int character)
character
- The character to test.public static boolean isText(int character)
character
- The character to test.public static boolean isToken(CharSequence token)
token
- The token to checkpublic static boolean isTokenChar(int character)
character
- The character to test.public static boolean isUpperCase(int character)
character
- The character to test.public static void writeCRLF(OutputStream os) throws IOException
os
- The output stream.IOException
public static void writeHeaderLine(Header header, OutputStream os) throws IOException
header
- The header to write.os
- The output stream.IOException
Copyright © 2005–2013. All rights reserved.