public class Http
extends java.lang.Object
implements java.io.Serializable
Example Usage:
Http http = new Http(); // build HTTP request HttpRequest request = new HttpRequest("http://www.myserver.com"); // get HTTP response try { HttpResponse response = http.getResponse(request); System.out.println(new String(response.getBody())); } catch(Exception e) { System.out.println(e); }
Constructor and Description |
---|
Http()
Constructs a new
Http instance. |
Modifier and Type | Method and Description |
---|---|
void |
addHttpListener(HttpListener listener)
Adds an event listener for events implemented by
HttpListener interface. |
void |
clearProxySettings()
Clears proxy server values.
|
java.io.PrintStream |
getDebugStream()
Gets PrintStream used in reporting debug statements.
|
long |
getMaxDataSize()
Returns max data size.
|
int |
getReadBlockSize()
Gets the number of bytes read in each block of data read from server
|
HttpResponse |
getResponse(HttpFileUpload request)
Gets response to HTTP request.
|
HttpResponse |
getResponse(HttpRequest request)
Gets response to HTTP request.
|
HttpResponse |
getResponseToFile(HttpRequest request,
java.io.File file)
Gets response to HTTP request and writes contents to file.
|
int |
getTimeout()
Gets the timeout used when opening a HTTP connection.
|
int |
getWriteBlockSize()
Gets number of bytes written in each block to server
|
boolean |
isDebug()
Gets debug level of HTTP session.
|
void |
removeHttpListener(HttpListener listener)
Removes instance of
HttpListener . |
void |
setDebug(boolean value)
Sets debugging state.
|
void |
setDebugStream(java.io.PrintStream debugStream)
Sets PrintStream used in reporting debug statements.
|
void |
setMaxDataSize(long value)
Sets max data size.
|
void |
setProxyAuthentication(java.lang.String proxyUsername,
java.lang.String proxyPassword)
Sets the username and password to use when for authentication with
proxy server.
|
void |
setProxyHost(java.lang.String proxyHostname,
int proxyPort)
Sets the proxy hostname and port for this connection.
|
void |
setProxyType(java.lang.String proxyType)
Sets the proxy type will be used for this connection.
|
void |
setReadBlockSize(int value)
Sets the number of bytes read in each block of data read from server
|
void |
setTimeout(int value)
Sets the timeout for opening a HTTP connection.
|
void |
setWriteBlockSize(int value)
Sets number of bytes written in each block to server
|
public int getTimeout()
public void setTimeout(int value)
value
- in millisecondspublic boolean isDebug()
true
if debugging is onsetDebugStream(java.io.PrintStream)
public void setDebug(boolean value)
value
- true
to turn debugging onsetDebugStream(java.io.PrintStream)
public java.io.PrintStream getDebugStream()
PrintStream
public void setDebugStream(java.io.PrintStream debugStream)
debugStream
- the PrintStream to send debug statements toPrintStream
public int getWriteBlockSize()
public void setWriteBlockSize(int value)
value
- block sizepublic int getReadBlockSize()
public void setReadBlockSize(int value)
value
- block sizepublic long getMaxDataSize()
public void setMaxDataSize(long value)
value
- the max data size in bytespublic void setProxyAuthentication(java.lang.String proxyUsername, java.lang.String proxyPassword)
#clearProxySettings
method.proxyUsername
- the proxy usernameproxyPassword
- the proxy passwordclearProxySettings()
public void setProxyHost(java.lang.String proxyHostname, int proxyPort)
#clearProxySettings
method.proxyHostname
- the hostname or ip address of the proxy serverproxyPort
- the port of the proxy serverclearProxySettings()
public void setProxyType(java.lang.String proxyType)
proxyType
- The proxy type. Valid values: HTTP, SOCKS5public void clearProxySettings()
public void addHttpListener(HttpListener listener)
HttpListener
interface.listener
- an HttpListener
HttpListener
public void removeHttpListener(HttpListener listener)
HttpListener
.listener
- an HttpListener
HttpListener
public HttpResponse getResponse(HttpFileUpload request) throws HttpException
request
- the HttpFileUpload to performHttpResponse
HttpException
- thrown if an I/O or HTTP related error occursHttpResponse
,
HttpException
public HttpResponse getResponse(HttpRequest request) throws HttpException
request
- the HttpRequest to performHttpResponse
HttpException
- thrown if an I/O or HTTP related error occursHttpResponse
,
HttpException
public HttpResponse getResponseToFile(HttpRequest request, java.io.File file) throws HttpException
request
- the HttpRequest to performfile
- the file to write the response toHttpResponse
written to fileHttpException
- thrown if an I/O or HTTP related error occursHttpResponse
,
HttpException
Copyright © JSCAPE LLC. 1999-2021. All Rights Reserved