#include <HttpParser.h>
Static Public Member Functions | |
static std::pair< std::string, std::string > | receiveHeaderAndLeftover (Tcp &socket) |
Receive raw headers from the socket until \r \r . | |
static bool | receiveBody (Tcp &socket, const std::map< std::string, std::string > &headers, const std::string &leftoverBody, std::string &outBody, size_t maxLength, bool *wasTruncated) |
Receive the HTTP body from socket, using Content-Length or connection close. | |
static bool | receiveChunkedBodyToFile (Tcp &socket, const std::string &leftover, std::function< bool(const char *, size_t)> writeFn, size_t maxLength, bool *wasTruncated) |
static bool | receiveFixedLengthBodyToFile (Tcp &socket, const std::map< std::string, std::string > &headers, const std::string &leftover, std::function< bool(const char *, size_t)> writeFn, size_t maxLength, bool *wasTruncated) |
static int | parseStatusCode (const std::string &statusLine) |
Parses the HTTP status line to extract the status code. | |
static std::map< std::string, std::string > | parseHeaders (const std::string &rawHeaders) |
Parses the HTTP headers from a raw header string. | |
static bool | isChunkedEncoding (const std::map< std::string, std::string > &headers) |
static bool | receiveChunkedBodyToString (Tcp &socket, const std::string &leftover, std::string &out, size_t maxLength, bool *wasTruncated) |
static bool | receiveFixedLengthBodyToString (Tcp &socket, const std::map< std::string, std::string > &headers, const std::string &leftover, std::string &out, size_t maxLength, bool *wasTruncated) |
static bool | receiveUnknownLengthBodyToString (Tcp &socket, const std::string &leftover, std::string &out, size_t maxLength, bool *wasTruncated) |
Definition at line 23 of file HttpParser.h.
|
static |
Definition at line 175 of file HttpParser.cpp.
References toLower().
Referenced by receiveBody().
|
static |
rawHeaders | The raw HTTP headers as a string. |
Definition at line 46 of file HttpParser.cpp.
Referenced by HttpRequest::parseHeaders().
|
static |
statusLine | The HTTP status line (e.g., "HTTP/1.1 200 OK"). |
Definition at line 33 of file HttpParser.cpp.
|
static |
Receives the HTTP body from a TCP socket based on headers.
socket | The TCP socket to read from. |
headers | The parsed HTTP headers. |
leftoverBody | Any body data that was received after the headers. |
outBody | The output string to store the received body. |
maxLength | The maximum length of the body to receive. |
wasTruncated | Pointer to a boolean that will be set to true if the body was truncated. |
Definition at line 152 of file HttpParser.cpp.
References isChunkedEncoding(), receiveChunkedBodyToString(), receiveFixedLengthBodyToString(), and receiveUnknownLengthBodyToString().
|
static |
Definition at line 264 of file HttpParser.cpp.
References ChunkedDecoder::feedToFile(), HTTP_RECEIVE_TIMEOUT, ChunkedDecoder::isComplete(), Tcp::recv(), and ChunkedDecoder::wasTruncated().
|
static |
Definition at line 181 of file HttpParser.cpp.
References ChunkedDecoder::feed(), ChunkedDecoder::getDecoded(), HTTP_RECEIVE_TIMEOUT, ChunkedDecoder::isComplete(), Tcp::recv(), and ChunkedDecoder::wasTruncated().
Referenced by receiveBody().
|
static |
Definition at line 297 of file HttpParser.cpp.
References HTTP_RECEIVE_TIMEOUT, and Tcp::recv().
|
static |
Definition at line 205 of file HttpParser.cpp.
References HTTP_RECEIVE_TIMEOUT, and Tcp::recv().
Referenced by receiveBody().
|
static |
Receives HTTP headers and any leftover body data from a TCP socket.
socket | The socket to receive from |
outHeaders | The received headers |
leftoverBody | The leftover body after headers |
socket | The TCP socket to read from. |
Definition at line 111 of file HttpParser.cpp.
References HTTP_RECEIVE_TIMEOUT, and Tcp::recv().
|
static |
Definition at line 243 of file HttpParser.cpp.
References HTTP_RECEIVE_TIMEOUT, and Tcp::recv().
Referenced by receiveBody().