public class HttpRequest
extends java.lang.Object
A cross-platform HTTP API modeled after XMLHttpRequest. Supports streaming of request and response content.
public void classExample() { com.sap.cloud.server.odata.http.HttpRequest request = new com.sap.cloud.server.odata.http.HttpRequest(); request.open(com.sap.cloud.server.odata.http.HttpMethod.GET, "http://google.com"); request.send(); String text = request.getResponseText(); request.close(); Example.show("google.com home page text: ", text); }
Constructor and Description |
---|
HttpRequest() |
Modifier and Type | Method and Description |
---|---|
void |
close()
Close this HTTP request, and any response stream that may have been opened by
HttpRequest.send . |
void |
enableTrace(java.lang.String serviceName,
boolean traceRequest,
boolean traceHeaders,
boolean traceContent,
boolean prettyPrint)
Enable HTTP request tracing.
|
java.lang.String |
getBaseAddress()
Return base address (scheme + authority = protocol + endpoint) for data servlet executing the request, e.g.
|
int |
getBatchPartIndex()
Return if
HttpRequest.isPartOfBatch is true, the part index within the batch (starting from 1). |
boolean |
getCompressRequest()
Return set to
true before calling HttpRequest.send if the caller should compress the request content (using "gzip" encoding). |
boolean |
getCompressResponse()
Return set to
false before calling HttpRequest.send if the server should compress the response content (using "gzip" encoding). |
java.lang.String |
getContextPath()
Return context path for data servlet executing the request (e.g.
|
java.lang.String |
getFullPathToServlet()
Return full path to servlet (omitting request path and query string).
|
HttpHandler |
getHandler()
Return (nullable) The optional internal handler for this request.
|
java.lang.String |
getMethod()
Return the HTTP method for this request.
|
java.lang.String |
getPassword()
Return (nullable) The password for this request.
|
boolean |
getPrettyPrint()
Return is this request enabled for pretty-printed tracing?
|
ByteStream |
getRequestBytes()
Return (nullable) Request data stream.
|
CharStream |
getRequestChars()
Return (nullable) Request text stream.
|
java.lang.String |
getRequestCookie(java.lang.String name)
Get a request cookie value.
|
HttpCookies |
getRequestCookies()
Return HTTP request cookies.
|
byte[] |
getRequestData()
Return (nullable) Request data for a non-streamed request.
|
java.lang.String |
getRequestHeader(java.lang.String name)
Get a request header value.
|
HttpHeaders |
getRequestHeaders()
Return HTTP request headers.
|
RequestOptions |
getRequestOptions()
Return caller's request options.
|
java.lang.String |
getRequestText()
Return (nullable) Request text for a non-streamed request.
|
ByteStream |
getResponseBytes()
Return response data stream.
|
CharStream |
getResponseChars()
Return response text stream.
|
java.lang.String |
getResponseCookie(java.lang.String name)
Get a response cookie value.
|
HttpCookies |
getResponseCookies()
Return HTTP response cookies.
|
byte[] |
getResponseData()
Return response data for a non-streamed response.
|
long |
getResponseDataCount()
Return response data counter.
|
long |
getResponseGzipCount()
Return response gzip counter.
|
java.lang.String |
getResponseHeader(java.lang.String name)
Get a response header value.
|
HttpHeaders |
getResponseHeaders()
Return HTTP response headers.
|
java.lang.String |
getResponseText()
Return response text for a non-streamed response.
|
boolean |
getServerCanStreamResponse()
Return can the response to this request possibly be streamed?
|
java.lang.String |
getServletPath()
Return servlet path for data servlet executing the request (e.g.
|
javax.servlet.http.HttpServletRequest |
getServletRequest() |
javax.servlet.http.HttpServletResponse |
getServletResponse() |
int |
getStatus()
Return HTTP response status code.
|
java.lang.String |
getStatusText()
Return HTTP response status text.
|
boolean |
getStreamRequest()
Return set to
false before calling HttpRequest.send if the caller does not wish to stream the request content. |
boolean |
getStreamResponse()
Return set to
false before calling HttpRequest.send if the caller does not wish to stream the response content. |
boolean |
getTraceContent()
Return is this request enabled for tracing of request/response content?
|
boolean |
getTraceHeaders()
Return is this request enabled for tracing of request/response headers?
|
java.lang.String |
getTraceID()
Return process-local ID for this request (for tracing purposes).
|
boolean |
getTraceRequest()
Return is this request enabled for request/response tracing?
|
boolean |
getUnzipResponse()
Return does response need to be unzipped? Should be set by
HttpHandler subclasses. |
java.lang.String |
getUrl()
Return the URL for this request.
|
java.lang.String |
getUsername()
Return (nullable) The username for this request.
|
int |
getVersion()
Return the HTTP version for this request.
|
boolean |
hasResponseBytes()
Return does this request have a byte stream response already set?
|
boolean |
hasResponseChars()
Return does this request have a text stream response already set?
|
boolean |
hasResponseData()
Return does this request have a binary (data) response already set?
|
boolean |
hasResponseText()
Return does this request have a string (text) response already set?
|
boolean |
isActive()
Return is a connection active (
HttpRequest.send was called, but HttpRequest.close has not yet been called)? |
boolean |
isPartOfBatch()
Return is this request part of a request batch?
|
void |
login(java.lang.String username,
java.lang.String password)
Specify the HTTP basic credentials.
|
void |
open(java.lang.String method,
java.lang.String url)
Specify the HTTP
HttpRequest.method and HttpRequest.url . |
void |
send()
Send this HTTP request to the server, and wait for a response.
|
ByteStream |
serverRequestBytes()
Return request content, resolved to ByteStream from
HttpRequest.requestBytes , HttpRequest.requestData , HttpRequest.requestChars , HttpRequest.requestText (whichever is first found to have content). |
CharStream |
serverRequestChars()
Return request content, resolved to CharStream from
HttpRequest.requestBytes , HttpRequest.requestData , HttpRequest.requestChars , HttpRequest.requestText (whichever is first found to have content). |
byte[] |
serverRequestData()
Return request content, resolved to binary from
HttpRequest.requestBytes , HttpRequest.requestData , HttpRequest.requestChars , HttpRequest.requestText (whichever is first found to have content). |
java.lang.String |
serverRequestText()
Return request content, resolved to string from
HttpRequest.requestBytes , HttpRequest.requestData , HttpRequest.requestChars , HttpRequest.requestText (whichever is first found to have content). |
ByteStream |
serverResponseBytes()
Return response content, resolved to ByteStream from
HttpRequest.responseBytes , HttpRequest.responseData , HttpRequest.responseChars , HttpRequest.responseText (whichever is first found to have content). |
CharStream |
serverResponseChars()
Return response content, resolved to CharStream from
HttpRequest.responseBytes , HttpRequest.responseData , HttpRequest.responseChars , HttpRequest.responseText (whichever is first found to have content). |
byte[] |
serverResponseData()
Return response content, resolved to binary from
HttpRequest.responseBytes , HttpRequest.responseData , HttpRequest.responseChars , HttpRequest.responseText (whichever is first found to have content). |
java.lang.String |
serverResponseText()
Return response content, resolved to string from
HttpRequest.responseBytes , HttpRequest.responseData , HttpRequest.responseChars , HttpRequest.responseText (whichever is first found to have content). |
void |
setActive(boolean value)
Set is a connection active (
HttpRequest.send was called, but HttpRequest.close has not yet been called)? |
void |
setBaseAddress(java.lang.String value)
Set base address (scheme + authority = protocol + endpoint) for data servlet executing the request, e.g.
|
void |
setBatchPartIndex(int value)
Set if
HttpRequest.isPartOfBatch is true, the part index within the batch (starting from 1). |
void |
setCompressRequest(boolean value)
Set set to
true before calling HttpRequest.send if the caller should compress the request content (using "gzip" encoding). |
void |
setCompressResponse(boolean value)
Set set to
false before calling HttpRequest.send if the server should compress the response content (using "gzip" encoding). |
void |
setContextPath(java.lang.String value)
Set context path for data servlet executing the request (e.g.
|
void |
setHandler(HttpHandler value)
Set the optional internal handler for this request.
|
void |
setInputStream(java.io.InputStream stream) |
void |
setMethod(java.lang.String value)
Set the HTTP method for this request.
|
void |
setPassword(java.lang.String value)
Set the password for this request.
|
void |
setRequestBytes(ByteStream value)
Set request data stream.
|
void |
setRequestChars(CharStream value)
Set request text stream.
|
void |
setRequestCookie(java.lang.String name,
java.lang.String value)
Set a request cookie.
|
void |
setRequestCookies(HttpCookies value)
Set HTTP request cookies.
|
void |
setRequestData(byte[] value)
Set request data for a non-streamed request.
|
void |
setRequestHeader(java.lang.String name,
java.lang.String value)
Set a request header.
|
void |
setRequestHeaders(HttpHeaders value)
Set HTTP request headers.
|
void |
setRequestOptions(RequestOptions value)
Set caller's request options.
|
void |
setRequestText(java.lang.String value)
Set request text for a non-streamed request.
|
void |
setResponseBytes(ByteStream value)
Set response data stream.
|
void |
setResponseChars(CharStream value)
Set response text stream.
|
void |
setResponseCookie(java.lang.String name,
java.lang.String value)
Set a response cookie.
|
void |
setResponseCookies(HttpCookies value)
Set HTTP response cookies.
|
void |
setResponseData(byte[] value)
Set response data for a non-streamed response.
|
void |
setResponseHeader(java.lang.String name,
java.lang.String value)
Set a response header.
|
void |
setResponseHeaders(HttpHeaders value)
Set HTTP response headers.
|
void |
setResponseText(java.lang.String value)
Set response text for a non-streamed response.
|
void |
setServerCanStreamResponse(boolean value)
Set can the response to this request possibly be streamed?
|
void |
setServletPath(java.lang.String value)
Set servlet path for data servlet executing the request (e.g.
|
void |
setServletRequest(javax.servlet.http.HttpServletRequest request) |
void |
setServletResponse(javax.servlet.http.HttpServletResponse response) |
void |
setStatus(int value)
Set HTTP response status code.
|
void |
setStatusText(java.lang.String value)
Set HTTP response status text.
|
void |
setStreamRequest(boolean value)
Set set to
false before calling HttpRequest.send if the caller does not wish to stream the request content. |
void |
setStreamResponse(boolean value)
Set set to
false before calling HttpRequest.send if the caller does not wish to stream the response content. |
void |
setTraceID(java.lang.String value)
Set process-local ID for this request (for tracing purposes).
|
void |
setUnzipResponse(boolean value)
Set does response need to be unzipped? Should be set by
HttpHandler subclasses. |
void |
setUrl(java.lang.String value)
Set the URL for this request.
|
void |
setUsername(java.lang.String value)
Set the username for this request.
|
void |
setVersion(int value)
Set the HTTP version for this request.
|
public javax.servlet.http.HttpServletRequest getServletRequest()
public javax.servlet.http.HttpServletResponse getServletResponse()
public void setServletRequest(javax.servlet.http.HttpServletRequest request)
public void setServletResponse(javax.servlet.http.HttpServletResponse response)
public void setInputStream(java.io.InputStream stream)
public void close()
Close this HTTP request, and any response stream that may have been opened by HttpRequest.send
.
If an application calls HttpRequest.send
, then it must also call this function to avoid resource leaks.
public void enableTrace(java.lang.String serviceName, boolean traceRequest, boolean traceHeaders, boolean traceContent, boolean prettyPrint)
Enable HTTP request tracing. Call this before calling HttpRequest.send
.
serviceName
- (nullable) Name of the service which this request will be sent to.traceRequest
- Trace the request (URL), and basic request/response flow. Note: this may result in tracing of sensitive data, such as URL query parameters.traceHeaders
- Trace the headers. Note: this may result in tracing of sensitive data, such as authentication information or cookie values.traceContent
- Trace the content. Note: this may result in tracing of sensitive data.prettyPrint
- If traceContent
is true
and HttpRequest.streamResponse
is false
, then content tracing of JSON or XML will be pretty-printed.public java.lang.String getBaseAddress()
Return base address (scheme + authority = protocol + endpoint) for data servlet executing the request, e.g. "http://myhost:80".
public int getBatchPartIndex()
Return if HttpRequest.isPartOfBatch
is true, the part index within the batch (starting from 1). Otherwise 0.
HttpRequest.isPartOfBatch
is true, the part index within the batch (starting from 1). Otherwise 0.public boolean getCompressRequest()
Return set to true
before calling HttpRequest.send
if the caller should compress the request content (using "gzip" encoding).
False by default.
true
before calling HttpRequest.send
if the caller should compress the request content (using "gzip" encoding).public boolean getCompressResponse()
Return set to false
before calling HttpRequest.send
if the server should compress the response content (using "gzip" encoding).
True by default.
false
before calling HttpRequest.send
if the server should compress the response content (using "gzip" encoding).public java.lang.String getContextPath()
Return context path for data servlet executing the request (e.g. "/myapp" or empty).
public java.lang.String getFullPathToServlet()
Return full path to servlet (omitting request path and query string).
This is a concatenation of HttpRequest.baseAddress
, HttpRequest.contextPath
, and HttpRequest.servletPath
.
public HttpHandler getHandler()
Return (nullable) The optional internal handler for this request.
public java.lang.String getMethod()
Return the HTTP method for this request. Set this using the HttpRequest.open
function.
HttpRequest.open
function.public java.lang.String getPassword()
Return (nullable) The password for this request. Set this using the HttpRequest.login
function.
HttpRequest.login
function.public boolean getPrettyPrint()
Return is this request enabled for pretty-printed tracing?
public ByteStream getRequestBytes()
Return (nullable) Request data stream. Set this before calling HttpRequest.send
.
HttpRequest.send
.public CharStream getRequestChars()
Return (nullable) Request text stream. Set this before calling HttpRequest.send
.
HttpRequest.send
.public java.lang.String getRequestCookie(java.lang.String name)
Get a request cookie value. For use by servers.
name
- Cookie name.public HttpCookies getRequestCookies()
Return HTTP request cookies. Set request cookies before calling HttpRequest.send
.
HttpRequest.send
.public byte[] getRequestData()
Return (nullable) Request data for a non-streamed request. Set this before calling HttpRequest.send
.
HttpRequest.send
.public java.lang.String getRequestHeader(java.lang.String name)
Get a request header value. For use by servers.
name
- Header name.public HttpHeaders getRequestHeaders()
Return HTTP request headers. Set request headers before calling HttpRequest.send
.
HttpRequest.send
.public RequestOptions getRequestOptions()
Return caller's request options.
public java.lang.String getRequestText()
Return (nullable) Request text for a non-streamed request. Set this before calling HttpRequest.send
.
HttpRequest.send
.public ByteStream getResponseBytes()
Return response data stream. Access this after calling HttpRequest.send
.
HttpRequest.send
.public CharStream getResponseChars()
Return response text stream. Access this after calling HttpRequest.send
.
HttpRequest.send
.public java.lang.String getResponseCookie(java.lang.String name)
Get a response cookie value. Call this after calling HttpRequest.send
.
name
- Cookie name.public HttpCookies getResponseCookies()
Return HTTP response cookies. Access response cookies after calling HttpRequest.send
.
HttpRequest.send
.public byte[] getResponseData()
Return response data for a non-streamed response. Access this after calling HttpRequest.send
.
HttpRequest.send
.public long getResponseDataCount()
Return response data counter. Counts received content data length in bytes.
public long getResponseGzipCount()
Return response gzip counter. Counts received content gzip length in bytes.
public java.lang.String getResponseHeader(java.lang.String name)
Get a response header value. Call this after calling HttpRequest.send
.
name
- Header name.public HttpHeaders getResponseHeaders()
Return HTTP response headers. Access response headers after calling HttpRequest.send
.
HttpRequest.send
.public java.lang.String getResponseText()
Return response text for a non-streamed response. Access this after calling HttpRequest.send
.
HttpRequest.send
.public boolean getServerCanStreamResponse()
Return can the response to this request possibly be streamed?
HttpRequest.streamResponse
, which indicates if the response will be streamed.
public java.lang.String getServletPath()
Return servlet path for data servlet executing the request (e.g. "/mypath" or empty).
public int getStatus()
Return HTTP response status code. Access this after calling HttpRequest.send
.
HttpRequest.send
.public java.lang.String getStatusText()
Return HTTP response status text. Access this after calling HttpRequest.send
.
HttpRequest.send
.public boolean getStreamRequest()
Return set to false
before calling HttpRequest.send
if the caller does not wish to stream the request content.
True by default.
false
before calling HttpRequest.send
if the caller does not wish to stream the request content.public boolean getStreamResponse()
Return set to false
before calling HttpRequest.send
if the caller does not wish to stream the response content.
True by default.
false
before calling HttpRequest.send
if the caller does not wish to stream the response content.public boolean getTraceContent()
Return is this request enabled for tracing of request/response content?
public boolean getTraceHeaders()
Return is this request enabled for tracing of request/response headers?
public java.lang.String getTraceID()
Return process-local ID for this request (for tracing purposes).
public boolean getTraceRequest()
Return is this request enabled for request/response tracing?
public boolean getUnzipResponse()
Return does response need to be unzipped? Should be set by HttpHandler
subclasses.
HttpHandler
subclasses.public java.lang.String getUrl()
Return the URL for this request. Set this using the HttpRequest.open
function.
HttpRequest.open
function.public java.lang.String getUsername()
Return (nullable) The username for this request. Set this using the HttpRequest.login
function.
HttpRequest.login
function.public int getVersion()
Return the HTTP version for this request. Defaults to HTTP 1.1.
public boolean hasResponseBytes()
Return does this request have a byte stream response already set?
public boolean hasResponseChars()
Return does this request have a text stream response already set?
public boolean hasResponseData()
Return does this request have a binary (data) response already set?
public boolean hasResponseText()
Return does this request have a string (text) response already set?
public boolean isActive()
Return is a connection active (HttpRequest.send
was called, but HttpRequest.close
has not yet been called)?
HttpRequest.send
was called, but HttpRequest.close
has not yet been called)?public boolean isPartOfBatch()
Return is this request part of a request batch?
public void login(java.lang.String username, java.lang.String password)
Specify the HTTP basic credentials. Call this before calling HttpRequest.send
if the server requires HTTP basic authentication.
username
- Username for HTTP basic authentication.password
- Password for HTTP basic authentication.public void open(java.lang.String method, java.lang.String url)
Specify the HTTP HttpRequest.method
and HttpRequest.url
. Call this before calling HttpRequest.send
.
method
- Value for HttpRequest.method
.url
- Value for HttpRequest.url
.public void send()
Send this HTTP request to the server, and wait for a response.
If HttpRequest.streamResponse
is true
, then waiting is only until response headers come back, and response content may be streamed as it is accessed.
If an application calls this function, then it must also call HttpRequest.close
after accessing all desired response content, to avoid resource leaks.
public ByteStream serverRequestBytes()
Return request content, resolved to ByteStream from HttpRequest.requestBytes
, HttpRequest.requestData
, HttpRequest.requestChars
, HttpRequest.requestText
(whichever is first found to have content).
HttpRequest.requestBytes
, HttpRequest.requestData
, HttpRequest.requestChars
, HttpRequest.requestText
(whichever is first found to have content).public CharStream serverRequestChars()
Return request content, resolved to CharStream from HttpRequest.requestBytes
, HttpRequest.requestData
, HttpRequest.requestChars
, HttpRequest.requestText
(whichever is first found to have content).
HttpRequest.requestBytes
, HttpRequest.requestData
, HttpRequest.requestChars
, HttpRequest.requestText
(whichever is first found to have content).public byte[] serverRequestData()
Return request content, resolved to binary from HttpRequest.requestBytes
, HttpRequest.requestData
, HttpRequest.requestChars
, HttpRequest.requestText
(whichever is first found to have content).
HttpRequest.requestBytes
, HttpRequest.requestData
, HttpRequest.requestChars
, HttpRequest.requestText
(whichever is first found to have content).public java.lang.String serverRequestText()
Return request content, resolved to string from HttpRequest.requestBytes
, HttpRequest.requestData
, HttpRequest.requestChars
, HttpRequest.requestText
(whichever is first found to have content).
HttpRequest.requestBytes
, HttpRequest.requestData
, HttpRequest.requestChars
, HttpRequest.requestText
(whichever is first found to have content).public ByteStream serverResponseBytes()
Return response content, resolved to ByteStream from HttpRequest.responseBytes
, HttpRequest.responseData
, HttpRequest.responseChars
, HttpRequest.responseText
(whichever is first found to have content).
HttpRequest.responseBytes
, HttpRequest.responseData
, HttpRequest.responseChars
, HttpRequest.responseText
(whichever is first found to have content).public CharStream serverResponseChars()
Return response content, resolved to CharStream from HttpRequest.responseBytes
, HttpRequest.responseData
, HttpRequest.responseChars
, HttpRequest.responseText
(whichever is first found to have content).
HttpRequest.responseBytes
, HttpRequest.responseData
, HttpRequest.responseChars
, HttpRequest.responseText
(whichever is first found to have content).public byte[] serverResponseData()
Return response content, resolved to binary from HttpRequest.responseBytes
, HttpRequest.responseData
, HttpRequest.responseChars
, HttpRequest.responseText
(whichever is first found to have content).
HttpRequest.responseBytes
, HttpRequest.responseData
, HttpRequest.responseChars
, HttpRequest.responseText
(whichever is first found to have content).public java.lang.String serverResponseText()
Return response content, resolved to string from HttpRequest.responseBytes
, HttpRequest.responseData
, HttpRequest.responseChars
, HttpRequest.responseText
(whichever is first found to have content).
HttpRequest.responseBytes
, HttpRequest.responseData
, HttpRequest.responseChars
, HttpRequest.responseText
(whichever is first found to have content).public void setActive(boolean value)
Set is a connection active (HttpRequest.send
was called, but HttpRequest.close
has not yet been called)?
value
- Is a connection active (HttpRequest.send
was called, but HttpRequest.close
has not yet been called)?public void setBaseAddress(java.lang.String value)
Set base address (scheme + authority = protocol + endpoint) for data servlet executing the request, e.g. "http://myhost:80".
value
- Base address (scheme + authority = protocol + endpoint) for data servlet executing the request, e.g. "http://myhost:80".public void setBatchPartIndex(int value)
Set if HttpRequest.isPartOfBatch
is true, the part index within the batch (starting from 1). Otherwise 0.
value
- If HttpRequest.isPartOfBatch
is true, the part index within the batch (starting from 1). Otherwise 0.public void setCompressRequest(boolean value)
Set set to true
before calling HttpRequest.send
if the caller should compress the request content (using "gzip" encoding).
False by default.
value
- Set to true
before calling HttpRequest.send
if the caller should compress the request content (using "gzip" encoding).public void setCompressResponse(boolean value)
Set set to false
before calling HttpRequest.send
if the server should compress the response content (using "gzip" encoding).
True by default.
value
- Set to false
before calling HttpRequest.send
if the server should compress the response content (using "gzip" encoding).public void setContextPath(java.lang.String value)
Set context path for data servlet executing the request (e.g. "/myapp" or empty).
value
- Context path for data servlet executing the request (e.g. "/myapp" or empty).public void setHandler(HttpHandler value)
Set the optional internal handler for this request.
value
- The optional internal handler for this request.public void setMethod(java.lang.String value)
Set the HTTP method for this request. Set this using the HttpRequest.open
function.
value
- The HTTP method for this request. Set this using the HttpRequest.open
function.public void setPassword(java.lang.String value)
Set the password for this request. Set this using the HttpRequest.login
function.
value
- The password for this request. Set this using the HttpRequest.login
function.public void setRequestBytes(ByteStream value)
Set request data stream. Set this before calling HttpRequest.send
.
value
- Request data stream. Set this before calling HttpRequest.send
.public void setRequestChars(CharStream value)
Set request text stream. Set this before calling HttpRequest.send
.
value
- Request text stream. Set this before calling HttpRequest.send
.public void setRequestCookie(java.lang.String name, java.lang.String value)
Set a request cookie. Call this before calling HttpRequest.send
.
name
- Cookie name.value
- Cookie value.public void setRequestCookies(HttpCookies value)
Set HTTP request cookies. Set request cookies before calling HttpRequest.send
.
value
- HTTP request cookies. Set request cookies before calling HttpRequest.send
.public void setRequestData(byte[] value)
Set request data for a non-streamed request. Set this before calling HttpRequest.send
.
value
- Request data for a non-streamed request. Set this before calling HttpRequest.send
.public void setRequestHeader(java.lang.String name, java.lang.String value)
Set a request header. Call this before calling HttpRequest.send
.
name
- Header name.value
- Header value.public void setRequestHeaders(HttpHeaders value)
Set HTTP request headers. Set request headers before calling HttpRequest.send
.
value
- HTTP request headers. Set request headers before calling HttpRequest.send
.public void setRequestOptions(RequestOptions value)
Set caller's request options.
value
- Caller's request options.public void setRequestText(java.lang.String value)
Set request text for a non-streamed request. Set this before calling HttpRequest.send
.
value
- Request text for a non-streamed request. Set this before calling HttpRequest.send
.public void setResponseBytes(ByteStream value)
Set response data stream. Access this after calling HttpRequest.send
.
value
- Response data stream. Access this after calling HttpRequest.send
.public void setResponseChars(CharStream value)
Set response text stream. Access this after calling HttpRequest.send
.
value
- Response text stream. Access this after calling HttpRequest.send
.public void setResponseCookie(java.lang.String name, java.lang.String value)
Set a response cookie. For use by servers.
name
- Cookie name.value
- Cookie value.public void setResponseCookies(HttpCookies value)
Set HTTP response cookies. Access response cookies after calling HttpRequest.send
.
value
- HTTP response cookies. Access response cookies after calling HttpRequest.send
.public void setResponseData(byte[] value)
Set response data for a non-streamed response. Access this after calling HttpRequest.send
.
value
- Response data for a non-streamed response. Access this after calling HttpRequest.send
.public void setResponseHeader(java.lang.String name, java.lang.String value)
Set a response header. For use by servers.
name
- Header name.value
- Header value.public void setResponseHeaders(HttpHeaders value)
Set HTTP response headers. Access response headers after calling HttpRequest.send
.
value
- HTTP response headers. Access response headers after calling HttpRequest.send
.public void setResponseText(java.lang.String value)
Set response text for a non-streamed response. Access this after calling HttpRequest.send
.
value
- Response text for a non-streamed response. Access this after calling HttpRequest.send
.public void setServerCanStreamResponse(boolean value)
Set can the response to this request possibly be streamed?
HttpRequest.streamResponse
, which indicates if the response will be streamed.
value
- Can the response to this request possibly be streamed?public void setServletPath(java.lang.String value)
Set servlet path for data servlet executing the request (e.g. "/mypath" or empty).
value
- Servlet path for data servlet executing the request (e.g. "/mypath" or empty).public void setStatus(int value)
Set HTTP response status code. Access this after calling HttpRequest.send
.
value
- HTTP response status code. Access this after calling HttpRequest.send
.public void setStatusText(java.lang.String value)
Set HTTP response status text. Access this after calling HttpRequest.send
.
value
- HTTP response status text. Access this after calling HttpRequest.send
.public void setStreamRequest(boolean value)
Set set to false
before calling HttpRequest.send
if the caller does not wish to stream the request content.
True by default.
value
- Set to false
before calling HttpRequest.send
if the caller does not wish to stream the request content.public void setStreamResponse(boolean value)
Set set to false
before calling HttpRequest.send
if the caller does not wish to stream the response content.
True by default.
value
- Set to false
before calling HttpRequest.send
if the caller does not wish to stream the response content.public void setTraceID(java.lang.String value)
Set process-local ID for this request (for tracing purposes).
value
- Process-local ID for this request (for tracing purposes).public void setUnzipResponse(boolean value)
Set does response need to be unzipped? Should be set by HttpHandler
subclasses.
value
- Does response need to be unzipped? Should be set by HttpHandler
subclasses.public void setUrl(java.lang.String value)
Set the URL for this request. Set this using the HttpRequest.open
function.
value
- The URL for this request. Set this using the HttpRequest.open
function.public void setUsername(java.lang.String value)
Set the username for this request. Set this using the HttpRequest.login
function.
value
- The username for this request. Set this using the HttpRequest.login
function.public void setVersion(int value)
Set the HTTP version for this request. Defaults to HTTP 1.1.
value
- The HTTP version for this request. Defaults to HTTP 1.1.