com.sibvisions.util.type
Class HttpUtil

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

public final class HttpUtil
extends java.lang.Object

The HttpUtil is a utility class for http communication.


Method Summary
static java.lang.String escapeHtml(java.lang.String pText)
          Replaces special characters with escape characters, valid for html.
static java.io.InputStream get(java.lang.String pURL)
          Sends a get request.
static java.io.InputStream get(java.lang.String pURL, java.io.File pFile)
          Sends a get request with given file.
static java.io.InputStream get(java.lang.String pURL, java.io.InputStream pStream)
          Sends a get request with content.
static java.io.InputStream get(java.lang.String pURL, java.io.InputStream pStream, java.util.Map<java.lang.String,java.lang.String> pProperties)
          Sends a get request with content.
static java.io.InputStream get(java.lang.String pURL, java.io.InputStream pStream, java.util.Map<java.lang.String,java.lang.String> pProperties, int pTimeout)
          Sends a get request with content.
static java.lang.String getETag(java.io.File pFile)
          Gets the ETag http header value for the last modified of a file.
static java.lang.String getLastModified(java.io.File pFile)
          Gets the Last-Modified http header value for the last modified of a file.
static java.io.InputStream post(java.lang.String pURL)
          Sends an empty post request.
static java.io.InputStream post(java.lang.String pURL, java.io.File pFile)
          Sends a post request with given file.
static java.io.InputStream post(java.lang.String pURL, java.io.InputStream pStream)
          Sends a post request with given data.
static java.io.InputStream post(java.lang.String pURL, java.io.InputStream pStream, java.lang.String pFileName)
          Sends a post request with given content.
static java.io.InputStream post(java.lang.String pURL, java.io.InputStream pStream, java.lang.String pFileName, java.util.Map<java.lang.String,java.lang.String> pProperties)
          Sends a post request with given content.
static java.io.InputStream post(java.lang.String pURL, java.io.InputStream pStream, java.lang.String pFileName, java.util.Map<java.lang.String,java.lang.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 java.io.InputStream post(java.lang.String pURL)
                                throws java.lang.Exception
Sends an empty post request.

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

post

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

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

post

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

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

post

public static java.io.InputStream post(java.lang.String pURL,
                                       java.io.InputStream pStream,
                                       java.lang.String pFileName)
                                throws java.lang.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:
java.lang.Exception - if communication failed

post

public static java.io.InputStream post(java.lang.String pURL,
                                       java.io.InputStream pStream,
                                       java.lang.String pFileName,
                                       java.util.Map<java.lang.String,java.lang.String> pProperties)
                                throws java.lang.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:
java.lang.Exception - if communication failed

post

public static java.io.InputStream post(java.lang.String pURL,
                                       java.io.InputStream pStream,
                                       java.lang.String pFileName,
                                       java.util.Map<java.lang.String,java.lang.String> pProperties,
                                       int pTimeout)
                                throws java.lang.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:
java.lang.Exception - if communication failed

get

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

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

get

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

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

get

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

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

get

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

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

get

public static java.io.InputStream get(java.lang.String pURL,
                                      java.io.InputStream pStream,
                                      java.util.Map<java.lang.String,java.lang.String> pProperties,
                                      int pTimeout)
                               throws java.lang.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:
java.lang.Exception - if communication failed

escapeHtml

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

Parameters:
pText - the text
Returns:
the escaped text

getETag

public static java.lang.String getETag(java.io.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 java.lang.String getLastModified(java.io.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.