Utility class for extracting the HTTP status value from an HTTP response. More...
#include <HttpStatusExtractor.h>
Public Member Functions | |
bool | feed (const char *data, unsigned int size) |
Feed HTTP response data to this HttpStatusExtractor. | |
string | getStatusLine () const |
Returns the HTTP status line that has been determined. | |
string | getBuffer () const |
Get the data that has been fed so far. |
Utility class for extracting the HTTP status value from an HTTP response.
This class is used for generating a proper HTTP response. The response data that Passenger backend processes generate are like CGI responses, and do not include an initial "HTTP/1.1 [status here]" line, so this class used to extract the status from the response in order to generate a proper initial HTTP response line.
This class is supposed to be used as follows:
This class will also ensure that the status line contains a status text, e.g. if the HTTP data's status value is only "200" then "OK" will be automatically appended.
bool Passenger::HttpStatusExtractor::feed | ( | const char * | data, | |
unsigned int | size | |||
) | [inline] |
Feed HTTP response data to this HttpStatusExtractor.
One is to keep feeding data until this method returns true. When a sufficient amount of data has been fed, this method will extract the status line from the data that has been fed so far, and return true.
Do not call this method again once it has returned true.
It is safe to feed excess data. That is, it is safe if the 'data' argument contains a part of the HTTP response body. HttpStatusExtractor will only look for the status line in the HTTP response header, not in the HTTP response body. All fed data is buffered and will be available via getBuffer(), so no data will be lost.
string Passenger::HttpStatusExtractor::getStatusLine | ( | ) | const [inline] |
Returns the HTTP status line that has been determined.
The default value is "200 OK\r\n", which is returned if the HTTP response data that has been fed so far does not include a status line.