Package org.opennms.netmgt.rtc
Class HttpUtils
- java.lang.Object
-
- org.opennms.netmgt.rtc.HttpUtils
-
public abstract class HttpUtils extends java.lang.Object
Provides convenience methods for use the HTTP POST method.- Author:
- Lawrence Karnowski
-
-
Field Summary
Fields Modifier and Type Field Description static int
DEFAULT_CONNECT_TIMEOUT
static int
DEFAULT_POST_BUFFER_SIZE
Default buffer size for reading data.
-
Constructor Summary
Constructors Constructor Description HttpUtils()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static java.io.InputStream
post(java.net.URL url, java.io.InputStream dataStream)
Post a givenInputStream
s data to a URL.static java.io.InputStream
post(java.net.URL url, java.io.InputStream dataStream, java.lang.String username, java.lang.String password)
Post a givenInputStream
s data to a URL using BASIC authentication and the given username and password.static java.io.InputStream
post(java.net.URL url, java.io.InputStream dataStream, java.lang.String username, java.lang.String password, int bufSize, int timeout)
Post a givenInputStream
s data to a URL using BASIC authentication, the given username and password, and a buffer size.static java.io.InputStream
post(java.net.URL url, java.io.Reader dataReader, java.lang.String username, java.lang.String password, int bufSize, int timeout)
Post a givenReader
s data to a URL using BASIC authentication, the given username and password, and a buffer size.
-
-
-
Field Detail
-
DEFAULT_POST_BUFFER_SIZE
public static final int DEFAULT_POST_BUFFER_SIZE
Default buffer size for reading data. (Default is one kilobyte.)- See Also:
- Constant Field Values
-
DEFAULT_CONNECT_TIMEOUT
public static final int DEFAULT_CONNECT_TIMEOUT
- See Also:
- Constant Field Values
-
-
Method Detail
-
post
public static java.io.InputStream post(java.net.URL url, java.io.InputStream dataStream) throws java.io.IOException
Post a givenInputStream
s data to a URL.- Parameters:
url
- theURL
to post todataStream
- an input stream containing the data to send- Returns:
- An
InputStream
that the programmer can read from to get the HTTP server's response. - Throws:
java.io.IOException
- if any.
-
post
public static java.io.InputStream post(java.net.URL url, java.io.InputStream dataStream, java.lang.String username, java.lang.String password) throws java.io.IOException
Post a givenInputStream
s data to a URL using BASIC authentication and the given username and password.- Parameters:
url
- theURL
to post todataStream
- an input stream containing the data to sendusername
- the username to use in the BASIC authenticationpassword
- the password to use in the BASIC authentication- Returns:
- An
InputStream
that the programmer can read from to get the HTTP server's response. - Throws:
java.io.IOException
- if any.
-
post
public static java.io.InputStream post(java.net.URL url, java.io.InputStream dataStream, java.lang.String username, java.lang.String password, int bufSize, int timeout) throws java.io.IOException
Post a givenInputStream
s data to a URL using BASIC authentication, the given username and password, and a buffer size.- Parameters:
url
- theURL
to post todataStream
- an input stream containing the data to sendusername
- the username to use in the BASIC authenticationpassword
- the password to use in the BASIC authenticationbufSize
- the size of the buffer to read fromdataStream
and write to the HTTP server- Returns:
- An
InputStream
that the programmer can read from to get the HTTP server's response. - Throws:
java.io.IOException
- if any.
-
post
public static java.io.InputStream post(java.net.URL url, java.io.Reader dataReader, java.lang.String username, java.lang.String password, int bufSize, int timeout) throws java.io.IOException
Post a givenReader
s data to a URL using BASIC authentication, the given username and password, and a buffer size.- Parameters:
url
- theURL
to post todataReader
- an input reader containing the data to sendusername
- the username to use in the BASIC authenticationpassword
- the password to use in the BASIC authenticationbufSize
- the size of the buffer to read fromdataStream
and write to the HTTP server- Returns:
- An
InputStream
that the programmer can read from to get the HTTP server's response. - Throws:
java.io.IOException
- if any.
-
-