Class HttpUtils
java.lang.Object
org.htmlunit.http.HttpUtils
Http related utils.
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final DateTimeFormatterASCII time date formatter.private static final DateTimeFormatterRFC 1036 date formatter.private static final DateTimeFormatterRFC 1123 date formatter.private static final ZoneIdprivate static final StringDate format pattern used to parse HTTP date headers in ANSI Casctime()format.static final StringDate format pattern used to parse HTTP date headers in RFC 1036 format.private static final StringDate format pattern used to parse HTTP date headers in RFC 1123 format.private static final DateTimeFormatter[]private static final BitSetSafe characters for x-www-form-urlencoded data; i.e. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate static voidcopyContent(String buf, HttpUtils.ParseRange range, BitSet delimiters, StringBuilder dst) Transfers content into the destination buffer until a whitespace character or any of the given delimiters is encountered.private static StringdecodeFormFields(String content, Charset charset) private static StringencodeFormFields(String content, Charset charset) static StringformatDate(Date date) Formats the given date according to the RFC 1123 pattern.private static booleanisWhitespace(char ch) static DateParses a date value.private static StringparseToken(String buf, HttpUtils.ParseRange range, BitSet delimiters) Extracts from the sequence of chars a token terminated with any of the given delimiters discarding semantically insignificant whitespace characters.static List<NameValuePair> parseUrlQuery(String s, Charset charset) Returns a list ofNameValuePairs URI query parameters.private static voidskipWhiteSpace(String buf, HttpUtils.ParseRange range) Skips semantically insignificant whitespace characters and moves the cursor to the closest non-whitespace character.static StringtoQueryFormFields(Iterable<? extends NameValuePair> parameters, Charset charset)
-
Field Details
-
URLENCODER
Safe characters for x-www-form-urlencoded data; i.e. alphanumeric plus"-", "_", ".", "*" -
PATTERN_RFC1123
Date format pattern used to parse HTTP date headers in RFC 1123 format.- See Also:
-
FORMATTER_RFC1123
RFC 1123 date formatter. -
PATTERN_RFC1036
Date format pattern used to parse HTTP date headers in RFC 1036 format.- See Also:
-
FORMATTER_RFC1036
RFC 1036 date formatter. -
PATTERN_ASCTIME
Date format pattern used to parse HTTP date headers in ANSI Casctime()format.- See Also:
-
FORMATTER_ASCTIME
ASCII time date formatter. -
STANDARD_PATTERNS
-
GMT_ID
-
-
Constructor Details
-
HttpUtils
private HttpUtils()
-
-
Method Details
-
parseDate
-
formatDate
-
parseUrlQuery
Returns a list ofNameValuePairs URI query parameters. By convention,'&'and';'are accepted as parameter separators.- Parameters:
s- URI query component.charset- charset to use when decoding the parameters.- Returns:
- list of query parameters.
-
decodeFormFields
-
toQueryFormFields
public static String toQueryFormFields(Iterable<? extends NameValuePair> parameters, Charset charset) - Parameters:
parameters- the paramterscharset- the charset- Returns:
- the query string from the given parameters
-
encodeFormFields
-
parseToken
Extracts from the sequence of chars a token terminated with any of the given delimiters discarding semantically insignificant whitespace characters.- Parameters:
buf- buffer with the sequence of chars to be parsedrange- defines the bounds and current position of the bufferdelimiters- set of delimiting characters. Can benullif the token is not delimited by any character.
-
skipWhiteSpace
Skips semantically insignificant whitespace characters and moves the cursor to the closest non-whitespace character.- Parameters:
buf- buffer with the sequence of chars to be parsedrange- defines the bounds and current position of the buffer
-
copyContent
private static void copyContent(String buf, HttpUtils.ParseRange range, BitSet delimiters, StringBuilder dst) Transfers content into the destination buffer until a whitespace character or any of the given delimiters is encountered.- Parameters:
buf- buffer with the sequence of chars to be parsedrange- defines the bounds and current position of the bufferdelimiters- set of delimiting characters. Can benullif the value is delimited by a whitespace only.dst- destination buffer
-
isWhitespace
private static boolean isWhitespace(char ch)
-