#include <Application.h>
Inherited by Passenger::Application::Application::StandardSession, and Passenger::ApplicationPoolServer::ApplicationPoolServer::RemoteSession.
Public Member Functions | |
virtual | ~Session () |
Implementing classes might throw arbitrary exceptions. | |
virtual void | sendHeaders (const char *headers, unsigned int size) |
Send HTTP request headers to the 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 application. | |
virtual int | getStream () const =0 |
Get the I/O stream's file descriptor. | |
virtual void | setReaderTimeout (unsigned int msec)=0 |
Set the timeout value for reading data from the I/O stream. | |
virtual void | setWriterTimeout (unsigned int msec)=0 |
Set the timeout value for writing data from the I/O stream. | |
virtual void | shutdownReader ()=0 |
Indicate that we don't want to read data anymore from the I/O stream. | |
virtual void | shutdownWriter ()=0 |
Indicate that we don't want to write data anymore to the I/O stream. | |
virtual void | closeStream ()=0 |
Close the I/O stream. | |
virtual void | discardStream ()=0 |
Discard the I/O stream's file descriptor, so that Session won't automatically closed it upon Session's destruction. | |
virtual pid_t | getPid () const =0 |
Get the process ID of the application instance that belongs to this session. |
Session is used to forward a single HTTP request to a Ruby on Rails/Rack application. A Session has two communication channels: one for reading data from the application, and one for writing data to the application.
In general, a session object is to be used in the following manner:
A usage example is shown in Application::connect().
virtual void Passenger::Application::Application::Session::closeStream | ( | ) | [pure virtual] |
virtual int Passenger::Application::Application::Session::getStream | ( | ) | const [pure virtual] |
Get the I/O stream's file descriptor.
This steam is full-duplex, and will be automatically closed upon Session's destruction, unless discardStream() is called.
virtual void Passenger::Application::Application::Session::sendBodyBlock | ( | const char * | block, | |
unsigned int | size | |||
) | [inline, virtual] |
Send a chunk of HTTP request body data to the 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. | |
boost::thread_interrupted |
virtual void Passenger::Application::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. | |
boost::thread_interrupted |
virtual void Passenger::Application::Application::Session::sendHeaders | ( | const char * | headers, | |
unsigned int | size | |||
) | [inline, virtual] |
Send HTTP request headers to the 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. | |
boost::thread_interrupted |
virtual void Passenger::Application::Application::Session::setReaderTimeout | ( | unsigned int | msec | ) | [pure virtual] |
Set the timeout value for reading data from the I/O stream.
If no data can be read within the timeout period, then the read call will fail with error EAGAIN or EWOULDBLOCK.
msec | The timeout, in milliseconds. If 0 is given, there will be no timeout. |
SystemException | Cannot set the timeout. |
virtual void Passenger::Application::Application::Session::setWriterTimeout | ( | unsigned int | msec | ) | [pure virtual] |
Set the timeout value for writing data from the I/O stream.
If no data can be written within the timeout period, then the write call will fail with error EAGAIN or EWOULDBLOCK.
msec | The timeout, in milliseconds. If 0 is given, there will be no timeout. |
SystemException | Cannot set the timeout. |
virtual void Passenger::Application::Application::Session::shutdownReader | ( | ) | [pure virtual] |
Indicate that we don't want to read data anymore from the I/O stream.
Calling this method after closeStream() is called will have no effect.
SystemException | Something went wrong. | |
boost::thread_interrupted |
virtual void Passenger::Application::Application::Session::shutdownWriter | ( | ) | [pure virtual] |
Indicate that we don't want to write data anymore to the I/O stream.
Calling this method after closeStream() is called will have no effect.
SystemException | Something went wrong. | |
boost::thread_interrupted |