Classes | Public Types | Public Member Functions | Protected Types | Protected Member Functions | Protected Attributes

gnash::HTTP Class Reference

#include <http.h>

Inheritance diagram for gnash::HTTP:
Inheritance graph
[legend]
Collaboration diagram for gnash::HTTP:
Collaboration graph
[legend]

List of all members.

Classes

struct  http_response_t
struct  http_version_t

Public Types

enum  http_status_e {
  CONTINUE = 100, SWITCHPROTOCOLS = 101, OK = 200, CREATED = 201,
  ACCEPTED = 202, NON_AUTHORITATIVE = 203, NO_CONTENT = 204, RESET_CONTENT = 205,
  PARTIAL_CONTENT = 206, MULTIPLE_CHOICES = 300, MOVED_PERMANENTLY = 301, FOUND = 302,
  SEE_OTHER = 303, NOT_MODIFIED = 304, USE_PROXY = 305, TEMPORARY_REDIRECT = 307,
  BAD_REQUEST = 400, UNAUTHORIZED = 401, PAYMENT_REQUIRED = 402, FORBIDDEN = 403,
  NOT_FOUND = 404, METHOD_NOT_ALLOWED = 405, NOT_ACCEPTABLE = 406, PROXY_AUTHENTICATION_REQUIRED = 407,
  REQUEST_TIMEOUT = 408, CONFLICT = 409, GONE = 410, LENGTH_REQUIRED = 411,
  PRECONDITION_FAILED = 412, REQUEST_ENTITY_TOO_LARGE = 413, REQUEST_URI_TOO_LARGE = 414, UNSUPPORTED_MEDIA_TYPE = 415,
  REQUESTED_RANGE_NOT_SATISFIABLE = 416, EXPECTATION_FAILED = 417, INTERNAL_SERVER_ERROR = 500, NOT_IMPLEMENTED = 501,
  BAD_GATEWAY = 502, SERVICE_UNAVAILABLE = 503, GATEWAY_TIMEOUT = 504, HTTP_VERSION_NOT_SUPPORTED = 505,
  LIFE_IS_GOOD = 1234, CLOSEPIPE = 1235
}
enum  http_method_e {
  HTTP_NONE, HTTP_OPTIONS, HTTP_GET, HTTP_HEAD,
  HTTP_POST, HTTP_PUT, HTTP_DELETE, HTTP_TRACE,
  HTTP_CONNECT, HTTP_RESPONSE
}
enum  rtmpt_cmd_e { OPEN, SEND, IDLE, CLOSE }

Public Member Functions

 HTTP ()
 ~HTTP ()
bool checkRequestFields (cygnal::Buffer &buf)
bool checkEntityFields (cygnal::Buffer &buf)
bool checkGeneralFields (cygnal::Buffer &buf)
std::vector< boost::shared_ptr
< cygnal::Element > > 
parseEchoRequest (cygnal::Buffer &buf)
std::vector< boost::shared_ptr
< cygnal::Element > > 
parseEchoRequest (boost::uint8_t *buf, size_t size)
size_t getContentLength ()
boost::uint8_t * processHeaderFields (cygnal::Buffer *buf)
std::string & getField (const std::string &name)
size_t NumOfFields ()
void clearFields ()
std::map< std::string,
std::string > & 
getFields ()
boost::shared_ptr< std::vector
< std::string > > 
getFieldItem (const std::string &name)
boost::shared_ptr
< http_response_t
parseStatus (const std::string &line)
boost::shared_ptr< cygnal::BufferformatServerReply (http_status_e code)
cygnal::BufferformatGetReply (DiskStream::filetype_e type, size_t size, http_status_e code)
cygnal::BufferformatGetReply (size_t size, http_status_e code)
cygnal::BufferformatGetReply (http_status_e code)
cygnal::BufferformatPostReply (rtmpt_cmd_e code)
HTTPoperator= (HTTP &obj)
bool clearHeader ()
 clear the data in the stored header
bool startHeader ()
 Start constructing a new HTTP header. As it's hard to predict how much storage to allocate, all of these methods for formatting HTTP header fields store the header while adding data to it. It requires another function to actually send the data.
cygnal::BufferformatCommon (const std::string &data)
 Format the common header fields that need no other processing. Most of these fields are purely ASCII based, and so chare a common constructor. A few require formatting of numerical data into string data, so they can't use the common form.
cygnal::BufferformatHeader (DiskStream::filetype_e type, size_t filesize, http_status_e code)
cygnal::BufferformatHeader (size_t filesize, http_status_e type)
cygnal::BufferformatHeader (http_status_e type)
cygnal::BufferformatRequest (const std::string &url, http_method_e req)
cygnal::BufferformatEchoResponse (const std::string &num, cygnal::Element &el)
cygnal::BufferformatEchoResponse (const std::string &num, cygnal::Buffer &data)
cygnal::BufferformatEchoResponse (const std::string &num, boost::uint8_t *data, size_t size)
cygnal::BufferformatMethod (const std::string &data)
cygnal::BufferformatDate ()
cygnal::BufferformatServer ()
cygnal::BufferformatServer (const std::string &data)
cygnal::BufferformatReferer (const std::string &data)
cygnal::BufferformatConnection (const std::string &data)
cygnal::BufferformatKeepAlive (const std::string &data)
cygnal::BufferformatContentLength ()
cygnal::BufferformatContentLength (boost::uint32_t filesize)
cygnal::BufferformatContentType ()
cygnal::BufferformatContentType (DiskStream::filetype_e type)
cygnal::BufferformatHost (const std::string &data)
cygnal::BufferformatAgent (const std::string &data)
cygnal::BufferformatAcceptRanges (const std::string &data)
cygnal::BufferformatLastModified ()
cygnal::BufferformatLastModified (const std::string &data)
cygnal::BufferformatEtag (const std::string &data)
cygnal::BufferformatLanguage (const std::string &data)
cygnal::BufferformatCharset (const std::string &data)
cygnal::BufferformatEncoding (const std::string &data)
cygnal::BufferformatTE (const std::string &data)
void terminateHeader ()
boost::uint8_t * getHeader ()
cygnal::BuffergetBuffer ()
void dump ()
int recvMsg (int fd)
 Receive a message from the other end of the network connection.
int recvMsg (int fd, size_t size)
size_t recvChunked (boost::uint8_t *data, size_t size)
int sendMsg ()
 Send a message to the other end of the network connection.
int sendMsg (int fd)
 Send a message to the other end of the network connection. ` Sends the contents of the _header and _body private data to the already opened network connection.
int sendMsg (const boost::uint8_t *data, size_t size)
 Send a message to the other end of the network connection. ` Sends the contents of the _header and _body private data to the already opened network connection.
int sendMsg (boost::shared_ptr< cygnal::Buffer > &buf)
int sendMsg (std::stringstream &sstr)
bool keepAlive ()
void keepAlive (bool x)
int getMaxRequests ()
int getFileSize ()
std::string & getFilespec ()
std::string & getParams ()
std::map< int, struct
status_codes * > 
getStatusCodes ()
http_version_tgetVersion ()
void setDocRoot (const std::string &path)
std::string & getDocRoot ()
boost::shared_ptr
< cygnal::Buffer > DSOEXPORT 
popChunk ()
boost::shared_ptr
< cygnal::Buffer > DSOEXPORT 
peekChunk ()
size_t DSOEXPORT sizeChunks ()
boost::shared_ptr
< cygnal::Buffer > DSOEXPORT 
mergeChunks ()
http_method_e getOperation ()

Protected Types

typedef boost::char_separator
< char > 
Sep
typedef boost::tokenizer< SepTok

Protected Member Functions

http_method_e extractCommand (boost::uint8_t *data)
http_method_e extractCommand (cygnal::Buffer &data)

Protected Attributes

http_method_e _cmd
cygnal::Buffer _buffer
CQue _que
DiskStream::filetype_e _filetype
std::string _filespec
std::string _params
boost::uint32_t _filesize
std::map< int, struct
status_codes * > 
_status_codes
std::map< std::string,
std::string > 
_fields
http_version_t _version
bool _keepalive
int _clientid
int _index
int _max_requests
std::string _docroot
bool _close

Member Typedef Documentation

typedef boost::char_separator<char> gnash::HTTP::Sep [protected]
typedef boost::tokenizer<Sep> gnash::HTTP::Tok [protected]

Member Enumeration Documentation

Enumerator:
HTTP_NONE 
HTTP_OPTIONS 
HTTP_GET 
HTTP_HEAD 
HTTP_POST 
HTTP_PUT 
HTTP_DELETE 
HTTP_TRACE 
HTTP_CONNECT 
HTTP_RESPONSE 
Enumerator:
CONTINUE 
SWITCHPROTOCOLS 
OK 
CREATED 
ACCEPTED 
NON_AUTHORITATIVE 
NO_CONTENT 
RESET_CONTENT 
PARTIAL_CONTENT 
MULTIPLE_CHOICES 
MOVED_PERMANENTLY 
FOUND 
SEE_OTHER 
NOT_MODIFIED 
USE_PROXY 
TEMPORARY_REDIRECT 
BAD_REQUEST 
UNAUTHORIZED 
PAYMENT_REQUIRED 
FORBIDDEN 
NOT_FOUND 
METHOD_NOT_ALLOWED 
NOT_ACCEPTABLE 
PROXY_AUTHENTICATION_REQUIRED 
REQUEST_TIMEOUT 
CONFLICT 
GONE 
LENGTH_REQUIRED 
PRECONDITION_FAILED 
REQUEST_ENTITY_TOO_LARGE 
REQUEST_URI_TOO_LARGE 
UNSUPPORTED_MEDIA_TYPE 
REQUESTED_RANGE_NOT_SATISFIABLE 
EXPECTATION_FAILED 
INTERNAL_SERVER_ERROR 
NOT_IMPLEMENTED 
BAD_GATEWAY 
SERVICE_UNAVAILABLE 
GATEWAY_TIMEOUT 
HTTP_VERSION_NOT_SUPPORTED 
LIFE_IS_GOOD 
CLOSEPIPE 
Enumerator:
OPEN 
SEND 
IDLE 
CLOSE 

Constructor & Destructor Documentation

gnash::HTTP::HTTP (  ) 
gnash::HTTP::~HTTP (  ) 

Member Function Documentation

bool gnash::HTTP::checkEntityFields ( cygnal::Buffer buf  ) 
bool gnash::HTTP::checkGeneralFields ( cygnal::Buffer buf  ) 
bool gnash::HTTP::checkRequestFields ( cygnal::Buffer buf  ) 
void gnash::HTTP::clearFields (  )  [inline]

References _fields.

bool gnash::HTTP::clearHeader (  ) 
void gnash::HTTP::dump (  ) 
HTTP::http_method_e gnash::HTTP::extractCommand ( boost::uint8_t *  data  )  [protected]
http_method_e gnash::HTTP::extractCommand ( cygnal::Buffer data  )  [inline, protected]
cygnal::Buffer& gnash::HTTP::formatAcceptRanges ( const std::string &  data  )  [inline]

Referenced by formatHeader().

cygnal::Buffer& gnash::HTTP::formatAgent ( const std::string &  data  )  [inline]
cygnal::Buffer& gnash::HTTP::formatCharset ( const std::string &  data  )  [inline]
cygnal::Buffer& gnash::HTTP::formatCommon ( const std::string &  data  ) 

Format the common header fields that need no other processing. Most of these fields are purely ASCII based, and so chare a common constructor. A few require formatting of numerical data into string data, so they can't use the common form.

cygnal::Buffer& gnash::HTTP::formatConnection ( const std::string &  data  )  [inline]
cygnal::Buffer & gnash::HTTP::formatContentLength (  ) 
cygnal::Buffer & gnash::HTTP::formatContentLength ( boost::uint32_t  filesize  ) 

References _buffer.

cygnal::Buffer & gnash::HTTP::formatContentType ( DiskStream::filetype_e  type  ) 
cygnal::Buffer & gnash::HTTP::formatContentType (  ) 
cygnal::Buffer & gnash::HTTP::formatDate (  ) 
cygnal::Buffer& gnash::HTTP::formatEchoResponse ( const std::string &  num,
cygnal::Element el 
)
cygnal::Buffer & gnash::HTTP::formatEchoResponse ( const std::string &  num,
boost::uint8_t *  data,
size_t  size 
)
cygnal::Buffer & gnash::HTTP::formatEchoResponse ( const std::string &  num,
cygnal::Buffer data 
)
cygnal::Buffer& gnash::HTTP::formatEncoding ( const std::string &  data  )  [inline]
cygnal::Buffer& gnash::HTTP::formatEtag ( const std::string &  data  )  [inline]
cygnal::Buffer& gnash::HTTP::formatGetReply ( size_t  size,
http_status_e  code 
)

Reimplemented in cygnal::HTTPServer.

cygnal::Buffer& gnash::HTTP::formatGetReply ( http_status_e  code  ) 

Reimplemented in cygnal::HTTPServer.

cygnal::Buffer& gnash::HTTP::formatGetReply ( DiskStream::filetype_e  type,
size_t  size,
http_status_e  code 
)

Reimplemented in cygnal::HTTPServer.

cygnal::Buffer & gnash::HTTP::formatHeader ( DiskStream::filetype_e  type,
size_t  filesize,
http_status_e  code 
)
cygnal::Buffer & gnash::HTTP::formatHeader ( http_status_e  type  ) 

References _filesize, and formatHeader().

cygnal::Buffer & gnash::HTTP::formatHeader ( size_t  filesize,
http_status_e  type 
)

References _filetype, and formatHeader().

cygnal::Buffer& gnash::HTTP::formatHost ( const std::string &  data  )  [inline]
cygnal::Buffer& gnash::HTTP::formatKeepAlive ( const std::string &  data  )  [inline]
cygnal::Buffer& gnash::HTTP::formatLanguage ( const std::string &  data  )  [inline]
cygnal::Buffer & gnash::HTTP::formatLastModified (  ) 

References s2x::d.

Referenced by formatHeader().

cygnal::Buffer& gnash::HTTP::formatLastModified ( const std::string &  data  )  [inline]
cygnal::Buffer& gnash::HTTP::formatMethod ( const std::string &  data  )  [inline]
cygnal::Buffer& gnash::HTTP::formatPostReply ( rtmpt_cmd_e  code  ) 

Reimplemented in cygnal::HTTPServer.

cygnal::Buffer& gnash::HTTP::formatReferer ( const std::string &  data  )  [inline]
cygnal::Buffer& gnash::HTTP::formatRequest ( const std::string &  url,
http_method_e  req 
)
cygnal::Buffer & gnash::HTTP::formatServer (  ) 
cygnal::Buffer& gnash::HTTP::formatServer ( const std::string &  data  ) 
boost::shared_ptr<cygnal::Buffer> gnash::HTTP::formatServerReply ( http_status_e  code  ) 

Reimplemented in cygnal::HTTPServer.

cygnal::Buffer& gnash::HTTP::formatTE ( const std::string &  data  )  [inline]
cygnal::Buffer& gnash::HTTP::getBuffer (  )  [inline]

References _buffer.

size_t gnash::HTTP::getContentLength (  ) 

References getField().

std::string& gnash::HTTP::getDocRoot (  )  [inline]
std::string& gnash::HTTP::getField ( const std::string &  name  )  [inline]
boost::shared_ptr< std::vector< std::string > > gnash::HTTP::getFieldItem ( const std::string &  name  ) 
std::map<std::string, std::string>& gnash::HTTP::getFields (  )  [inline]

References _fields.

int gnash::HTTP::getFileSize (  )  [inline]
std::string& gnash::HTTP::getFilespec (  )  [inline]
boost::uint8_t* gnash::HTTP::getHeader (  )  [inline]

References _buffer.

int gnash::HTTP::getMaxRequests (  )  [inline]
http_method_e gnash::HTTP::getOperation (  )  [inline]
std::string& gnash::HTTP::getParams (  )  [inline]
std::map<int, struct status_codes *> gnash::HTTP::getStatusCodes (  )  [inline]
http_version_t* gnash::HTTP::getVersion (  )  [inline]

References _version.

bool gnash::HTTP::keepAlive (  )  [inline]
void gnash::HTTP::keepAlive ( bool  x  )  [inline]
boost::shared_ptr<cygnal::Buffer> DSOEXPORT gnash::HTTP::mergeChunks (  )  [inline]
size_t gnash::HTTP::NumOfFields (  )  [inline]

References _fields.

HTTP & gnash::HTTP::operator= ( HTTP obj  ) 
std::vector<boost::shared_ptr<cygnal::Element > > gnash::HTTP::parseEchoRequest ( cygnal::Buffer buf  )  [inline]
std::vector<boost::shared_ptr<cygnal::Element > > gnash::HTTP::parseEchoRequest ( boost::uint8_t *  buf,
size_t  size 
)

Reimplemented in cygnal::GatewayTest.

boost::shared_ptr<http_response_t> gnash::HTTP::parseStatus ( const std::string &  line  ) 
boost::shared_ptr<cygnal::Buffer> DSOEXPORT gnash::HTTP::peekChunk (  )  [inline]

Referenced by connection_handler().

boost::shared_ptr<cygnal::Buffer> DSOEXPORT gnash::HTTP::popChunk (  )  [inline]
boost::uint8_t * gnash::HTTP::processHeaderFields ( cygnal::Buffer buf  ) 
size_t gnash::HTTP::recvChunked ( boost::uint8_t *  data,
size_t  size 
)
int gnash::HTTP::recvMsg ( int  fd  ) 

Receive a message from the other end of the network connection.

Parameters:
fd The file descriptor to read from
Returns:
The number of bytes sent

Referenced by cygnal::HTTPServer::http_handler().

int gnash::HTTP::recvMsg ( int  fd,
size_t  size 
)
int DSOEXPORT gnash::HTTP::sendMsg ( const boost::uint8_t *  data,
size_t  size 
)

Send a message to the other end of the network connection. ` Sends the contents of the _header and _body private data to the already opened network connection.

Parameters:
data A real pointer to the data.
size The number of bytes of data stored.
Returns:
The number of bytes sent

References gnash::Network::writeNet().

int gnash::HTTP::sendMsg ( boost::shared_ptr< cygnal::Buffer > &  buf  )  [inline]

References sendMsg().

Referenced by sendMsg().

int gnash::HTTP::sendMsg ( std::stringstream &  sstr  )  [inline]

References sendMsg().

Referenced by sendMsg().

int DSOEXPORT gnash::HTTP::sendMsg (  ) 

Send a message to the other end of the network connection.

Send a message to the other end of the network connection. ` Sends the contents of the _header and _body private data to the already opened network connection.

Parameters:
data A real pointer to the data.
size The number of bytes of data stored.
buf A smart pointer to a Buffer class.
sstr A smart pointer to a Buffer class.
fd The file descriptor to use for writing to the network.
void Send the contents of the _header and _body.
Returns:
The number of bytes sent
The number of bytes sent
int DSOEXPORT gnash::HTTP::sendMsg ( int  fd  ) 

Send a message to the other end of the network connection. ` Sends the contents of the _header and _body private data to the already opened network connection.

Parameters:
fd The file descriptor to use for writing to the network.
Returns:
The number of bytes sent
void gnash::HTTP::setDocRoot ( const std::string &  path  )  [inline]

Referenced by connection_handler().

size_t DSOEXPORT gnash::HTTP::sizeChunks (  )  [inline]
bool gnash::HTTP::startHeader (  ) 

Start constructing a new HTTP header. As it's hard to predict how much storage to allocate, all of these methods for formatting HTTP header fields store the header while adding data to it. It requires another function to actually send the data.

References clearHeader().

void gnash::HTTP::terminateHeader (  )  [inline]

Member Data Documentation

int gnash::HTTP::_clientid [protected]

Referenced by dump().

bool gnash::HTTP::_close [protected]

Referenced by formatHeader().

std::string gnash::HTTP::_docroot [protected]
std::map<std::string, std::string> gnash::HTTP::_fields [protected]
boost::uint32_t gnash::HTTP::_filesize [protected]
std::string gnash::HTTP::_filespec [protected]
int gnash::HTTP::_index [protected]
bool gnash::HTTP::_keepalive [protected]
int gnash::HTTP::_max_requests [protected]

Referenced by clearHeader(), and processHeaderFields().

std::string gnash::HTTP::_params [protected]
CQue gnash::HTTP::_que [protected]
std::map<int, struct status_codes *> gnash::HTTP::_status_codes [protected]

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