org.apache.http.client.utils
Class URLUtils

java.lang.Object
  extended by org.apache.http.client.utils.URLUtils

public class URLUtils
extends java.lang.Object

The home for utility methods that handle various URL encoding tasks.

Since:
4.0
Author:
Michael Becke, Oleg Kalnichevski

Method Summary
static java.lang.String formUrlEncode(org.apache.http.NameValuePair[] pairs, java.lang.String charset)
          Form-urlencoding routine.
static java.lang.String simpleFormUrlEncode(org.apache.http.NameValuePair[] pairs, java.lang.String charset)
          Form-urlencoding routine.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

simpleFormUrlEncode

public static java.lang.String simpleFormUrlEncode(org.apache.http.NameValuePair[] pairs,
                                                   java.lang.String charset)
Form-urlencoding routine. The default encoding for all forms is `application/x-www-form-urlencoded'. A form data set is represented in this media type as follows: The form field names and values are escaped: space characters are replaced by `+', and then reserved characters are escaped as per [URL]; that is, non-alphanumeric characters are replaced by `%HH', a percent sign and two hexadecimal digits representing the ASCII code of the character. Line breaks, as in multi-line text field values, are represented as CR LF pairs, i.e. `%0D%0A'.

if the given charset is not supported, ISO-8859-1 is used instead.

Parameters:
pairs - the values to be encoded
charset - the character set of pairs to be encoded
Returns:
the urlencoded pairs

formUrlEncode

public static java.lang.String formUrlEncode(org.apache.http.NameValuePair[] pairs,
                                             java.lang.String charset)
                                      throws java.io.UnsupportedEncodingException
Form-urlencoding routine. The default encoding for all forms is `application/x-www-form-urlencoded'. A form data set is represented in this media type as follows: The form field names and values are escaped: space characters are replaced by `+', and then reserved characters are escaped as per [URL]; that is, non-alphanumeric characters are replaced by `%HH', a percent sign and two hexadecimal digits representing the ASCII code of the character. Line breaks, as in multi-line text field values, are represented as CR LF pairs, i.e. `%0D%0A'.

Parameters:
pairs - the values to be encoded
charset - the character set of pairs to be encoded
Returns:
the urlencoded pairs
Throws:
java.io.UnsupportedEncodingException - if charset is not supported


Copyright © 2000-2007 Apache Software Foundation. All Rights Reserved.