Class HttpClientConverter

java.lang.Object
org.htmlunit.httpclient.HttpClientConverter

public final class HttpClientConverter extends Object
Helper methods to convert from/to HttpClient.
  • Field Details

  • 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 public static List<NameValuePair> parseUrlQuery(String query, Charset charset)
      Deprecated.
      as of version 4.1.0; use HttpUtils.parseUrlQuery(String, Charset) instead
      Parses url query into name/value pairs using methods from HttpClient.
      Parameters:
      query - the urlencoded query
      charset - the charset or null (defaulting to utf-8)
      Returns:
      the name/value pairs
    • toQueryFormFields

      @Deprecated public static String toQueryFormFields(List<NameValuePair> parameters, Charset enc)
      Deprecated.
      as of version 4.1.0; use HttpUtils.toQueryFormFields(Iterable, Charset) instead
      Parameters:
      parameters - the paramters
      enc - the charset
      Returns:
      the query string from the given parameters
    • parseHttpDate

      @Deprecated public static Date parseHttpDate(String s)
      Deprecated.
      as of version 4.1.0; use HttpUtils.parseDate(String) instead
      Parses 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 returns null if the specified string is null or unparseable.
      Parameters:
      s - the string to parse as a date
      Returns:
      the date version of the specified string, or null
    • formatDate

      @Deprecated public static String formatDate(Date date)
      Deprecated.
      as of version 4.1.0; use HttpUtils.parseDate(String) instead
      Formats 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(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(URL url)
      Helper that builds a CookieOrigin.
      Parameters:
      url - the url to be used
      Returns:
      the new CookieOrigin
    • replaceForCookieIfNecessary

      public static URL replaceForCookieIfNecessary(URL url)
      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

      public static List<org.apache.http.cookie.Cookie> toHttpClient(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 List<Cookie> fromHttpClient(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(Set<Cookie> cookies, URL normalizedUrl, BrowserVersion browserVersion, Set<Cookie> matches)