OpenSDN source code
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
HttpSession Class Reference

#include <http_session.h>

Inheritance diagram for HttpSession:
Collaboration diagram for HttpSession:

Classes

class  RequestBuilder
 
class  RequestHandler
 

Public Types

typedef boost::function< void(HttpSession
*session, enum
TcpSession::Event event)> 
SessionEventCb
 
- Public Types inherited from SslSession
typedef
boost::asio::ssl::stream
< boost::asio::ip::tcp::socket > 
SslSocket
 
- Public Types inherited from TcpSession
enum  Event {
  EVENT_NONE, ACCEPT, CONNECT_COMPLETE, CONNECT_FAILED,
  CLOSE
}
 
enum  Direction { ACTIVE, PASSIVE }
 
typedef
boost::asio::ip::tcp::socket 
Socket
 
typedef
boost::asio::ip::tcp::socket::native_handle_type 
NativeSocketType
 
typedef
boost::asio::ip::tcp::endpoint 
Endpoint
 
typedef boost::function< void(TcpSession
*, Event)> 
EventObserver
 
typedef boost::asio::const_buffer Buffer
 

Public Member Functions

 HttpSession (HttpServer *server, SslSocket *sock, bool async_ready=true)
 
virtual ~HttpSession ()
 
const std::string get_context ()
 
void AcceptSession ()
 
void RegisterEventCb (SessionEventCb cb)
 
- Public Member Functions inherited from SslSession
 SslSession (SslServer *server, SslSocket *socket, bool async_read_ready=true)
 
virtual Socketsocket () const
 
void TriggerSslHandShake (SslHandShakeCallbackHandler)
 
bool IsSslDisabled ()
 
bool IsSslHandShakeDelayed ()
 
bool IsSslHandShakeSuccess ()
 
bool IsSslHandShakeSuccessLocked ()
 
bool IsSslHandShakeInProgress ()
 
void SetSslHandShakeInProgress (bool state)
 
- Public Member Functions inherited from TcpSession
 TcpSession (TcpServer *server, Socket *socket, bool async_read_ready=true, size_t buffer_send_size=TcpSession::kDefaultWriteBufferSize)
 
virtual bool Send (const uint8_t *data, size_t size, size_t *sent)
 
virtual bool Connected (Endpoint remote)
 
virtual void Accepted ()
 
void ConnectFailed ()
 
void Close ()
 
virtual std::string ToString () const
 
NativeSocketType sock_descriptor ()
 
TcpServerserver ()
 
int32_t local_port () const
 
int32_t remote_port () const
 
void set_observer (EventObserver observer)
 
virtual void ReleaseBuffer (Buffer buffer)
 
virtual int GetSessionInstance () const
 
bool IsEstablished () const
 
bool IsClosed () const
 
bool IsServerSession ()
 
Endpoint remote_endpoint () const
 
const std::string & remote_addr_string () const
 
Endpoint local_endpoint () const
 
const boost::system::error_code & close_reason () const
 
virtual boost::system::error_code SetSocketOptions ()
 
void set_read_on_connect (bool read)
 
void SessionEstablished (Endpoint remote, Direction direction)
 
virtual void AsyncReadStart ()
 
virtual void SetDeferReader (bool defer_reader)
 
virtual bool IsReaderDeferred () const
 
const io::SocketStatsGetSocketStats () const
 
void GetRxSocketStats (SocketIOStats *socket_stats) const
 
void GetTxSocketStats (SocketIOStats *socket_stats) const
 
void GetRxSocketStats (SocketIOStats &socket_stats) const
 
void GetTxSocketStats (SocketIOStats &socket_stats) const
 
int SetMd5SocketOption (uint32_t peer_ip, const std::string &md5_password)
 
int ClearMd5SocketOption (uint32_t peer_ip)
 
int SetDscpSocketOption (uint8_t value)
 
uint8_t GetDscpValue () const
 
const std::string & ToUVEKey () const
 
boost::system::error_code SetTcpNoDelay ()
 
boost::system::error_code SetTcpSendBufSize (uint32_t size)
 
boost::system::error_code SetTcpRecvBufSize (uint32_t size)
 

Static Public Member Functions

static bool SendSession (std::string const &s, const uint8_t *data, size_t size, size_t *sent)
 
static std::string get_client_context (std::string const &s)
 
static bool set_client_context (std::string const &s, const std::string &ctx)
 
static tbb::atomic< long > GetPendingTaskCount ()
 
- Static Public Member Functions inherited from SslSession
static bool IsSocketErrorHard (const boost::system::error_code &ec)
 
- Static Public Member Functions inherited from TcpSession
static const uint8_t * BufferData (const Buffer &buffer)
 
static size_t BufferSize (const Buffer &buffer)
 
static bool IsSocketErrorHard (const boost::system::error_code &ec)
 

Public Attributes

 OnMessageBegin
 
 OnUrl
 
 OnStatusComplete
 
 OnHeaderField
 
 OnHeaderValue
 
 OnHeadersComplete
 
 OnBody
 

Protected Member Functions

virtual void OnRead (Buffer buffer)
 
- Protected Member Functions inherited from SslSession
virtual ~SslSession ()
 
- Protected Member Functions inherited from TcpSession
void AsyncReadStartInternal (TcpSessionPtr session)
 
virtual ~TcpSession ()
 
virtual void WriteReady (const boost::system::error_code &error)
 
void AsyncWriteInternal (TcpSessionPtr session)
 
virtual int reader_task_id () const
 
bool established () const
 
EventObserver observer ()
 
boost::system::error_code SetSocketKeepaliveOptions (int keepalive_time, int keepalive_intvl, int keepalive_probes, int tcp_user_timeout_val=0)
 
void CloseInternal (const boost::system::error_code &ec, bool call_observer, bool notify_server=true)
 
void TriggerAsyncReadHandler ()
 

Private Types

typedef boost::intrusive_ptr
< HttpSession
HttpSessionPtr
 
typedef std::map< std::string,
HttpSessionPtr
map_type
 

Private Member Functions

void OnSessionEvent (TcpSession *session, enum TcpSession::Event event)
 
const std::string get_client_context ()
 
void set_client_context (const std::string &client_ctx)
 
 DISALLOW_COPY_AND_ASSIGN (HttpSession)
 

Static Private Member Functions

static map_typeGetMap ()
 
static HttpSessionPtr GetSession (std::string const &s)
 

Private Attributes

boost::scoped_ptr< RequestBuilderrequest_builder_
 
tbb::concurrent_queue
< HttpRequest * > 
request_queue_
 
tbb::atomic< bool > req_queue_empty_
 
std::string context_str_
 
std::string client_context_str_
 
SessionEventCb event_cb_
 

Static Private Attributes

static int req_handler_task_id_ = -1
 
static map_typecontext_map_ = 0
 
static tbb::mutex map_mutex_
 
static tbb::atomic< long > task_count_
 

Additional Inherited Members

- Static Public Attributes inherited from TcpSession
static const int kDefaultBufferSize = 16 * 1024
 
static const int kDefaultWriteBufferSize = 32 * 1024
 
- Protected Types inherited from TcpSession
typedef boost::intrusive_ptr
< TcpSession
TcpSessionPtr
 
typedef boost::asio::strand
< boost::asio::io_context::executor_type > 
Strand
 
- Static Protected Member Functions inherited from TcpSession
static void AsyncReadHandler (TcpSessionPtr session)
 
static void AsyncWriteHandler (TcpSessionPtr session, const boost::system::error_code &error, std::size_t bytes_transferred)
 
- Protected Attributes inherited from TcpSession
tbb::mutex mutex_
 
io::SocketStats stats_
 
boost::scoped_ptr< Strandio_strand_
 

Detailed Description

Definition at line 133 of file http_session.cc.

Member Typedef Documentation

typedef boost::intrusive_ptr<HttpSession> HttpSession::HttpSessionPtr
private

Definition at line 57 of file http_session.h.

typedef std::map<std::string, HttpSessionPtr> HttpSession::map_type
private

Definition at line 59 of file http_session.h.

typedef boost::function<void(HttpSession *session, enum TcpSession::Event event)> HttpSession::SessionEventCb

Definition at line 21 of file http_session.h.

Constructor & Destructor Documentation

HttpSession::HttpSession ( HttpServer server,
SslSocket sock,
bool  async_ready = true 
)

Definition at line 222 of file http_session.cc.

Here is the call graph for this function:

HttpSession::~HttpSession ( )
virtual

Definition at line 233 of file http_session.cc.

Member Function Documentation

void HttpSession::AcceptSession ( )

Definition at line 240 of file http_session.cc.

Here is the call graph for this function:

HttpSession::DISALLOW_COPY_AND_ASSIGN ( HttpSession  )
private
static std::string HttpSession::get_client_context ( std::string const &  s)
inlinestatic

Definition at line 33 of file http_session.h.

Here is the call graph for this function:

const std::string HttpSession::get_client_context ( )
inlineprivate

Definition at line 78 of file http_session.h.

const std::string HttpSession::get_context ( )
inline

Definition at line 25 of file http_session.h.

static map_type* HttpSession::GetMap ( )
inlinestaticprivate

Definition at line 64 of file http_session.h.

static tbb::atomic<long> HttpSession::GetPendingTaskCount ( )
inlinestatic

Definition at line 45 of file http_session.h.

static HttpSessionPtr HttpSession::GetSession ( std::string const &  s)
inlinestaticprivate

Definition at line 70 of file http_session.h.

Here is the call graph for this function:

void HttpSession::OnRead ( Buffer  buffer)
protectedvirtual

Implements TcpSession.

Definition at line 289 of file http_session.cc.

Here is the call graph for this function:

void HttpSession::OnSessionEvent ( TcpSession session,
enum TcpSession::Event  event 
)
private

Definition at line 252 of file http_session.cc.

Here is the call graph for this function:

void HttpSession::RegisterEventCb ( SessionEventCb  cb)

Definition at line 248 of file http_session.cc.

static bool HttpSession::SendSession ( std::string const &  s,
const uint8_t *  data,
size_t  size,
size_t *  sent 
)
inlinestatic

Definition at line 27 of file http_session.h.

Here is the call graph for this function:

static bool HttpSession::set_client_context ( std::string const &  s,
const std::string &  ctx 
)
inlinestatic

Definition at line 38 of file http_session.h.

Here is the call graph for this function:

void HttpSession::set_client_context ( const std::string &  client_ctx)
inlineprivate

Definition at line 79 of file http_session.h.

Member Data Documentation

std::string HttpSession::client_context_str_
private

Definition at line 85 of file http_session.h.

HttpSession::map_type * HttpSession::context_map_ = 0
staticprivate

Definition at line 89 of file http_session.h.

std::string HttpSession::context_str_
private

Definition at line 84 of file http_session.h.

SessionEventCb HttpSession::event_cb_
private

Definition at line 86 of file http_session.h.

tbb::mutex HttpSession::map_mutex_
staticprivate

Definition at line 90 of file http_session.h.

HttpSession::OnBody

Definition at line 134 of file http_session.cc.

HttpSession::OnHeaderField

Definition at line 134 of file http_session.cc.

HttpSession::OnHeadersComplete

Definition at line 134 of file http_session.cc.

HttpSession::OnHeaderValue

Definition at line 134 of file http_session.cc.

HttpSession::OnMessageBegin

Definition at line 134 of file http_session.cc.

HttpSession::OnStatusComplete

Definition at line 134 of file http_session.cc.

HttpSession::OnUrl

Definition at line 134 of file http_session.cc.

int HttpSession::req_handler_task_id_ = -1
staticprivate

Definition at line 88 of file http_session.h.

tbb::atomic<bool> HttpSession::req_queue_empty_
private

Definition at line 83 of file http_session.h.

boost::scoped_ptr<RequestBuilder> HttpSession::request_builder_
private

Definition at line 81 of file http_session.h.

tbb::concurrent_queue<HttpRequest *> HttpSession::request_queue_
private

Definition at line 82 of file http_session.h.

tbb::atomic< long > HttpSession::task_count_
staticprivate

Definition at line 91 of file http_session.h.


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