OpenAPI 1.0

com.aquafold.openapi.net
Interface AQWebRequest


public interface AQWebRequest

The AQWebRequest interface implements an HTTP method. The following methods are supported as of this release:

The request represented by an AQWebRequest can be sent to an HTTP server via an AQWebClient which would read response data from the HTTP server and then return it to application as an AQWebResponse object.

Field-value pairs can be added to an AQWebRequest by invocation of addParameter(String name, String value) or addParameter(String name, String[] values). For get requests, field-value pairs are encoded as UTF-8 characters and appended to the URL as the query string. For post requests, field-value pairs are sent to server along with the request body.

The request represented by an AQWebRequest can be sent to an HTTP server by invoking one of these methods:

Please see AQWebClient for example of creating an instance of an AQWebClient.

Once a request is successfully processed, a response object is returned to the caller. Various information can be retrieved from the response object, please see AQWebResponse for more information.

An instance of the object that implements the AQWebRequest interface can be instantiated via AQWebClient.newWebRequest(String url).


Method Summary
 void addParameter(String name, String value)
          Adds a field-value pair to this object.
 void addParameter(String name, String[] values)
          Adds a field with multiple values to this object, duplicated values are ignored.
 void addRequestHeader(String headerName, String headerValue)
          Adds the specified request header, not overwriting any previous value.
 void addUpload(String filename, byte[] source, String contentType, String charset)
          Adds the array of bytes to be uploaded to remote server to this object.
 void addUpload(String filename, String sourceFile, String contentType, String charset)
          Adds the array of bytes to be uploaded to remote server to this object.
 void clearUploads()
          Removes all of uploads that were added to this request using addUpload(String filename, String sourceFile, String contentType, String charset) and addUpload(String filename, byte[] source, String contentType, String charset).
 String getAcceptCharsetHeader()
          Returns the value of the Accept-Charset request header.
 String getAcceptEncodingHeader()
          Returns the value of the Accept-Encoding request header.
 String getAcceptHeader()
          Returns the value of the Accept request header.
 String getAcceptLanguageHeader()
          Returns the value of the Accept-Language request header.
 String getAllowHeader()
          Returns the value of the Allow entity header.
 String getAuthorizationHeader()
          Returns the value of the Authorization request header.
 String getCacheControlHeader()
          Returns the value of the Cache-Control general header.
 String getConnectionHeader()
          Returns the value of the Connection general header.
 String getContentEncodingHeader()
          Returns the value of the Content-Encoding entity header.
 String getContentLanguageHeader()
          Returns the value of the Content-Language entity header.
 int getContentLengthHeader()
          Returns the value of the Content-Length entity header.
 String getContentLocationHeader()
          Returns the value of the Content-Location entity header.
 String getContentMD5Header()
          Returns the value of the Content-MD5 entity header.
 String getContentRangeHeader()
          Returns the value of the Content-Range entity header.
 String getContentTypeHeader()
          Returns the value of the Content-Type entity header.
 String getDateHeader()
          Returns the value of the Date general header.
 String getExpectHeader()
          Returns the value of the Expect request header.
 String getExpiresHeader()
          Returns the value of the Expires entity header.
 String getFromHeader()
          Returns the value of the From request header.
 String getHeaderField(String name)
          Returns the header value associated with the given header name.
 List<String> getHeaderFields(String name)
          Returns the header values associated with the given header name.
 Map<String,List<String>> getHeaderMap()
          Returns all of headers this request currently has.
 String getHostHeader()
          Returns the value of the Host request header.
 String getIfMatchHeader()
          Returns the value of the If-Match request header.
 String getIfModifiedSinceHeader()
          Returns the value of the If-Modified-Since request header.
 String getIfNoneMatchHeader()
          Returns the value of the If-None-Match request header.
 String getIfRangeHeader()
          Returns the value of the If-Range request header.
 String getIfUnmodifiedSinceHeader()
          Returns the value of the If-Unmodified-Since request header.
 String getLastModifiedHeader()
          Returns the value of the Last-Modified entity header.
 String getMaxForwardsHeader()
          Returns the value of the Max-Forwards request header.
 String getPragmaHeader()
          Returns the value of the Pragma general header.
 String getProxyAuthorizationHeader()
          Returns the value of the Proxy-Authorization request header.
 String getRangeHeader()
          Returns the value of the Range request header.
 String getRefererHeader()
          Returns the value of the Referer request header.
 String getTEHeader()
          Returns the value of the TE request header.
 String getTrailerHeader()
          Returns the value of the Trailer general header.
 String getTransferEncodingHeader()
          Returns the value of the Transfer-Encoding general header.
 String getUpgradeHeader()
          Returns the value of the Upgrade general header.
 String getURL()
          Returns the URL string to which this request to be sent.
 String getUserAgentHeader()
          Returns the value of the User-Agent request header.
 String getViaHeader()
          Returns the value of the Via general header.
 String getWarningHeader()
          Returns the value of the Warning general header.
 void removeParameter(String name)
          Removes a field with all values from this request.
 void removeRequestHeader(String headerName)
          Remove the request header associated with the given name.
 void setUserAgentHeader(String headerValue)
          Sets the value of the User-Agent request header.
 String toString()
          Returns a string representation of this object.
 

Method Detail

addParameter

void addParameter(String name,
                  String value)
                  throws Exception
Adds a field-value pair to this object. Note that field-value pairs with the same field name are allowed, however, duplicated field-value pairs are ignored.

Parameters:
name - the name of the field
value - the value of the field
Throws:
Exception - if name or value is a null object, or name containing spaces only

addParameter

void addParameter(String name,
                  String[] values)
                  throws Exception
Adds a field with multiple values to this object, duplicated values are ignored.

Parameters:
name - the name of the field
values - the list of values
Throws:
Exception

removeParameter

void removeParameter(String name)
Removes a field with all values from this request.

Parameters:
name - the name of the field

addUpload

void addUpload(String filename,
               String sourceFile,
               String contentType,
               String charset)
               throws Exception
Adds the array of bytes to be uploaded to remote server to this object.

Parameters:
filename - the filename to use for the uploaded file
sourceFile - the file to upload
contentType - the content type for the file to upload; defaults to application/octet-stream if null
charset - the charset encoding for the file to upload; defaults to ISO-8859-1 if null
Throws:
Exception

addUpload

void addUpload(String filename,
               byte[] source,
               String contentType,
               String charset)
               throws Exception
Adds the array of bytes to be uploaded to remote server to this object.

Parameters:
filename - the filename to use for the uploaded content
source - the content to upload
contentType - the content type for the source to upload; defaults to application/octet-stream if null
charset - the charset encoding for the source to upload; defaults to ISO-8859-1 if null
Throws:
Exception

clearUploads

void clearUploads()
Removes all of uploads that were added to this request using addUpload(String filename, String sourceFile, String contentType, String charset) and addUpload(String filename, byte[] source, String contentType, String charset).


getURL

String getURL()
Returns the URL string to which this request to be sent.

Returns:
the URL string to which this request to be sent.

addRequestHeader

void addRequestHeader(String headerName,
                      String headerValue)
Adds the specified request header, not overwriting any previous value. Note that header-name matching is case insensitive.

Parameters:
headerName - the header's name
headerValue - the header's value

removeRequestHeader

void removeRequestHeader(String headerName)
Remove the request header associated with the given name. Note that header-name matching is case insensitive.

Parameters:
headerName - the header's name

getHeaderMap

Map<String,List<String>> getHeaderMap()
Returns all of headers this request currently has. The key of the map entry is the header name and corresponding entry value is a list of possible header values.

Returns:
a map containing all of request headers

getHeaderFields

List<String> getHeaderFields(String name)
Returns the header values associated with the given header name.

Parameters:
name - the name of the header
Returns:
a list of zero or more values

getHeaderField

String getHeaderField(String name)
Returns the header value associated with the given header name. If multiple values are found, only the last value is returned.

Parameters:
name - the name of the header
Returns:
the header value or null if header name is not defined

getCacheControlHeader

String getCacheControlHeader()
Returns the value of the Cache-Control general header.

Returns:
the header value or null if the Cache-Control header is not defined

getConnectionHeader

String getConnectionHeader()
Returns the value of the Connection general header.

Returns:
the header value or null if the Connection header is not defined

getDateHeader

String getDateHeader()
Returns the value of the Date general header.

Returns:
the header value or null if the Date header is not defined

getPragmaHeader

String getPragmaHeader()
Returns the value of the Pragma general header.

Returns:
the header value or null if the Pragma header is not defined

getTrailerHeader

String getTrailerHeader()
Returns the value of the Trailer general header.

Returns:
the header value or null if the Trailer header is not defined

getTransferEncodingHeader

String getTransferEncodingHeader()
Returns the value of the Transfer-Encoding general header.

Returns:
the header value or null if the Transfer-Encoding header is not defined

getUpgradeHeader

String getUpgradeHeader()
Returns the value of the Upgrade general header.

Returns:
the header value or null if the Upgrade header is not defined

getViaHeader

String getViaHeader()
Returns the value of the Via general header.

Returns:
the header value or null if the Via header is not defined

getWarningHeader

String getWarningHeader()
Returns the value of the Warning general header.

Returns:
the header value or null if the Warning header is not defined

getAllowHeader

String getAllowHeader()
Returns the value of the Allow entity header.

Returns:
the header value or null if the Allow header is not defined

getContentEncodingHeader

String getContentEncodingHeader()
Returns the value of the Content-Encoding entity header.

Returns:
the header value or null if the Content-Encoding header is not defined

getContentLanguageHeader

String getContentLanguageHeader()
Returns the value of the Content-Language entity header.

Returns:
the header value or null if the Content-Language header is not defined

getContentLengthHeader

int getContentLengthHeader()
Returns the value of the Content-Length entity header.

Returns:
the header value or null if the Content-Length header is not defined

getContentLocationHeader

String getContentLocationHeader()
Returns the value of the Content-Location entity header.

Returns:
the header value or null if the Content-Location header is not defined

getContentMD5Header

String getContentMD5Header()
Returns the value of the Content-MD5 entity header.

Returns:
the header value or null if the Content-MD5 header is not defined

getContentRangeHeader

String getContentRangeHeader()
Returns the value of the Content-Range entity header.

Returns:
the header value or null if the Content-Range header is not defined

getContentTypeHeader

String getContentTypeHeader()
Returns the value of the Content-Type entity header.

Returns:
the header value or null if the Content-Type header is not defined

getExpiresHeader

String getExpiresHeader()
Returns the value of the Expires entity header.

Returns:
the header value or null if the Expires header is not defined

getLastModifiedHeader

String getLastModifiedHeader()
Returns the value of the Last-Modified entity header.

Returns:
the header value or null if the Last-Modified header is not defined

getAcceptHeader

String getAcceptHeader()
Returns the value of the Accept request header.

Returns:
the header value or null if the Accept header is not defined

getAcceptCharsetHeader

String getAcceptCharsetHeader()
Returns the value of the Accept-Charset request header.

Returns:
the header value or null if the Accept-Charset header is not defined

getAcceptEncodingHeader

String getAcceptEncodingHeader()
Returns the value of the Accept-Encoding request header.

Returns:
the header value or null if the Accept-Encoding header is not defined

getAcceptLanguageHeader

String getAcceptLanguageHeader()
Returns the value of the Accept-Language request header.

Returns:
the header value or null if the Accept-Language header is not defined

getAuthorizationHeader

String getAuthorizationHeader()
Returns the value of the Authorization request header.

Returns:
the header value or null if the Authorization header is not defined

getExpectHeader

String getExpectHeader()
Returns the value of the Expect request header.

Returns:
the header value or null if the Expect header is not defined

getFromHeader

String getFromHeader()
Returns the value of the From request header.

Returns:
the header value or null if the From header is not defined

getHostHeader

String getHostHeader()
Returns the value of the Host request header.

Returns:
the header value or null if the Host header is not defined

getIfMatchHeader

String getIfMatchHeader()
Returns the value of the If-Match request header.

Returns:
the header value or null if the If-Match header is not defined

getIfModifiedSinceHeader

String getIfModifiedSinceHeader()
Returns the value of the If-Modified-Since request header.

Returns:
the header value or null if the If-Modified-Since header is not defined

getIfNoneMatchHeader

String getIfNoneMatchHeader()
Returns the value of the If-None-Match request header.

Returns:
the header value or null if the If-None-Match header is not defined

getIfRangeHeader

String getIfRangeHeader()
Returns the value of the If-Range request header.

Returns:
the header value or null if the If-Range header is not defined

getIfUnmodifiedSinceHeader

String getIfUnmodifiedSinceHeader()
Returns the value of the If-Unmodified-Since request header.

Returns:
the header value or null if the If-Unmodified-Since header is not defined

getMaxForwardsHeader

String getMaxForwardsHeader()
Returns the value of the Max-Forwards request header.

Returns:
the header value or null if the Max-Forwards header is not defined

getProxyAuthorizationHeader

String getProxyAuthorizationHeader()
Returns the value of the Proxy-Authorization request header.

Returns:
the header value or null if the Proxy-Authorization header is not defined

getRangeHeader

String getRangeHeader()
Returns the value of the Range request header.

Returns:
the header value or null if the Range header is not defined

getRefererHeader

String getRefererHeader()
Returns the value of the Referer request header.

Returns:
the header value or null if the Referer header is not defined

getTEHeader

String getTEHeader()
Returns the value of the TE request header.

Returns:
the header value or null if the TE header is not defined

getUserAgentHeader

String getUserAgentHeader()
Returns the value of the User-Agent request header.

Returns:
the header value or null if the User-Agent header is not defined

setUserAgentHeader

void setUserAgentHeader(String headerValue)
Sets the value of the User-Agent request header.

Parameters:
headerValue - the header's value

toString

String toString()
Returns a string representation of this object.

Overrides:
toString in class Object
Returns:
a string representation of this object

OpenAPI 1.0


Copyright © 2010 AquaFold, Inc. All Rights Reserved. Use is subject to license terms.