|
Sonde v1.1.0
Embeddable Model Context Protocol server for Qt applications
|
HTTP/1.1 request parsing for the HTTP transport. More...
#include <QtCore/QByteArray>#include <QtCore/QHash>Go to the source code of this file.
Classes | |
| struct | Sonde::Http::Request |
| A parsed HTTP request. More... | |
| struct | Sonde::Http::ParseLimits |
| Size limits applied while parsing. More... | |
Namespaces | |
| namespace | Sonde |
| Embeddable Model Context Protocol server for Qt applications. | |
Enumerations | |
| enum class | Sonde::Http::ParseStatus { Incomplete , Complete , Error } |
| Result of trying to parse a request from the front of a buffer. More... | |
Functions | |
| ParseStatus | Sonde::Http::parseRequest (QByteArray *buffer, const ParseLimits &limits, Request *request, int *errorStatus) |
Parses one request from the front of buffer, and removes it when complete. | |
| bool | Sonde::Http::parseHead (const QByteArray &head, Request *request) |
| Parses the request line and headers. | |
| qsizetype | Sonde::Http::decodeChunked (const QByteArray &buffer, qsizetype from, qsizetype maxBody, QByteArray *out) |
Decodes a chunked body that starts at from in buffer. | |
| QByteArray | Sonde::Http::reasonPhrase (int status) |
| The reason phrase of an HTTP status code, e.g. "Not Found". | |
| bool | Sonde::Http::bearerTokenMatches (const QByteArray &authorization, const QByteArray &token) |
| Whether an Authorization header carries Bearer <token>. | |
HTTP/1.1 request parsing for the HTTP transport.
Internal; split out from the transport so it can be unit-tested and fuzzed without sockets.
|
strong |
| bool Sonde::Http::bearerTokenMatches | ( | const QByteArray & | authorization, |
| const QByteArray & | token ) |
Whether an Authorization header carries Bearer <token>.
Compares in time that depends only on the lengths, not on how much of the token matches, so the token can't be guessed byte by byte from timing.
| qsizetype Sonde::Http::decodeChunked | ( | const QByteArray & | buffer, |
| qsizetype | from, | ||
| qsizetype | maxBody, | ||
| QByteArray * | out ) |
Decodes a chunked body that starts at from in buffer.
from), 0 if more data is needed, or -1 if the body is malformed or larger than maxBody. | bool Sonde::Http::parseHead | ( | const QByteArray & | head, |
| Request * | request ) |
Parses the request line and headers.
| ParseStatus Sonde::Http::parseRequest | ( | QByteArray * | buffer, |
| const ParseLimits & | limits, | ||
| Request * | request, | ||
| int * | errorStatus ) |
Parses one request from the front of buffer, and removes it when complete.
| buffer | Received bytes. |
| limits | Size limits. |
| request | Receives the request. |
| errorStatus | Receives the HTTP status to respond with on ParseStatus::Error. |