#include <Application.h>
Inherited by Passenger::Application::StandardSession, and Passenger::ApplicationPoolServer::RemoteSession.
Session is used to forward a single HTTP request to a Ruby on Rails application. A Session has two communication channels: one for reading data from the RoR application, and one for writing data to the RoR application.
In general, a session object is to be used in the following manner:
A usage example is shown in Application::connect().
Public Member Functions | |
virtual void | sendHeaders (const char *headers, unsigned int size) |
Send HTTP request headers to the RoR application. | |
virtual void | sendHeaders (const string &headers) |
Convenience shortcut for sendHeaders(const char *, unsigned int). | |
virtual void | sendBodyBlock (const char *block, unsigned int size) |
Send a chunk of HTTP request body data to the RoR application. | |
virtual int | getReader () const =0 |
Get the reader channel's file descriptor. | |
virtual void | closeReader ()=0 |
Close the reader channel. | |
virtual int | getWriter () const =0 |
Get the writer channel's file descriptor. | |
virtual void | closeWriter ()=0 |
Close the writer channel. | |
virtual pid_t | getPid () const =0 |
Get the process ID of the application instance that belongs to this session. |
virtual void Passenger::Application::Session::sendHeaders | ( | const char * | headers, | |
unsigned int | size | |||
) | [inline, virtual] |
Send HTTP request headers to the RoR application.
The HTTP headers must be converted into CGI headers, and then encoded into a string that matches this grammar:
headers ::= header* header ::= name NUL value NUL name ::= notnull+ value ::= notnull+ notnull ::= "\x01" | "\x02" | "\x02" | ... | "\xFF" NUL = "\x00"
This method should be the first one to be called during the lifetime of a Session object. Otherwise strange things may happen.
headers | The HTTP request headers, converted into CGI headers and encoded as a string, according to the description. | |
size | The size, in bytes, of headers . |
IOException | The writer channel has already been closed. | |
SystemException | Something went wrong during writing. |
virtual void Passenger::Application::Session::sendHeaders | ( | const string & | headers | ) | [inline, virtual] |
Convenience shortcut for sendHeaders(const char *, unsigned int).
headers |
IOException | The writer channel has already been closed. | |
SystemException | Something went wrong during writing. |
virtual void Passenger::Application::Session::sendBodyBlock | ( | const char * | block, | |
unsigned int | size | |||
) | [inline, virtual] |
Send a chunk of HTTP request body data to the RoR application.
You can call this method as many times as is required to transfer the entire HTTP request body.
This method should only be called after a sendHeaders(). Otherwise strange things may happen.
block | A block of HTTP request body data to send. | |
size | The size, in bytes, of block . |
IOException | The writer channel has already been closed. | |
SystemException | Something went wrong during writing. |
virtual int Passenger::Application::Session::getReader | ( | ) | const [pure virtual] |
Get the reader channel's file descriptor.
virtual void Passenger::Application::Session::closeReader | ( | ) | [pure virtual] |
Close the reader channel.
This method may be safely called multiple times.
virtual int Passenger::Application::Session::getWriter | ( | ) | const [pure virtual] |
Get the writer channel's file descriptor.
You should rarely have to use this directly. One should only use sendHeaders() and sendBodyBlock() whenever possible.
virtual void Passenger::Application::Session::closeWriter | ( | ) | [pure virtual] |
Close the writer channel.
This method may be safely called multiple times.