public class HttpRequest
extends java.lang.Object
execute()
method can be used
(repeatedly) to send requests and wait for a response.Modifier and Type | Class and Description |
---|---|
static class |
HttpRequest.Method
Enumeration of possible HTTP request methods.
|
Constructor and Description |
---|
HttpRequest()
Construct a new, empty HTTP request.
|
HttpRequest(java.net.URL url,
HttpRequest.Method method,
RecordToken properties,
java.lang.String body,
int timeout)
Construct a new HTTP request, parameterized with a URL, method,
properties, body, and time out.
|
Modifier and Type | Method and Description |
---|---|
void |
disconnect()
Disconnect the current HttpURLConnection.
|
HttpResponse |
execute()
Issue a HTTP request using the specified URL.
|
java.lang.String |
getBody()
Get the body of the message.
|
java.net.HttpURLConnection |
getConnection()
Get the current connection.
|
java.lang.String |
getLineBreak()
Set the lineBreak character sequence.
|
HttpRequest.Method |
getMethod()
Get the request method.
|
RecordToken |
getProperties()
Get the properties that determine the HTTP header.
|
int |
getTimeout()
Get the timeout observed upon execution of the request.
|
java.net.URL |
getUrl()
Get the currently set URL.
|
void |
setBody(java.lang.String body)
Set the body of the message.
|
void |
setConnection(java.net.HttpURLConnection connection)
Set the current connection.
|
void |
setLineBreak(java.lang.String lineBreak)
Set the lineBreak character sequence.
|
void |
setMethod(HttpRequest.Method method)
Set the request method.
|
void |
setProperties(RecordToken properties)
Set the properties that determine the HTTP header.
|
void |
setTimeout(int timeout)
Set the timeout observed upon execution of the request.
|
void |
setUrl(java.net.URL url)
Set the url to send this HTTP request to.
|
public HttpRequest()
public HttpRequest(java.net.URL url, HttpRequest.Method method, RecordToken properties, java.lang.String body, int timeout)
url
- The URL to send the request to.method
- The request method (e.g., GET/POST/PUT ...).
According to the Java documentation,
"GET POST HEAD OPTIONS PUT DELETE TRACE are legal, subject to protocol
restrictions."properties
- Optional properties included as part of the headerbody
- The message content to sendtimeout
- The maximum timeout to wait for obtaining a connection,
issuing the request and receiving a responsepublic HttpResponse execute()
public void disconnect()
public java.lang.String getBody()
setBody(String)
public java.net.HttpURLConnection getConnection()
setConnection(HttpURLConnection)
public java.lang.String getLineBreak()
setLineBreak(String)
public HttpRequest.Method getMethod()
setMethod(Method)
public RecordToken getProperties()
setProperties(RecordToken)
public int getTimeout()
setTimeout(int)
public java.net.URL getUrl()
setUrl(URL)
public void setBody(java.lang.String body)
body
- The body of the message.getBody()
public void setConnection(java.net.HttpURLConnection connection)
connection
- A HttpURLConnection object.getConnection()
public void setLineBreak(java.lang.String lineBreak)
lineBreak
- A String containing the line break sequence.getLineBreak()
public void setMethod(HttpRequest.Method method)
method
- The request method.getMethod()
public void setProperties(RecordToken properties)
properties
- A record token that maps header fields to strings.getProperties()
public void setTimeout(int timeout)
timeout
- An integer denoting time in milliseconds.getTimeout()
public void setUrl(java.net.URL url)
url
- The target URL.getUrl()