Sonde
v1.1.0
Embeddable Model Context Protocol server for Qt applications
Toggle main menu visibility
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
15
namespace
Sonde::Cli {
16
18
struct
HttpReply
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
29
using
Header
= std::pair<QByteArray, QByteArray>;
30
32
class
Http
33
{
34
public
:
35
Http();
36
39
HttpReply
send
(
const
QByteArray &verb,
const
QUrl &url,
const
QList<Header> &headers,
40
const
QByteArray &body,
int
timeoutMs);
41
42
private
:
43
QNetworkAccessManager
m_manager
;
44
};
45
46
}
// namespace Sonde::Cli
Sonde::Cli::Http::send
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
Sonde::Cli::Http::m_manager
QNetworkAccessManager m_manager
Makes the requests.
Definition
http.h:43
Sonde::Cli::Header
std::pair< QByteArray, QByteArray > Header
A header's name and value.
Definition
http.h:29
Sonde::Cli::HttpReply
The answer to a request, or why there was none.
Definition
http.h:19
Sonde::Cli::HttpReply::body
QByteArray body
The body.
Definition
http.h:25
Sonde::Cli::HttpReply::status
int status
The HTTP status, or 0 if no answer came.
Definition
http.h:20
Sonde::Cli::HttpReply::error
QNetworkReply::NetworkError error
Why none came.
Definition
http.h:21
Sonde::Cli::HttpReply::errorString
QString errorString
Why none came, in words.
Definition
http.h:22
Sonde::Cli::HttpReply::contentType
QByteArray contentType
The Content-Type header.
Definition
http.h:23
Sonde::Cli::HttpReply::sessionId
QByteArray sessionId
The Mcp-Session-Id header.
Definition
http.h:24
tools
cli
http.h
Generated by
1.18.0