Package org.htmlunit.httpclient
Class HttpClientConverter
- java.lang.Object
-
- org.htmlunit.httpclient.HttpClientConverter
-
public final class HttpClientConverter extends java.lang.ObjectHelper methods to convert from/to HttpClient.
-
-
Field Summary
Fields Modifier and Type Field Description static intFORBIDDENDeprecated.as of version 4.1.0; useHttpStatus.FORBIDDEN_403insteadstatic intINTERNAL_SERVER_ERRORDeprecated.as of version 4.1.0; useHttpStatus.INTERNAL_SERVER_ERROR_500insteadstatic intMOVED_PERMANENTLYDeprecated.as of version 4.1.0; useHttpStatus.MOVED_PERMANENTLY_301insteadstatic intMOVED_TEMPORARILYDeprecated.as of version 4.1.0; useHttpStatus.FOUND_302insteadstatic intMULTIPLE_CHOICESDeprecated.as of version 4.1.0; useHttpStatus.MULTIPLE_CHOICES_300insteadstatic intNO_CONTENTDeprecated.as of version 4.1.0; useHttpStatus.NO_CONTENT_204insteadstatic intNOT_FOUNDDeprecated.as of version 4.1.0; useHttpStatus.NOT_FOUND_404insteadstatic intNOT_MODIFIEDDeprecated.as of version 4.1.0; useHttpStatus.NOT_MODIFIED_304insteadstatic intOKDeprecated.as of version 4.1.0; useHttpStatus.OK_200insteadstatic intPERMANENT_REDIRECTDeprecated.as of version 4.1.0; useHttpStatus.PERMANENT_REDIRECT_308insteadstatic intSEE_OTHERDeprecated.as of version 4.1.0; useHttpStatus.SEE_OTHER_303insteadstatic intTEMPORARY_REDIRECTDeprecated.as of version 4.1.0; useHttpStatus.TEMPORARY_REDIRECT_307insteadstatic intUSE_PROXYDeprecated.as of version 4.1.0; useHttpStatus.USE_PROXY_305instead
-
Constructor Summary
Constructors Modifier Constructor Description privateHttpClientConverter()
-
Method Summary
All Methods Static Methods Concrete Methods Deprecated Methods Modifier and Type Method Description static voidaddMatching(java.util.Set<Cookie> cookies, java.net.URL normalizedUrl, BrowserVersion browserVersion, java.util.Set<Cookie> matches)static org.apache.http.cookie.CookieOriginbuildCookieOrigin(java.net.URL url)Helper that builds a CookieOrigin.static java.lang.StringformatDate(java.util.Date date)Deprecated.as of version 4.1.0; useHttpUtils.parseDate(String)insteadstatic java.util.List<Cookie>fromHttpClient(java.util.List<org.apache.http.cookie.Cookie> cookies)Converts the specified array of HttpClient cookies into a list of cookies.static booleanisNoHttpResponseException(java.lang.Exception e)static java.util.List<org.apache.http.NameValuePair>nameValuePairsToHttpClient(java.util.List<NameValuePair> pairs)Converts the specified name/value pairs into HttpClient name/value pairs.static java.util.List<Cookie>parseCookie(java.lang.String cookieString, java.net.URL pageUrl, BrowserVersion browserVersion)static java.util.DateparseHttpDate(java.lang.String s)Deprecated.as of version 4.1.0; useHttpUtils.parseDate(String)insteadstatic java.util.List<NameValuePair>parseUrlQuery(java.lang.String query, java.nio.charset.Charset charset)Deprecated.as of version 4.1.0; useHttpUtils.parseUrlQuery(String, Charset)insteadstatic java.net.URLreplaceForCookieIfNecessary(java.net.URL url)CookieOrigindoesn't like empty hosts and negative ports, but these things happen if we're dealing with a local file.static java.util.List<org.apache.http.cookie.Cookie>toHttpClient(java.util.Collection<Cookie> cookies)Converts the specified collection of cookies into a collection of HttpClient cookies.static java.lang.StringtoQueryFormFields(java.util.List<NameValuePair> parameters, java.nio.charset.Charset enc)Deprecated.as of version 4.1.0; useHttpUtils.toQueryFormFields(Iterable, Charset)instead
-
-
-
Field Detail
-
OK
@Deprecated public static final int OK
Deprecated.as of version 4.1.0; useHttpStatus.OK_200insteadForwarder to HttpStatus.SC_OK.- See Also:
- Constant Field Values
-
NO_CONTENT
@Deprecated public static final int NO_CONTENT
Deprecated.as of version 4.1.0; useHttpStatus.NO_CONTENT_204insteadForwarder to HttpStatus.SC_NO_CONTENT.- See Also:
- Constant Field Values
-
MULTIPLE_CHOICES
@Deprecated public static final int MULTIPLE_CHOICES
Deprecated.as of version 4.1.0; useHttpStatus.MULTIPLE_CHOICES_300insteadForwarder to HttpStatus.MULTIPLE_CHOICES.- See Also:
- Constant Field Values
-
MOVED_PERMANENTLY
@Deprecated public static final int MOVED_PERMANENTLY
Deprecated.as of version 4.1.0; useHttpStatus.MOVED_PERMANENTLY_301insteadForwarder to HttpStatus.MOVED_PERMANENTLY.- See Also:
- Constant Field Values
-
MOVED_TEMPORARILY
@Deprecated public static final int MOVED_TEMPORARILY
Deprecated.as of version 4.1.0; useHttpStatus.FOUND_302insteadForwarder to HttpStatus.MOVED_TEMPORARILY.- See Also:
- Constant Field Values
-
SEE_OTHER
@Deprecated public static final int SEE_OTHER
Deprecated.as of version 4.1.0; useHttpStatus.SEE_OTHER_303insteadForwarder to HttpStatus.SEE_OTHER.- See Also:
- Constant Field Values
-
TEMPORARY_REDIRECT
@Deprecated public static final int TEMPORARY_REDIRECT
Deprecated.as of version 4.1.0; useHttpStatus.TEMPORARY_REDIRECT_307insteadForwarder to HttpStatus.TEMPORARY_REDIRECT.- See Also:
- Constant Field Values
-
PERMANENT_REDIRECT
@Deprecated public static final int PERMANENT_REDIRECT
Deprecated.as of version 4.1.0; useHttpStatus.PERMANENT_REDIRECT_308instead308.- See Also:
- Constant Field Values
-
NOT_MODIFIED
@Deprecated public static final int NOT_MODIFIED
Deprecated.as of version 4.1.0; useHttpStatus.NOT_MODIFIED_304insteadForwarder to HttpStatus.NOT_MODIFIED.- See Also:
- Constant Field Values
-
USE_PROXY
@Deprecated public static final int USE_PROXY
Deprecated.as of version 4.1.0; useHttpStatus.USE_PROXY_305insteadForwarder to HttpStatus.SC_USE_PROXY.- See Also:
- Constant Field Values
-
FORBIDDEN
@Deprecated public static final int FORBIDDEN
Deprecated.as of version 4.1.0; useHttpStatus.FORBIDDEN_403insteadForwarder to HttpStatus.SC_FORBIDDEN.- See Also:
- Constant Field Values
-
NOT_FOUND
@Deprecated public static final int NOT_FOUND
Deprecated.as of version 4.1.0; useHttpStatus.NOT_FOUND_404insteadForwarder to HttpStatus.SC_NOT_FOUND.- See Also:
- Constant Field Values
-
INTERNAL_SERVER_ERROR
@Deprecated public static final int INTERNAL_SERVER_ERROR
Deprecated.as of version 4.1.0; useHttpStatus.INTERNAL_SERVER_ERROR_500insteadForwarder to HttpStatus.SC_INTERNAL_SERVER_ERROR.- See Also:
- Constant Field Values
-
-
Method Detail
-
nameValuePairsToHttpClient
public static java.util.List<org.apache.http.NameValuePair> nameValuePairsToHttpClient(java.util.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 public static java.util.List<NameValuePair> parseUrlQuery(java.lang.String query, java.nio.charset.Charset charset)
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 public static java.lang.String toQueryFormFields(java.util.List<NameValuePair> parameters, java.nio.charset.Charset enc)
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 public static java.util.Date parseHttpDate(java.lang.String s)
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 returnsnullif the specified string isnullor unparseable.- Parameters:
s- the string to parse as a date- Returns:
- the date version of the specified string, or
null
-
formatDate
@Deprecated public static java.lang.String formatDate(java.util.Date date)
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
public static boolean isNoHttpResponseException(java.lang.Exception e)
- Parameters:
e- the exception to check- Returns:
- true if the provided Exception is na
NoHttpResponseException
-
buildCookieOrigin
public static org.apache.http.cookie.CookieOrigin buildCookieOrigin(java.net.URL url)
Helper that builds a CookieOrigin.- Parameters:
url- the url to be used- Returns:
- the new CookieOrigin
-
replaceForCookieIfNecessary
public static java.net.URL replaceForCookieIfNecessary(java.net.URL url)
CookieOrigindoesn'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 java.util.List<Cookie> parseCookie(java.lang.String cookieString, java.net.URL pageUrl, BrowserVersion browserVersion) throws org.apache.http.cookie.MalformedCookieException
- Throws:
org.apache.http.cookie.MalformedCookieException
-
toHttpClient
public static java.util.List<org.apache.http.cookie.Cookie> toHttpClient(java.util.Collection<Cookie> cookies)
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
public static java.util.List<Cookie> fromHttpClient(java.util.List<org.apache.http.cookie.Cookie> cookies)
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
public static void addMatching(java.util.Set<Cookie> cookies, java.net.URL normalizedUrl, BrowserVersion browserVersion, java.util.Set<Cookie> matches)
-
-