Ark Server API (ASE) - Wiki
|
#include <HTTPSession.h>
Public Types | |
enum | { HTTP_PORT = 80 } |
Public Member Functions | |
void | setKeepAlive (bool keepAlive) |
bool | getKeepAlive () const |
void | setTimeout (const Poco::Timespan &timeout) |
void | setTimeout (const Poco::Timespan &connectionTimeout, const Poco::Timespan &sendTimeout, const Poco::Timespan &receiveTimeout) |
Sets the timeout for the HTTP session. | |
Poco::Timespan | getTimeout () const |
Sets different timeouts for the HTTP session. | |
bool | connected () const |
Returns the timeout for the HTTP session. | |
virtual void | abort () |
Returns true if the underlying socket is connected. | |
const Poco::Exception * | networkException () const |
void | attachSessionData (const Poco::Any &data) |
const Poco::Any & | sessionData () const |
StreamSocket | detachSocket () |
StreamSocket & | socket () |
void | drainBuffer (Poco::Buffer< char > &buffer) |
Returns a reference to the underlying socket. | |
Protected Member Functions | |
HTTPSession () | |
HTTPSession (const StreamSocket &socket) | |
HTTPSession (const StreamSocket &socket, bool keepAlive) | |
virtual | ~HTTPSession () |
int | get () |
int | peek () |
virtual int | read (char *buffer, std::streamsize length) |
virtual int | write (const char *buffer, std::streamsize length) |
int | receive (char *buffer, int length) |
Writes data to the socket. | |
int | buffered () const |
Reads up to length bytes. | |
void | refill () |
Returns the number of bytes in the buffer. | |
virtual void | connect (const SocketAddress &address) |
Refills the internal buffer. | |
void | attachSocket (const StreamSocket &socket) |
void | close () |
void | setException (const Poco::Exception &exc) |
Closes the underlying socket. | |
void | clearException () |
Stores a clone of the exception. | |
Private Types | |
enum | { HTTP_DEFAULT_TIMEOUT = 60000000 , HTTP_DEFAULT_CONNECTION_TIMEOUT = 30000000 } |
Clears the stored exception. More... | |
Private Member Functions | |
HTTPSession (const HTTPSession &) | |
HTTPSession & | operator= (const HTTPSession &) |
Private Attributes | |
StreamSocket | _socket |
char * | _pBuffer |
char * | _pCurrent |
char * | _pEnd |
bool | _keepAlive |
Poco::Timespan | _connectionTimeout |
Poco::Timespan | _receiveTimeout |
Poco::Timespan | _sendTimeout |
Poco::Exception * | _pException |
Poco::Any | _data |
Friends | |
class | HTTPStreamBuf |
class | HTTPHeaderStreamBuf |
class | HTTPFixedLengthStreamBuf |
class | HTTPChunkedStreamBuf |
HTTPSession implements basic HTTP session management for both HTTP clients and HTTP servers.
HTTPSession implements buffering for HTTP connections, as well as specific support for the various HTTP stream classes.
This class can not be instantiated. HTTPClientSession or HTTPServerSession must be used instead.
Definition at line 34 of file HTTPSession.h.
anonymous enum |
Returns the data attached with attachSessionData(), or an empty Poco::Any if no user data has been attached.
Enumerator | |
---|---|
HTTP_PORT |
Definition at line 92 of file HTTPSession.h.
|
private |
Clears the stored exception.
Enumerator | |
---|---|
HTTP_DEFAULT_TIMEOUT | |
HTTP_DEFAULT_CONNECTION_TIMEOUT |
Definition at line 182 of file HTTPSession.h.
|
protected |
Copies all bytes remaining in the internal buffer to the given Poco::Buffer, resizing it as necessary.
This is usually used together with detachSocket() to obtain any data already read from the socket, but not yet processed.
|
protected |
Creates a HTTP session using an unconnected stream socket.
|
protected |
Creates a HTTP session using the given socket. The session takes ownership of the socket and closes it when it's no longer used.
|
protectedvirtual |
Creates a HTTP session using the given socket. The session takes ownership of the socket and closes it when it's no longer used.
|
private |
|
virtual |
Returns true if the underlying socket is connected.
Reimplemented in Poco::Net::HTTPSClientSession.
void Poco::Net::HTTPSession::attachSessionData | ( | const Poco::Any & | data | ) |
If sending or receiving data over the underlying socket connection resulted in an exception, a pointer to this exception is returned.
Otherwise, NULL is returned.
|
protected |
Connects the underlying socket to the given address and sets the socket's receive timeout.
|
inlineprotected |
Reads up to length bytes.
Definition at line 236 of file HTTPSession.h.
|
protected |
Stores a clone of the exception.
|
protected |
Attaches a socket to the session, replacing the previously attached socket.
|
protectedvirtual |
Refills the internal buffer.
Reimplemented in Poco::Net::HTTPSClientSession.
bool Poco::Net::HTTPSession::connected | ( | ) | const |
Returns the timeout for the HTTP session.
StreamSocket Poco::Net::HTTPSession::detachSocket | ( | ) |
void Poco::Net::HTTPSession::drainBuffer | ( | Poco::Buffer< char > & | buffer | ) |
Returns a reference to the underlying socket.
|
protected |
Destroys the HTTPSession and closes the underlying socket.
|
inline |
Sets the keep-alive flag for this session.
If the keep-alive flag is enabled, persistent HTTP/1.1 connections are supported.
Definition at line 212 of file HTTPSession.h.
|
inline |
Sets different timeouts for the HTTP session.
Definition at line 218 of file HTTPSession.h.
|
inline |
Aborts a session in progress by shutting down and closing the underlying socket.
Definition at line 230 of file HTTPSession.h.
|
private |
|
protected |
Returns the next byte in the buffer. Reads more data from the socket if there are no bytes left in the buffer.
|
protectedvirtual |
Peeks at the next character in the buffer. Reads more data from the socket if there are no bytes left in the buffer.
Reimplemented in Poco::Net::HTTPSClientSession.
|
protected |
Writes data to the socket.
|
protected |
Returns the number of bytes in the buffer.
|
inline |
Allows to attach an application-specific data item to the session.
On the server side, this can be used to manage data that must be maintained over the entire lifetime of a persistent connection (that is, multiple requests sent over the same connection).
Definition at line 242 of file HTTPSession.h.
|
protected |
Closes the underlying socket.
void Poco::Net::HTTPSession::setKeepAlive | ( | bool | keepAlive | ) |
void Poco::Net::HTTPSession::setTimeout | ( | const Poco::Timespan & | connectionTimeout, |
const Poco::Timespan & | sendTimeout, | ||
const Poco::Timespan & | receiveTimeout ) |
Sets the timeout for the HTTP session.
void Poco::Net::HTTPSession::setTimeout | ( | const Poco::Timespan & | timeout | ) |
Returns the value of the keep-alive flag for this session.
|
inline |
Detaches the socket from the session.
The socket is returned, and a new, uninitialized socket is attached to the session.
Definition at line 224 of file HTTPSession.h.
|
protectedvirtual |
Reads up to length bytes.
If there is data in the buffer, this data is returned. Otherwise, data is read from the socket to avoid unnecessary buffering.
Reimplemented in Poco::Net::HTTPClientSession.
|
friend |
Definition at line 205 of file HTTPSession.h.
|
friend |
Definition at line 204 of file HTTPSession.h.
|
friend |
Definition at line 203 of file HTTPSession.h.
|
friend |
Definition at line 202 of file HTTPSession.h.
|
private |
Definition at line 196 of file HTTPSession.h.
|
private |
Definition at line 200 of file HTTPSession.h.
|
private |
Definition at line 195 of file HTTPSession.h.
|
private |
Definition at line 192 of file HTTPSession.h.
|
private |
Definition at line 193 of file HTTPSession.h.
|
private |
Definition at line 194 of file HTTPSession.h.
|
private |
Definition at line 199 of file HTTPSession.h.
|
private |
Definition at line 197 of file HTTPSession.h.
|
private |
Definition at line 198 of file HTTPSession.h.
|
private |
Definition at line 191 of file HTTPSession.h.