#include <HttpReader.h>
Public Types | |
enum class | State : unsigned { READY = 0 , READING_HEADERS = 1 , READING_DATA = 2 , COMPLETED = 4 , READ_ERROR = 8 } |
enum class | ReadMode { REQUEST , RESPONSE } |
Public Member Functions | |
State | getReaderState () const |
HttpHeaders & | getHttpHeaders () |
String | httpHeader (const String &headerName) const |
HttpReader (TCPSocket &socket, Buffer &output, ReadMode readMode) | |
TCPSocket & | socket () |
Buffer & | output () |
void | read () |
bool | readHttpRequest () |
void | readHttpHeaders () |
int | readAll (std::chrono::milliseconds timeout) |
int | getStatusCode () const |
const String & | getStatusText () const |
String | getRequestType () const |
String | getRequestURL () const |
void | close () |
HTTP response reader
Designed to be able accepting asynchronous data
|
strong |
Read mode, defines is it HTTP request (GET, POST, etc) or response.
|
strong |
Constructor
socket | Socket to read from |
output | Output data buffer |
HttpHeaders & sptk::HttpReader::getHttpHeaders | ( | ) |
Access to response headers
State sptk::HttpReader::getReaderState | ( | ) | const |
Returns current reader state
int sptk::HttpReader::getStatusCode | ( | ) | const |
Status code getter
const String & sptk::HttpReader::getStatusText | ( | ) | const |
Status text getter
Read-only access to response headers by name
headerName | Header name |
Buffer & sptk::HttpReader::output | ( | ) |
Get output buffer
void sptk::HttpReader::read | ( | ) |
Read data that can be read completely
int sptk::HttpReader::readAll | ( | std::chrono::milliseconds | timeout | ) |
Read HTTP headers and data after socket is just connected. For requests, received by server, call readHttpRequest() first
timeout | Read timeout |
void sptk::HttpReader::readHttpHeaders | ( | ) |
Read headers that can be read completely
bool sptk::HttpReader::readHttpRequest | ( | ) |
Read HTTP request string
TCPSocket & sptk::HttpReader::socket | ( | ) |
Get read socket