public abstract class AbstractHTTPRequest
extends java.lang.Object
AbstractHTTPRequest
class encapsulates an HTTP request to ISY.
This class may also be used for other types of HTTP request and it's the
superclass to UDSOAPRequest
UDSOAPRequest
Modifier and Type | Field and Description |
---|---|
protected java.net.InetSocketAddress |
address
The address segment of the URL (includes the port)
|
protected java.io.ByteArrayOutputStream |
ba
The output stream encapsulated in a
ByteArrayOutputStream |
protected boolean |
closed
The status of the socket: true if close, false otherwise
|
protected java.lang.String |
credentials |
protected java.lang.String |
hostName
The HOST header name
|
protected java.io.InputStream |
is
The input stream
|
protected java.lang.String |
method
The method which is either a GET or a POST
|
protected java.io.OutputStream |
os
The output stream
|
protected java.nio.channels.SocketChannel |
sc |
protected static int |
SEND_BUFFER_SIZE |
java.lang.String |
url_path
The path segment of the URL (such as /web/nodescnf.xml)
|
Modifier | Constructor and Description |
---|---|
protected |
AbstractHTTPRequest(java.lang.String hostName,
java.net.InetSocketAddress address,
java.lang.String url_path)
Constructor
|
protected |
AbstractHTTPRequest(java.lang.String hostName,
java.net.InetSocketAddress address,
java.lang.String method,
java.lang.String url_path)
Constructor
|
Modifier and Type | Method and Description |
---|---|
abstract void |
close(int status)
Releases all the resources
|
static AbstractHTTPRequest |
create(boolean isSSL,
java.lang.String hostName,
java.net.InetSocketAddress address,
java.lang.String url_path,
java.lang.String httpCredentials)
UDHTTPRequest and UDHTTPSRequest factory method
|
static AbstractHTTPRequest |
create(boolean isSSL,
java.lang.String hostName,
java.net.InetSocketAddress address,
java.lang.String method,
java.lang.String url_path,
java.lang.String httpCredentials)
UDHTTPRequest and UDHTTPSRequest factory method
|
static AbstractHTTPRequest |
create(java.lang.String url,
java.lang.String httpCredentials)
UDHTTPRequest and UDHTTPSRequest factory method
|
java.lang.String |
get()
Issues a GET request to the URL pointed to by this object.
|
java.lang.String |
getFile() |
java.lang.StringBuffer |
getHeader(int body_length,
boolean terminate_header)
Returns the HTTP header for this request
|
java.lang.String |
getHost()
Returns the String representation of the host segment of the URL for this request
|
java.lang.StringBuffer |
getHostAndPort()
Returns the host:port combination for the URL for this request
|
int |
getPort()
Returns the port segment of the URL for this request
|
abstract java.lang.String |
getProtocol() |
UDHTTPResponse |
getServerResponse(java.lang.StringBuffer header,
java.lang.StringBuffer body,
boolean keep_alive)
Issues the request to the server and returns the response in
UDHTTPResponse object |
abstract UDHTTPResponse |
getServerResponse(java.lang.StringBuffer header,
java.lang.StringBuffer body,
boolean keep_alive,
java.lang.Object device)
Issues the request to the server and returns the response
|
abstract java.net.Socket |
getSocket() |
int |
getSocketTimeoutMillis()
Returns the number of milliseconds before the socket times out.
|
java.lang.String |
getURL()
Returns the String representation of the URL for this request
|
abstract boolean |
isSSL() |
UDHTTPResponse |
post(byte[] body,
boolean keep_alive,
IUpdaterClient view)
Simple post
|
abstract UDHTTPResponse |
post(java.lang.StringBuffer header,
byte[] body,
boolean keep_alive,
java.lang.Object device,
IUpdaterClient view)
Simple post
|
static void |
setSendBufferSize(boolean isLarge) |
void |
setSocketTimeoutMillis(int v)
Sets the number of milliseconds before the socket times out.
|
protected static int SEND_BUFFER_SIZE
public java.lang.String url_path
protected java.net.InetSocketAddress address
protected java.lang.String hostName
protected java.lang.String method
protected java.io.InputStream is
protected java.io.OutputStream os
protected boolean closed
protected java.io.ByteArrayOutputStream ba
ByteArrayOutputStream
protected java.nio.channels.SocketChannel sc
protected java.lang.String credentials
protected AbstractHTTPRequest(java.lang.String hostName, java.net.InetSocketAddress address, java.lang.String method, java.lang.String url_path)
hostName
- - the actual HOST header name to be used in the calladdress
- - the address segment of the URL including portmethod
- - the method either GET or POSTurl_path
- - the path segment of the URL (i.e. /web/nodescnf.xml)protected AbstractHTTPRequest(java.lang.String hostName, java.net.InetSocketAddress address, java.lang.String url_path)
Note: the method is defaulted to "GET"
hostName
- - the actual HOST header name to be used in the calladdress
- - the address segment of the URL including porturl_path
- - the path segment of the URL (i.e. /web/nodescnf.xml)public int getSocketTimeoutMillis()
public void setSocketTimeoutMillis(int v)
public java.lang.String getURL()
public java.lang.String getHost()
public int getPort()
public java.lang.String getFile()
public java.lang.StringBuffer getHostAndPort()
public java.lang.StringBuffer getHeader(int body_length, boolean terminate_header)
body_length
- - the length of the body for this request. Content-Length is
used only for POST methodterminate_header
- - whether or not to terminate the header with a \r\n; this UDSOAPRequest
public UDHTTPResponse getServerResponse(java.lang.StringBuffer header, java.lang.StringBuffer body, boolean keep_alive)
UDHTTPResponse
objectheader
- - the header for the requestbody
- - the body for the request if any (in case of POST)keep_alive
- - whether or not the connection should be kept aliveUDHTTPResponse
UDHTTPResponse
public abstract UDHTTPResponse getServerResponse(java.lang.StringBuffer header, java.lang.StringBuffer body, boolean keep_alive, java.lang.Object device)
The response is of type UDHTTPResponse
Use this method to encapuslate requests to ISY
header
- - the header for the requestbody
- - the body for the request if any (in case of POST)keep_alive
- - whether or not the connection should be kept alivedevice
- - the UDProxyDevice
objectUDHTTPResponse
UDHTTPResponse
,
UDProxyDevice
public UDHTTPResponse post(byte[] body, boolean keep_alive, IUpdaterClient view)
body
- - the body for the request if any (in case of POST)keep_alive
- - whether or not the connection should be kept aliveview
- - updates the progress barUDHTTPResponse
UDHTTPResponse
public abstract UDHTTPResponse post(java.lang.StringBuffer header, byte[] body, boolean keep_alive, java.lang.Object device, IUpdaterClient view)
The response is of type UDHTTPResponse
Use this method to encapuslate requests to ISY
header
- - the header for the requestbody
- - the body for the request if any (in case of POST)keep_alive
- - whether or not the connection should be kept alivedevice
- - the UDProxyDevice
objectUDHTTPResponse
UDHTTPResponse
,
UDProxyDevice
public java.lang.String get()
Does not work with any content except text/xml/html
public abstract void close(int status)
Releases all resources and closes all the connection which this object holds
status
- - @depracatedpublic abstract java.lang.String getProtocol()
public abstract java.net.Socket getSocket()
public abstract boolean isSSL()
public static AbstractHTTPRequest create(boolean isSSL, java.lang.String hostName, java.net.InetSocketAddress address, java.lang.String method, java.lang.String url_path, java.lang.String httpCredentials)
UDHTTPRequest and UDHTTPSRequest factory method
isSSL
- - whether or not to return UDHTTPRequest or UDHTTPSRequesthostName
- - the actual HOST header name to be used in the calladdress
- - the address segment of the URL including portmethod
- - the method either GET or POSTurl_path
- - the path segment of the URL (i.e. /web/nodescnf.xml)httpCredentials
- - Complete HTTP Authorization headerpublic static AbstractHTTPRequest create(boolean isSSL, java.lang.String hostName, java.net.InetSocketAddress address, java.lang.String url_path, java.lang.String httpCredentials)
UDHTTPRequest and UDHTTPSRequest factory method
Note: the method is defaulted to "GET"isSSL
- - whether or not to return UDHTTPRequest or UDHTTPSRequesthostName
- - the actual HOST header name to be used in the calladdress
- - the address segment of the URL including porturl_path
- - the path segment of the URL (i.e. /web/nodescnf.xml)httpCredentials
- - Complete HTTP Authorization headerpublic static AbstractHTTPRequest create(java.lang.String url, java.lang.String httpCredentials)
UDHTTPRequest and UDHTTPSRequest factory method
Creates a request based on a String representation of an URLurl
- - the URLpublic static void setSendBufferSize(boolean isLarge)