|
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||
java.lang.Object | +--com.finwin.util.HTTPRequest
An object for making HTTP requests over TCP/IP. This object implements an HTTP
request, including producting an HTTP/1.0 header and reading the response
header. It will perform an HTTP post operation, allowing the program to specify
keyed elements for the post.
Note: When using this object, the method close() must be called
to release network resources heald by the object. If close() is not called
memory leaks and network resource leaks may occur.
| Inner Class Summary | |
class |
HTTPRequest.pair
|
| Field Summary | |
static int |
GET
|
static int |
POST
|
| Constructor Summary | |
HTTPRequest(int method,
java.net.URL url)
Constructs the HTTP request secifying the method for the request and the url to contact. |
|
| Method Summary | |
void |
addHeader(java.lang.String key,
java.lang.String value)
Adds an element to the request header. |
void |
addPostValue(java.lang.String key,
java.lang.String value)
Adds a value to the post request. |
void |
close()
Releases the TCP/IP data in use by the request. |
java.lang.String |
getHeader(java.lang.String key)
Attempts to locate a header entry. |
java.io.BufferedReader |
getInputReader()
Returns the input stream from the request, so that large files may be read by buffered readers. |
java.lang.String |
getResponse()
Reads the response and returns it as a string. |
int |
getResultCode()
Obtains the result code. |
int |
request()
Makes the request from the server. |
static java.lang.String |
urlEnc(java.lang.String s)
Encodes a string URL style. |
| Methods inherited from class java.lang.Object |
clone,
equals,
finalize,
getClass,
hashCode,
notify,
notifyAll,
toString,
wait,
wait,
wait |
| Field Detail |
public static final int GET
public static final int POST
| Constructor Detail |
public HTTPRequest(int method,
java.net.URL url)
method must
come from the set {HTTPRequest.GET, HTTPRequest.POST}.
The url must be a valid URL. Calling this method will default the
request port| Method Detail |
public void addHeader(java.lang.String key,
java.lang.String value)
key - The name of the header elementvalue - The value of the element to add to the request header
public void addPostValue(java.lang.String key,
java.lang.String value)
method to the constructor,
otherwise this method will throw an IllegalArgumentExceptionkey - The name of the value to be posted with the request.value - The value of the element to be posted with the request.public static final java.lang.String urlEnc(java.lang.String s)
s - The source valuepublic java.lang.String getHeader(java.lang.String key)
key - The header key to locatepublic java.lang.String getResponse()
public java.io.BufferedReader getInputReader()
public int getResultCode()
request()request()public void close()
HTTPRequest.public int request()
getResponse() or calling getInputReader()
to get the response's input reader.getResponse(),
getInputReader()
|
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||