Package org.htmlunit.httpclient
Class HttpClientConverter
java.lang.Object
org.htmlunit.httpclient.HttpClientConverter
Helper methods to convert from/to HttpClient.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final int
Deprecated.static final int
Deprecated.as of version 4.1.0; useHttpStatus.INTERNAL_SERVER_ERROR_500
insteadstatic final int
Deprecated.as of version 4.1.0; useHttpStatus.MOVED_PERMANENTLY_301
insteadstatic final int
Deprecated.as of version 4.1.0; useHttpStatus.FOUND_302
insteadstatic final int
Deprecated.as of version 4.1.0; useHttpStatus.MULTIPLE_CHOICES_300
insteadstatic final int
Deprecated.as of version 4.1.0; useHttpStatus.NO_CONTENT_204
insteadstatic final int
Deprecated.as of version 4.1.0; useHttpStatus.NOT_FOUND_404
insteadstatic final int
Deprecated.as of version 4.1.0; useHttpStatus.NOT_MODIFIED_304
insteadstatic final int
Deprecated.as of version 4.1.0; useHttpStatus.OK_200
insteadstatic final int
Deprecated.as of version 4.1.0; useHttpStatus.PERMANENT_REDIRECT_308
insteadstatic final int
Deprecated.as of version 4.1.0; useHttpStatus.SEE_OTHER_303
insteadstatic final int
Deprecated.as of version 4.1.0; useHttpStatus.TEMPORARY_REDIRECT_307
insteadstatic final int
Deprecated.as of version 4.1.0; useHttpStatus.USE_PROXY_305
instead -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic void
addMatching
(Set<Cookie> cookies, URL normalizedUrl, BrowserVersion browserVersion, Set<Cookie> matches) static org.apache.http.cookie.CookieOrigin
buildCookieOrigin
(URL url) Helper that builds a CookieOrigin.static String
formatDate
(Date date) Deprecated.as of version 4.1.0; useHttpUtils.parseDate(String)
insteadfromHttpClient
(List<org.apache.http.cookie.Cookie> cookies) Converts the specified array of HttpClient cookies into a list of cookies.static boolean
static List
<org.apache.http.NameValuePair> Converts the specified name/value pairs into HttpClient name/value pairs.parseCookie
(String cookieString, URL pageUrl, BrowserVersion browserVersion) static Date
Deprecated.as of version 4.1.0; useHttpUtils.parseDate(String)
insteadstatic List
<NameValuePair> parseUrlQuery
(String query, Charset charset) Deprecated.as of version 4.1.0; useHttpUtils.parseUrlQuery(String, Charset)
insteadstatic URL
CookieOrigin
doesn't like empty hosts and negative ports, but these things happen if we're dealing with a local file.static List
<org.apache.http.cookie.Cookie> toHttpClient
(Collection<Cookie> cookies) Converts the specified collection of cookies into a collection of HttpClient cookies.static String
toQueryFormFields
(List<NameValuePair> parameters, Charset enc) Deprecated.as of version 4.1.0; useHttpUtils.toQueryFormFields(Iterable, Charset)
instead
-
Field Details
-
OK
Deprecated.as of version 4.1.0; useHttpStatus.OK_200
insteadForwarder to HttpStatus.SC_OK.- See Also:
-
NO_CONTENT
Deprecated.as of version 4.1.0; useHttpStatus.NO_CONTENT_204
insteadForwarder to HttpStatus.SC_NO_CONTENT.- See Also:
-
MULTIPLE_CHOICES
Deprecated.as of version 4.1.0; useHttpStatus.MULTIPLE_CHOICES_300
insteadForwarder to HttpStatus.MULTIPLE_CHOICES.- See Also:
-
MOVED_PERMANENTLY
Deprecated.as of version 4.1.0; useHttpStatus.MOVED_PERMANENTLY_301
insteadForwarder to HttpStatus.MOVED_PERMANENTLY.- See Also:
-
MOVED_TEMPORARILY
Deprecated.as of version 4.1.0; useHttpStatus.FOUND_302
insteadForwarder to HttpStatus.MOVED_TEMPORARILY.- See Also:
-
SEE_OTHER
Deprecated.as of version 4.1.0; useHttpStatus.SEE_OTHER_303
insteadForwarder to HttpStatus.SEE_OTHER.- See Also:
-
TEMPORARY_REDIRECT
Deprecated.as of version 4.1.0; useHttpStatus.TEMPORARY_REDIRECT_307
insteadForwarder to HttpStatus.TEMPORARY_REDIRECT.- See Also:
-
PERMANENT_REDIRECT
Deprecated.as of version 4.1.0; useHttpStatus.PERMANENT_REDIRECT_308
instead308.- See Also:
-
NOT_MODIFIED
Deprecated.as of version 4.1.0; useHttpStatus.NOT_MODIFIED_304
insteadForwarder to HttpStatus.NOT_MODIFIED.- See Also:
-
USE_PROXY
Deprecated.as of version 4.1.0; useHttpStatus.USE_PROXY_305
insteadForwarder to HttpStatus.SC_USE_PROXY.- See Also:
-
FORBIDDEN
Deprecated.as of version 4.1.0; useHttpStatus.FORBIDDEN_403
insteadForwarder to HttpStatus.SC_FORBIDDEN.- See Also:
-
NOT_FOUND
Deprecated.as of version 4.1.0; useHttpStatus.NOT_FOUND_404
insteadForwarder to HttpStatus.SC_NOT_FOUND.- See Also:
-
INTERNAL_SERVER_ERROR
Deprecated.as of version 4.1.0; useHttpStatus.INTERNAL_SERVER_ERROR_500
insteadForwarder to HttpStatus.SC_INTERNAL_SERVER_ERROR.- See Also:
-
-
Constructor Details
-
HttpClientConverter
private HttpClientConverter()
-
-
Method Details
-
nameValuePairsToHttpClient
public static List<org.apache.http.NameValuePair> nameValuePairsToHttpClient(List<NameValuePair> pairs) Converts the specified name/value pairs into HttpClient name/value pairs.- Parameters:
pairs
- the name/value pairs to convert- Returns:
- the converted name/value pairs
-
parseUrlQuery
Deprecated.as of version 4.1.0; useHttpUtils.parseUrlQuery(String, Charset)
insteadParses url query into name/value pairs using methods from HttpClient.- Parameters:
query
- the urlencoded querycharset
- the charset or null (defaulting to utf-8)- Returns:
- the name/value pairs
-
toQueryFormFields
Deprecated.as of version 4.1.0; useHttpUtils.toQueryFormFields(Iterable, Charset)
instead- Parameters:
parameters
- the paramtersenc
- the charset- Returns:
- the query string from the given parameters
-
parseHttpDate
Deprecated.as of version 4.1.0; useHttpUtils.parseDate(String)
insteadParses the specified date string, assuming that it is formatted according to RFC 1123, RFC 1036 or as an ANSI C HTTP date header. This method returnsnull
if the specified string isnull
or unparseable.- Parameters:
s
- the string to parse as a date- Returns:
- the date version of the specified string, or
null
-
formatDate
Deprecated.as of version 4.1.0; useHttpUtils.parseDate(String)
insteadFormats the given date according to the RFC 1123 pattern.- Parameters:
date
- The date to format.- Returns:
- An RFC 1123 formatted date string.
-
isNoHttpResponseException
- Parameters:
e
- the exception to check- Returns:
- true if the provided Exception is na
NoHttpResponseException
-
buildCookieOrigin
Helper that builds a CookieOrigin.- Parameters:
url
- the url to be used- Returns:
- the new CookieOrigin
-
replaceForCookieIfNecessary
CookieOrigin
doesn't like empty hosts and negative ports, but these things happen if we're dealing with a local file. This method allows us to work around this limitation in HttpClient by feeding it a bogus host and port.- Parameters:
url
- the URL to replace if necessary- Returns:
- the replacement URL, or the original URL if no replacement was necessary
-
parseCookie
public static List<Cookie> parseCookie(String cookieString, URL pageUrl, BrowserVersion browserVersion) throws org.apache.http.cookie.MalformedCookieException - Throws:
org.apache.http.cookie.MalformedCookieException
-
toHttpClient
Converts the specified collection of cookies into a collection of HttpClient cookies.- Parameters:
cookies
- the cookies to be converted- Returns:
- the specified cookies, as HttpClient cookies
-
fromHttpClient
Converts the specified array of HttpClient cookies into a list of cookies.- Parameters:
cookies
- the cookies to be converted- Returns:
- the specified HttpClient cookies, as cookies
-
addMatching
-
HttpStatus.FORBIDDEN_403
instead