Loading...
Searching...
No Matches
QHttpParser Class Reference

Utility methods for parsing HTTP requests and responses. More...

`#include <QHttpEngine/QHttpParser>`

## Static Public Member Functions

static bool | parseHeaderList (const QList< QByteArray > &lines, QHttpHeaderMap &headers)
| Parse a list of lines containing HTTP headers.
static bool | parseHeaders (const QByteArray &data, QList< QByteArray > &parts, QHttpHeaderMap &headers)
| Parse HTTP headers.
static bool | parseRequestHeaders (const QByteArray &data, QByteArray &method, QByteArray &path, QHttpHeaderMap &headers)
| Parse HTTP request headers.
static bool | parseResponseHeaders (const QByteArray &data, int &statusCode, QByteArray &statusReason, QHttpHeaderMap &headers)
| Parse HTTP response headers.
static void | split (const QByteArray &data, const QByteArray &delim, int maxSplit, QList< QByteArray > &parts)
| Split a QByteArray by the provided delimiter.

## Detailed Description

This class provides a set of static methods for parsing HTTP request and response headers. Functionality is broken up into smaller methods in order to make the unit tests simpler.

## Member Function Documentation

## parseHeaderList()

static bool QHttpParser::parseHeaderList | ( | const QList< QByteArray > & | lines,
|  | QHttpHeaderMap & | headers
| ) |  |

static

Each line is expected to be in the format "name: value". Parsing is immediately aborted if an invalid line is encountered.

## parseHeaders()

static bool QHttpParser::parseHeaders | ( | const QByteArray & | data,
|  | QList< QByteArray > & | parts,
|  | QHttpHeaderMap & | headers
| ) |  |

static

The specified header data (everything up to the double CRLF) is parsed into a status line and HTTP headers. The parts list will contain the parts from the status line.

## split()

static void QHttpParser::split | ( | const QByteArray & | data,
|  | const QByteArray & | delim,
|  | int | maxSplit,
|  | QList< QByteArray > & | parts
| ) |  |

static

If the delimiter is not present in the QByteArray, the resulting list will contain the original QByteArray as its only element. The delimiter must not be empty.

If maxSplit is nonzero, the list will contain no more than maxSplit + 1 items. If maxSplit is equal to zero, there will be no limit on the number of splits performed.

The documentation for this class was generated from the following file:

- qhttpparser.h