railo.commons.net
Class HTTPUtil

java.lang.Object
  extended by railo.commons.net.HTTPUtil

public final class HTTPUtil
extends Object


Field Summary
static short ACTION_GET
          Field ACTION_GET
static short ACTION_POST
          Field ACTION_POST
static int STATUS_OK
          Field STATUS_OK
 
Constructor Summary
HTTPUtil()
           
 
Method Summary
static org.apache.commons.httpclient.HttpMethod delete(URL url, String username, String password, int timeout, String charset, String useragent, String proxyserver, int proxyport, String proxyuser, String proxypassword, org.apache.commons.httpclient.Header[] headers)
           
static String encode(String realpath)
           
static String escapeQSValue(String str)
           
static void forward(PageContext pc, String realPath)
           
static ContentType getContentType(org.apache.commons.httpclient.HttpMethod http)
           
static int getPort(URL url)
           
static org.apache.commons.httpclient.HttpMethod head(URL url, String username, String password, int timeout, String charset, String useragent, String proxyserver, int proxyport, String proxyuser, String proxypassword, org.apache.commons.httpclient.Header[] headers)
           
static void include(PageContext pc, javax.servlet.ServletRequest req, javax.servlet.ServletResponse rsp, String realPath)
           
static void include(PageContext pc, String realPath)
           
static org.apache.commons.httpclient.HttpMethod invoke(URL url, String username, String password, long timeout, String charset, String useragent, String proxyserver, int proxyport, String proxyuser, String proxypassword, org.apache.commons.httpclient.Header[] headers)
          make a http requst to given url
static boolean isSecure(URL url)
           
static long length(URL url)
          return the length of a file defined by a url.
static void main(String[] args)
           
static String optimizeRealPath(PageContext pc, String realPath)
           
static Map<String,String> parseParameterList(String _str, boolean decode, String charset)
           
static org.apache.commons.httpclient.HttpMethod post(URL url, String username, String password, long timeout, String charset, String useragent, String proxyserver, int proxyport, String proxyuser, String proxypassword, org.apache.commons.httpclient.Header[] headers)
           
static org.apache.commons.httpclient.HttpMethod put(URL url, String username, String password, int timeout, String charset, String useragent, String proxyserver, int proxyport, String proxyuser, String proxypassword, org.apache.commons.httpclient.Header[] headers, org.apache.commons.httpclient.methods.RequestEntity body)
           
static String removeRef(String url)
           
static URL removeRef(URL url)
           
static javax.servlet.ServletRequest removeWrap(javax.servlet.ServletRequest req)
           
static String[] splitMimeTypeAndCharset(String mimetype)
           
static String[] splitTypeAndSubType(String mimetype)
           
static org.apache.commons.httpclient.methods.RequestEntity toRequestEntity(Object value)
           
static URI toURI(String strUrl)
           
static URI toURI(String strUrl, int port)
           
static URL toURL(org.apache.commons.httpclient.HttpMethod httpMethod)
           
static URL toURL(String strUrl)
          cast a string to a url
static URL toURL(String strUrl, int port)
          cast a string to a url
static URL toURL(String strUrl, URL defaultValue)
           
static String validateURL(String strUrl, String defaultValue)
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ACTION_POST

public static final short ACTION_POST
Field ACTION_POST

See Also:
Constant Field Values

ACTION_GET

public static final short ACTION_GET
Field ACTION_GET

See Also:
Constant Field Values

STATUS_OK

public static final int STATUS_OK
Field STATUS_OK

See Also:
Constant Field Values
Constructor Detail

HTTPUtil

public HTTPUtil()
Method Detail

invoke

public static org.apache.commons.httpclient.HttpMethod invoke(URL url,
                                                              String username,
                                                              String password,
                                                              long timeout,
                                                              String charset,
                                                              String useragent,
                                                              String proxyserver,
                                                              int proxyport,
                                                              String proxyuser,
                                                              String proxypassword,
                                                              org.apache.commons.httpclient.Header[] headers)
                                                       throws IOException
make a http requst to given url

Parameters:
url -
username -
password -
timeout -
charset -
useragent -
proxyserver -
proxyport -
proxyuser -
proxypassword -
headers -
Returns:
Throws:
IOException

post

public static org.apache.commons.httpclient.HttpMethod post(URL url,
                                                            String username,
                                                            String password,
                                                            long timeout,
                                                            String charset,
                                                            String useragent,
                                                            String proxyserver,
                                                            int proxyport,
                                                            String proxyuser,
                                                            String proxypassword,
                                                            org.apache.commons.httpclient.Header[] headers)
                                                     throws IOException
Throws:
IOException

toURL

public static URL toURL(String strUrl)
                 throws MalformedURLException
cast a string to a url

Parameters:
strUrl - string represent a url
Returns:
url from string
Throws:
MalformedURLException

toURL

public static URL toURL(String strUrl,
                        URL defaultValue)

validateURL

public static String validateURL(String strUrl,
                                 String defaultValue)

toURL

public static URL toURL(String strUrl,
                        int port)
                 throws MalformedURLException
cast a string to a url

Parameters:
strUrl - string represent a url
Returns:
url from string
Throws:
MalformedURLException

toURI

public static URI toURI(String strUrl)
                 throws URISyntaxException
Throws:
URISyntaxException

toURI

public static URI toURI(String strUrl,
                        int port)
                 throws URISyntaxException
Throws:
URISyntaxException

main

public static void main(String[] args)
                 throws Exception
Throws:
Exception

escapeQSValue

public static String escapeQSValue(String str)

put

public static org.apache.commons.httpclient.HttpMethod put(URL url,
                                                           String username,
                                                           String password,
                                                           int timeout,
                                                           String charset,
                                                           String useragent,
                                                           String proxyserver,
                                                           int proxyport,
                                                           String proxyuser,
                                                           String proxypassword,
                                                           org.apache.commons.httpclient.Header[] headers,
                                                           org.apache.commons.httpclient.methods.RequestEntity body)
                                                    throws IOException
Throws:
IOException

delete

public static org.apache.commons.httpclient.HttpMethod delete(URL url,
                                                              String username,
                                                              String password,
                                                              int timeout,
                                                              String charset,
                                                              String useragent,
                                                              String proxyserver,
                                                              int proxyport,
                                                              String proxyuser,
                                                              String proxypassword,
                                                              org.apache.commons.httpclient.Header[] headers)
                                                       throws IOException
Throws:
IOException

head

public static org.apache.commons.httpclient.HttpMethod head(URL url,
                                                            String username,
                                                            String password,
                                                            int timeout,
                                                            String charset,
                                                            String useragent,
                                                            String proxyserver,
                                                            int proxyport,
                                                            String proxyuser,
                                                            String proxypassword,
                                                            org.apache.commons.httpclient.Header[] headers)
                                                     throws IOException
Throws:
IOException

toRequestEntity

public static org.apache.commons.httpclient.methods.RequestEntity toRequestEntity(Object value)
                                                                           throws PageException
Throws:
PageException

removeRef

public static URL removeRef(URL url)
                     throws MalformedURLException
Throws:
MalformedURLException

removeRef

public static String removeRef(String url)
                        throws MalformedURLException
Throws:
MalformedURLException

toURL

public static URL toURL(org.apache.commons.httpclient.HttpMethod httpMethod)

optimizeRealPath

public static String optimizeRealPath(PageContext pc,
                                      String realPath)

forward

public static void forward(PageContext pc,
                           String realPath)
                    throws javax.servlet.ServletException,
                           IOException
Throws:
javax.servlet.ServletException
IOException

removeWrap

public static javax.servlet.ServletRequest removeWrap(javax.servlet.ServletRequest req)

include

public static void include(PageContext pc,
                           String realPath)
                    throws javax.servlet.ServletException,
                           IOException
Throws:
javax.servlet.ServletException
IOException

include

public static void include(PageContext pc,
                           javax.servlet.ServletRequest req,
                           javax.servlet.ServletResponse rsp,
                           String realPath)
                    throws javax.servlet.ServletException,
                           IOException
Throws:
javax.servlet.ServletException
IOException

encode

public static String encode(String realpath)

getPort

public static int getPort(URL url)

length

public static long length(URL url)
return the length of a file defined by a url.

Parameters:
dataUrl -
Returns:

getContentType

public static ContentType getContentType(org.apache.commons.httpclient.HttpMethod http)

parseParameterList

public static Map<String,String> parseParameterList(String _str,
                                                    boolean decode,
                                                    String charset)

splitMimeTypeAndCharset

public static String[] splitMimeTypeAndCharset(String mimetype)

splitTypeAndSubType

public static String[] splitTypeAndSubType(String mimetype)

isSecure

public static boolean isSecure(URL url)


Copyright © 2012 Railo