activemq-cpp-3.9.0
decaf::net::HttpURLConnection Class Referenceabstract

This abstract subclass of URLConnection defines methods for managing HTTP connection according to the description given by RFC 2068. More...

#include <src/main/decaf/net/HttpURLConnection.h>

Inheritance diagram for decaf::net::HttpURLConnection:

Public Member Functions

virtual ~HttpURLConnection ()
 
virtual void disconnect ()=0
 Closes the connection to the HTTP server. More...
 
virtual decaf::io::InputStreamgetErrorStream () const
 Returns an input stream from the server in the case of an error such as the requested file has not been found on the remote server. More...
 
std::string getRequestMethod () const
 Returns the request method which will be used to make the request to the remote HTTP server. More...
 
int getResponseCode ()
 Returns the response code returned by the remote HTTP server. More...
 
std::string getResponseMessage ()
 Returns the response message returned by the remote HTTP server. More...
 
void setRequestMethod (const std::string &method)
 Sets the request command which will be sent to the remote HTTP server. More...
 
bool getInstanceFollowRedirects () const
 Returns whether this connection follows redirects. More...
 
void setInstanceFollowRedirects (bool followRedirects)
 Sets whether this connection follows redirects. More...
 
void setFixedLengthStreamingMode (int contentLength)
 If the length of a HTTP request body is known ahead, sets fixed length to enable streaming without buffering. More...
 
void setChunkedStreamingMode (int chunklen)
 If the length of a HTTP request body is NOT known ahead, enable chunked transfer encoding to enable streaming with buffering. More...
 
- Public Member Functions inherited from decaf::net::URLConnection
virtual ~URLConnection ()
 
virtual void connect ()=0
 Establishes the connection to the earlier configured resource. More...
 
bool getAllowUserInteraction () const
 Gets the option value which indicates whether user interaction is allowed on this URLConnection. More...
 
void setAllowUserInteraction (bool newValue)
 Sets the flag indicating whether this connection allows user interaction or not. More...
 
std::string getContentEncoding () const
 Gets the content encoding type specified by the response header field content-encoding or empty string if this field is not set. More...
 
int getContentLength () const
 Gets the content length in bytes specified by the response header field 'content-length' or '-1' if this field is not set. More...
 
std::string getContentType () const
 Gets the MIME-type of the content specified by the response header field 'content-type' or empty string if type is unknown. More...
 
long long getDate () const
 Gets the timestamp when this response has been sent as a date in milliseconds since January 1, 1970 GMT or '0' if this timestamp is unknown. More...
 
bool getDefaultUseCaches () const
 Gets the default setting whether this connection allows using caches. More...
 
void setDefaultUseCaches (bool newValue)
 Sets the default value for the flag indicating whether this connection allows to use caches. More...
 
bool getDoInput () const
 Gets the value of the option. More...
 
void setDoInput (bool newValue)
 Sets the flag indicating whether this URLConnection allows input. More...
 
bool getDoOutput () const
 Gets the value of the option doOutput which specifies whether this connection allows to send data. More...
 
void setDoOutput (bool newValue)
 Sets the flag indicating whether this URLConnection allows output. More...
 
long getExpiration () const
 Gets the timestamp when this response will be expired in milliseconds since January 1, 1970 GMT or 0 if this timestamp is unknown. More...
 
URL getURL () const
 Gets the URL represented by this URLConnection. More...
 
bool getUseCaches () const
 Gets the value of the flag which specifies whether this URLConnection allows to use caches. More...
 
void setUseCaches (bool newValue)
 Sets the flag indicating whether this connection allows to use caches or not. More...
 
int getConnectTimeout () const
 Gets the configured connecting timeout. More...
 
void setConnectTimeout (int timeout)
 Sets the timeout value in milliseconds for establishing the connection to the resource pointed by this URLConnection instance. More...
 
int getReadTimeout () const
 Gets the configured timeout for reading from the input stream of an established connection to the resource. More...
 
void setReadTimeout (int timeout)
 Sets the timeout value in milliseconds for reading from the input stream of an established connection to the resource. More...
 
virtual std::string toString () const
 Returns the string representation containing the name of this class and the URL. More...
 
virtual std::string getHeaderField (int pos DECAF_UNUSED) const
 Gets the header value at the field position pos or empty string if the header has fewer than pos fields. More...
 
virtual std::string getHeaderField (const std::string &key DECAF_UNUSED) const
 Gets the value of the header field specified by key or empty string if there is no field with this name. More...
 
long long getHeaderFieldDate (const std::string &field, long long defaultValue) const
 Gets the specified header value as a date in milliseconds since January 1, 1970 GMT. More...
 
int getHeaderFieldInt (const std::string &field, int defaultValue) const
 Gets the specified header value as a number. More...
 
long long getLastModified () const
 Gets the value of the response header field 'last-modified' or zero if this value is not set. More...
 
virtual decaf::io::InputStreamgetInputStream ()
 Gets an InputStream for reading data from the resource pointed by this URLConnection. More...
 
virtual decaf::io::OutputStreamgetOutputStream ()
 Gets an OutputStream for writing data to this URLConnection. More...
 
long long getIfModifiedSince () const
 Gets the point of time since when the data must be modified to be transmitted. More...
 
void setIfModifiedSince (long long newValue)
 Sets the point of time since when the data must be modified to be transmitted. More...
 

Static Public Member Functions

static bool getFollowRedirects ()
 Returns the value of followRedirects which indicates if this connection follows a different URL redirected by the server. More...
 
static void setFollowRedirects (bool follow)
 Sets the flag of whether this connection will follow redirects returned by the remote server. More...
 
- Static Public Member Functions inherited from decaf::net::URLConnection
static bool getDefaultAllowUserInteraction ()
 Gets the default setting whether this connection allows user interaction. More...
 
static void setDefaultAllowUserInteraction (bool allows)
 Sets the default value for the flag indicating whether this connection allows user interaction or not. More...
 

Static Public Attributes

static const int HTTP_ACCEPTED
 Numeric status code, 202: Accepted. More...
 
static const int HTTP_BAD_GATEWAY
 Numeric status code, 502: Bad Gateway. More...
 
static const int HTTP_BAD_METHOD
 Numeric status code, 405: Bad Method. More...
 
static const int HTTP_BAD_REQUEST
 Numeric status code, 400: Bad Request. More...
 
static const int HTTP_CLIENT_TIMEOUT
 Numeric status code, 408: Client Timeout. More...
 
static const int HTTP_CONFLICT
 Numeric status code, 409: Conflict. More...
 
static const int HTTP_CREATED
 Numeric status code, 201: Created. More...
 
static const int HTTP_ENTITY_TOO_LARGE
 Numeric status code, 413: Entity too large. More...
 
static const int HTTP_FORBIDDEN
 Numeric status code, 403: Forbidden. More...
 
static const int HTTP_GATEWAY_TIMEOUT
 Numeric status code, 504: Gateway timeout. More...
 
static const int HTTP_GONE
 Numeric status code, 410: Gone. More...
 
static const int HTTP_INTERNAL_ERROR
 Numeric status code, 500: Internal error. More...
 
static const int HTTP_LENGTH_REQUIRED
 Numeric status code, 411: Length required. More...
 
static const int HTTP_MOVED_PERM
 Numeric status code, 301 Moved permanently. More...
 
static const int HTTP_MOVED_TEMP
 Numeric status code, 302: Moved temporarily. More...
 
static const int HTTP_MULT_CHOICE
 Numeric status code, 300: Multiple choices. More...
 
static const int HTTP_NO_CONTENT
 Numeric status code, 204: No content. More...
 
static const int HTTP_NOT_ACCEPTABLE
 Numeric status code, 406: Not acceptable. More...
 
static const int HTTP_NOT_AUTHORITATIVE
 Numeric status code, 203: Not authoritative. More...
 
static const int HTTP_NOT_FOUND
 Numeric status code, 404: Not found. More...
 
static const int HTTP_NOT_IMPLEMENTED
 Numeric status code, 501: Not implemented. More...
 
static const int HTTP_NOT_MODIFIED
 Numeric status code, 304: Not modified. More...
 
static const int HTTP_OK
 Numeric status code, 200: OK. More...
 
static const int HTTP_PARTIAL
 Numeric status code, 206: Partial. More...
 
static const int HTTP_PAYMENT_REQUIRED
 Numeric status code, 402: Payment required. More...
 
static const int HTTP_PRECON_FAILED
 Numeric status code, 412: Precondition failed. More...
 
static const int HTTP_PROXY_AUTH
 Numeric status code, 407: Proxy authentication required. More...
 
static const int HTTP_REQ_TOO_LONG
 Numeric status code, 414: Request too long. More...
 
static const int HTTP_RESET
 Numeric status code, 205: Reset. More...
 
static const int HTTP_SEE_OTHER
 Numeric status code, 303: See other. More...
 
static const int HTTP_USE_PROXY
 Numeric status code, 305: Use proxy. More...
 
static const int HTTP_UNAUTHORIZED
 Numeric status code, 401: Unauthorized. More...
 
static const int HTTP_UNSUPPORTED_TYPE
 Numeric status code, 415: Unsupported type. More...
 
static const int HTTP_UNAVAILABLE
 Numeric status code, 503: Unavailable. More...
 
static const int HTTP_VERSION
 Numeric status code, 505: Version not supported. More...
 

Protected Member Functions

 HttpURLConnection (const URL &url)
 
- Protected Member Functions inherited from decaf::net::URLConnection
 URLConnection (const URL &url)
 

Protected Attributes

std::string method
 The HTTP request method of this HttpURLConnection. More...
 
int responseCode
 The status code of the response obtained from the HTTP request. More...
 
std::string responseMessage
 The HTTP response message which corresponds to the response code. More...
 
bool instanceFollowRedirects
 Flag to define whether the protocol will automatically follow redirects or not. More...
 
int chunkLength
 If the HTTP chunked encoding is enabled this parameter defines the chunk-length. More...
 
int fixedContentLength
 If using HTTP fixed-length streaming mode this parameter defines the fixed length of content. More...
 
- Protected Attributes inherited from decaf::net::URLConnection
URL url
 
long long ifModifiedSince
 The data must be modified more recently than this time in milliseconds since January 1, 1970, GMT to be transmitted. More...
 
bool useCaches
 Specifies whether the using of caches is enabled or the data has to be recent for every request. More...
 
bool connected
 Specifies whether this. More...
 
bool doOutput
 Specifies whether this. More...
 
bool doInput
 Specifies whether this. More...
 
bool allowUserInteraction
 Specifies whether this. More...
 

Detailed Description

This abstract subclass of URLConnection defines methods for managing HTTP connection according to the description given by RFC 2068.

See also
ContentHandler
URL
URLConnection
URLStreamHandler
Since
1.0

Constructor & Destructor Documentation

decaf::net::HttpURLConnection::HttpURLConnection ( const URL url)
protected
virtual decaf::net::HttpURLConnection::~HttpURLConnection ( )
virtual

Member Function Documentation

virtual void decaf::net::HttpURLConnection::disconnect ( )
pure virtual

Closes the connection to the HTTP server.

See also
URLConnection::connect()
URLConnection::connected
virtual decaf::io::InputStream* decaf::net::HttpURLConnection::getErrorStream ( ) const
inlinevirtual

Returns an input stream from the server in the case of an error such as the requested file has not been found on the remote server.

This stream can be used to read the data the server will send back.

Returns
the error input stream returned by the server.

References NULL.

static bool decaf::net::HttpURLConnection::getFollowRedirects ( )
inlinestatic

Returns the value of followRedirects which indicates if this connection follows a different URL redirected by the server.

It is enabled by default.

Returns
the value of the flag.
bool decaf::net::HttpURLConnection::getInstanceFollowRedirects ( ) const
inline

Returns whether this connection follows redirects.

Returns
if this connection follows redirects, false otherwise.
std::string decaf::net::HttpURLConnection::getRequestMethod ( ) const
inline

Returns the request method which will be used to make the request to the remote HTTP server.

All possible methods of this HTTP implementation is listed in the class definition.

Returns
the request method string.
int decaf::net::HttpURLConnection::getResponseCode ( )

Returns the response code returned by the remote HTTP server.

Returns
the response code, -1 if no valid response code.
Exceptions
IOExceptionif there is an IO error during the retrieval.
std::string decaf::net::HttpURLConnection::getResponseMessage ( )

Returns the response message returned by the remote HTTP server.

Returns
the response message. empty string if no such response exists.
Exceptions
IOExceptionif there is an error during the retrieval.
void decaf::net::HttpURLConnection::setChunkedStreamingMode ( int  chunklen)

If the length of a HTTP request body is NOT known ahead, enable chunked transfer encoding to enable streaming with buffering.

Notice that not all http servers support this mode. Sets after connection will cause an exception.

Parameters
chunklenthe length of a chunk.
Exceptions
IllegalStateExceptionif already connected or an other mode already set.
void decaf::net::HttpURLConnection::setFixedLengthStreamingMode ( int  contentLength)

If the length of a HTTP request body is known ahead, sets fixed length to enable streaming without buffering.

Sets after connection will cause an exception.

Parameters
contentLengththe fixed length of the HTTP request body.
Exceptions
IllegalStateExceptionif already connected or an other mode already set.
IllegalArgumentExceptionif contentLength is less than zero.
static void decaf::net::HttpURLConnection::setFollowRedirects ( bool  follow)
inlinestatic

Sets the flag of whether this connection will follow redirects returned by the remote server.

Parameters
followthe value to enable or disable this option.
void decaf::net::HttpURLConnection::setInstanceFollowRedirects ( bool  followRedirects)
inline

Sets whether this connection follows redirects.

Parameters
followRedirectsif this connection will follows redirects, false otherwise.
void decaf::net::HttpURLConnection::setRequestMethod ( const std::string &  method)

Sets the request command which will be sent to the remote HTTP server.

This method can only be called before the connection is made.

Parameters
methodthe string representing the method to be used.
Exceptions
ProtocolExceptionif this is called after connected, or the method is not supported by this HTTP implementation.

Field Documentation

int decaf::net::HttpURLConnection::chunkLength
protected

If the HTTP chunked encoding is enabled this parameter defines the chunk-length.

Default value is

-1

that means the chunked encoding mode is disabled.

int decaf::net::HttpURLConnection::fixedContentLength
protected

If using HTTP fixed-length streaming mode this parameter defines the fixed length of content.

Default value is

-1

that means the fixed-length streaming mode is disabled.

const int decaf::net::HttpURLConnection::HTTP_ACCEPTED
static

Numeric status code, 202: Accepted.

const int decaf::net::HttpURLConnection::HTTP_BAD_GATEWAY
static

Numeric status code, 502: Bad Gateway.

const int decaf::net::HttpURLConnection::HTTP_BAD_METHOD
static

Numeric status code, 405: Bad Method.

const int decaf::net::HttpURLConnection::HTTP_BAD_REQUEST
static

Numeric status code, 400: Bad Request.

const int decaf::net::HttpURLConnection::HTTP_CLIENT_TIMEOUT
static

Numeric status code, 408: Client Timeout.

const int decaf::net::HttpURLConnection::HTTP_CONFLICT
static

Numeric status code, 409: Conflict.

const int decaf::net::HttpURLConnection::HTTP_CREATED
static

Numeric status code, 201: Created.

const int decaf::net::HttpURLConnection::HTTP_ENTITY_TOO_LARGE
static

Numeric status code, 413: Entity too large.

const int decaf::net::HttpURLConnection::HTTP_FORBIDDEN
static

Numeric status code, 403: Forbidden.

const int decaf::net::HttpURLConnection::HTTP_GATEWAY_TIMEOUT
static

Numeric status code, 504: Gateway timeout.

const int decaf::net::HttpURLConnection::HTTP_GONE
static

Numeric status code, 410: Gone.

const int decaf::net::HttpURLConnection::HTTP_INTERNAL_ERROR
static

Numeric status code, 500: Internal error.

const int decaf::net::HttpURLConnection::HTTP_LENGTH_REQUIRED
static

Numeric status code, 411: Length required.

const int decaf::net::HttpURLConnection::HTTP_MOVED_PERM
static

Numeric status code, 301 Moved permanently.

const int decaf::net::HttpURLConnection::HTTP_MOVED_TEMP
static

Numeric status code, 302: Moved temporarily.

const int decaf::net::HttpURLConnection::HTTP_MULT_CHOICE
static

Numeric status code, 300: Multiple choices.

const int decaf::net::HttpURLConnection::HTTP_NO_CONTENT
static

Numeric status code, 204: No content.

const int decaf::net::HttpURLConnection::HTTP_NOT_ACCEPTABLE
static

Numeric status code, 406: Not acceptable.

const int decaf::net::HttpURLConnection::HTTP_NOT_AUTHORITATIVE
static

Numeric status code, 203: Not authoritative.

const int decaf::net::HttpURLConnection::HTTP_NOT_FOUND
static

Numeric status code, 404: Not found.

const int decaf::net::HttpURLConnection::HTTP_NOT_IMPLEMENTED
static

Numeric status code, 501: Not implemented.

const int decaf::net::HttpURLConnection::HTTP_NOT_MODIFIED
static

Numeric status code, 304: Not modified.

const int decaf::net::HttpURLConnection::HTTP_OK
static

Numeric status code, 200: OK.

const int decaf::net::HttpURLConnection::HTTP_PARTIAL
static

Numeric status code, 206: Partial.

const int decaf::net::HttpURLConnection::HTTP_PAYMENT_REQUIRED
static

Numeric status code, 402: Payment required.

const int decaf::net::HttpURLConnection::HTTP_PRECON_FAILED
static

Numeric status code, 412: Precondition failed.

const int decaf::net::HttpURLConnection::HTTP_PROXY_AUTH
static

Numeric status code, 407: Proxy authentication required.

const int decaf::net::HttpURLConnection::HTTP_REQ_TOO_LONG
static

Numeric status code, 414: Request too long.

const int decaf::net::HttpURLConnection::HTTP_RESET
static

Numeric status code, 205: Reset.

const int decaf::net::HttpURLConnection::HTTP_SEE_OTHER
static

Numeric status code, 303: See other.

const int decaf::net::HttpURLConnection::HTTP_UNAUTHORIZED
static

Numeric status code, 401: Unauthorized.

const int decaf::net::HttpURLConnection::HTTP_UNAVAILABLE
static

Numeric status code, 503: Unavailable.

const int decaf::net::HttpURLConnection::HTTP_UNSUPPORTED_TYPE
static

Numeric status code, 415: Unsupported type.

const int decaf::net::HttpURLConnection::HTTP_USE_PROXY
static

Numeric status code, 305: Use proxy.

const int decaf::net::HttpURLConnection::HTTP_VERSION
static

Numeric status code, 505: Version not supported.

bool decaf::net::HttpURLConnection::instanceFollowRedirects
protected

Flag to define whether the protocol will automatically follow redirects or not.

The default value is

true

.

std::string decaf::net::HttpURLConnection::method
protected

The HTTP request method of this HttpURLConnection.

The default value is "GET".

int decaf::net::HttpURLConnection::responseCode
protected

The status code of the response obtained from the HTTP request.

The default value is

-1

.

1xx: Informational 2xx: Success 3xx: Relocation/Redirection 4xx: Client Error 5xx: Server Error

std::string decaf::net::HttpURLConnection::responseMessage
protected

The HTTP response message which corresponds to the response code.


The documentation for this class was generated from the following file: