com.sibvisions.util.type
Class HttpUtil

java.lang.Object
  extended by com.sibvisions.util.type.HttpUtil

public final class HttpUtil
extends Object

The HttpUtil is a utility class for http communication.


Method Summary
static String escapeHtml(String pText)
          Replaces special characters with escape characters, valid for html.
static InputStream get(String pURL)
          Sends a get request.
static InputStream get(String pURL, File pFile)
          Sends a get request with given file.
static InputStream get(String pURL, InputStream pStream)
          Sends a get request with content.
static InputStream get(String pURL, InputStream pStream, Map<String,String> pProperties)
          Sends a get request with content.
static InputStream get(String pURL, InputStream pStream, Map<String,String> pProperties, int pTimeout)
          Sends a get request with content.
static String getETag(File pFile)
          Gets the ETag http header value for the last modified of a file.
static String getLastModified(File pFile)
          Gets the Last-Modified http header value for the last modified of a file.
static InputStream post(String pURL)
          Sends an empty post request.
static InputStream post(String pURL, File pFile)
          Sends a post request with given file.
static InputStream post(String pURL, InputStream pStream)
          Sends a post request with given data.
static InputStream post(String pURL, InputStream pStream, String pFileName)
          Sends a post request with given content.
static InputStream post(String pURL, InputStream pStream, String pFileName, Map<String,String> pProperties)
          Sends a post request with given content.
static InputStream post(String pURL, InputStream pStream, String pFileName, Map<String,String> pProperties, int pTimeout)
          Sends a post request with given content.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

post

public static InputStream post(String pURL)
                        throws Exception
Sends an empty post request.

Parameters:
pURL - the URL
Returns:
the response stream
Throws:
Exception - if communication failed

post

public static InputStream post(String pURL,
                               InputStream pStream)
                        throws Exception
Sends a post request with given data.

Parameters:
pURL - the URL
pStream - the content to send
Returns:
the response stream
Throws:
Exception - if communication failed

post

public static InputStream post(String pURL,
                               File pFile)
                        throws Exception
Sends a post request with given file.

Parameters:
pURL - the URL
pFile - the file
Returns:
the response stream
Throws:
Exception - if communication failed

post

public static InputStream post(String pURL,
                               InputStream pStream,
                               String pFileName)
                        throws Exception
Sends a post request with given content.

Parameters:
pURL - the URL
pStream - the content to send
pFileName - the file name
Returns:
the response stream
Throws:
Exception - if communication failed

post

public static InputStream post(String pURL,
                               InputStream pStream,
                               String pFileName,
                               Map<String,String> pProperties)
                        throws Exception
Sends a post request with given content.

Parameters:
pURL - the URL
pStream - the content to send
pFileName - the file name
pProperties - additional request properties
Returns:
the response stream
Throws:
Exception - if communication failed

post

public static InputStream post(String pURL,
                               InputStream pStream,
                               String pFileName,
                               Map<String,String> pProperties,
                               int pTimeout)
                        throws Exception
Sends a post request with given content.

Parameters:
pURL - the URL
pStream - the content to send
pFileName - the file name
pProperties - additional request properties
pTimeout - the connect and read timeout
Returns:
the response stream
Throws:
Exception - if communication failed

get

public static InputStream get(String pURL)
                       throws Exception
Sends a get request.

Parameters:
pURL - the URL
Returns:
the response stream
Throws:
Exception - if communication failed

get

public static InputStream get(String pURL,
                              File pFile)
                       throws Exception
Sends a get request with given file.

Parameters:
pURL - the URL
pFile - the file
Returns:
the response stream
Throws:
Exception - if communication failed

get

public static InputStream get(String pURL,
                              InputStream pStream)
                       throws Exception
Sends a get request with content.

Parameters:
pURL - the URL
pStream - the content stream
Returns:
the response stream
Throws:
Exception - if communication failed

get

public static InputStream get(String pURL,
                              InputStream pStream,
                              Map<String,String> pProperties)
                       throws Exception
Sends a get request with content.

Parameters:
pURL - the URL
pStream - the content stream
pProperties - additional request properties
Returns:
the response stream
Throws:
Exception - if communication failed

get

public static InputStream get(String pURL,
                              InputStream pStream,
                              Map<String,String> pProperties,
                              int pTimeout)
                       throws Exception
Sends a get request with content.

Parameters:
pURL - the URL
pStream - the content stream
pProperties - additional request properties
pTimeout - the connect and read timeout
Returns:
the response stream
Throws:
Exception - if communication failed

escapeHtml

public static String escapeHtml(String pText)
Replaces special characters with escape characters, valid for html.

Parameters:
pText - the text
Returns:
the escaped text

getETag

public static String getETag(File pFile)
Gets the ETag http header value for the last modified of a file.

Parameters:
pFile - the requested file
Returns:
the ETag value with the last modified of the file

getLastModified

public static String getLastModified(File pFile)
Gets the Last-Modified http header value for the last modified of a file.

Parameters:
pFile - the requested file
Returns:
the Last-Modified value with the last modified of the file


Copyright © 2009 SIB Visions GmbH. All Rights Reserved.