Sonde v1.1.0
Embeddable Model Context Protocol server for Qt applications
Loading...
Searching...
No Matches
http.h
Go to the documentation of this file.
1#pragma once
2
5
6#include <QtCore/QByteArray>
7#include <QtCore/QList>
8#include <QtCore/QString>
9#include <QtCore/QUrl>
10#include <QtNetwork/QNetworkAccessManager>
11#include <QtNetwork/QNetworkReply>
12
13#include <utility>
14
15namespace Sonde::Cli {
16
19{
20 int status = 0;
21 QNetworkReply::NetworkError error = QNetworkReply::NoError;
22 QString errorString;
23 QByteArray contentType;
24 QByteArray sessionId;
25 QByteArray body;
26};
27
29using Header = std::pair<QByteArray, QByteArray>;
30
32class Http
33{
34public:
35 Http();
36
39 HttpReply send(const QByteArray &verb, const QUrl &url, const QList<Header> &headers,
40 const QByteArray &body, int timeoutMs);
41
42private:
43 QNetworkAccessManager m_manager;
44};
45
46} // namespace Sonde::Cli
HttpReply send(const QByteArray &verb, const QUrl &url, const QList< Header > &headers, const QByteArray &body, int timeoutMs)
Sends verb to url with headers and body, and waits at most timeoutMs for the whole answer.
Definition http.cpp:21
QNetworkAccessManager m_manager
Makes the requests.
Definition http.h:43
std::pair< QByteArray, QByteArray > Header
A header's name and value.
Definition http.h:29
The answer to a request, or why there was none.
Definition http.h:19
QByteArray body
The body.
Definition http.h:25
int status
The HTTP status, or 0 if no answer came.
Definition http.h:20
QNetworkReply::NetworkError error
Why none came.
Definition http.h:21
QString errorString
Why none came, in words.
Definition http.h:22
QByteArray contentType
The Content-Type header.
Definition http.h:23
QByteArray sessionId
The Mcp-Session-Id header.
Definition http.h:24