16#ifndef HYDROCOUPLEOGC_HTTPCLIENT_H
17#define HYDROCOUPLEOGC_HTTPCLIENT_H
30class QNetworkAccessManager;
96 explicit HttpClient(QObject *parent =
nullptr);
123 RequestId get(
const QUrl &url,
const ServiceCredentials &credentials,
161 QNetworkReply *reply =
nullptr;
162 QList<RequestId> waiters;
165 void deliver(
const QByteArray &key,
const HttpResponse &response);
167 QNetworkAccessManager *m_manager =
nullptr;
169 int m_transferTimeout = 30000;
170 RequestId m_nextId = 1;
172 QHash<RequestId, Waiter> m_waiters;
173 QHash<QByteArray, InFlight> m_inFlight;
int pendingCount() const
How many callers are waiting.
Definition httpclient.cpp:255
RequestId get(const QUrl &url, const ServiceCredentials &credentials, Callback callback)
Asks for url, calling callback when it is known.
Definition httpclient.cpp:81
void setUserAgent(const QString &userAgent)
Sent on every request; identifies the client to a server's logs.
Definition httpclient.cpp:66
void setTransferTimeout(int milliseconds)
How long a request may stall before it is given up on.
Definition httpclient.cpp:71
std::function< void(const HttpResponse &)> Callback
Called on the thread the client lives on, once, per get().
Definition httpclient.h:83
void cancelAll()
Gives up on everything outstanding.
Definition httpclient.cpp:243
void setCacheDirectory(const QString &path, qint64 maximumBytes=0)
Where responses are cached between sessions.
Definition httpclient.cpp:43
void cancel(RequestId id)
Gives up on id.
Definition httpclient.cpp:201
HttpClient(QObject *parent=nullptr)
Constructs a client with nothing outstanding.
Definition httpclient.cpp:31
int inFlightCount() const
How many requests are actually on the wire.
Definition httpclient.cpp:260
quint64 RequestId
What get() returns, and cancel() takes. Never 0 for a live ask.
Definition httpclient.h:86
Symbol visibility for the shared library.
#define HYDROCOUPLEOGC_EXPORT
Definition export.h:20
Definition axisorder.h:30
What a request has to carry to be let through, and how to say so in a log without saying it.
What came back.
Definition httpclient.h:39
QString contentType
Definition httpclient.h:46
QString error
Why not, when ok is false.
Definition httpclient.h:60
bool ok
Whether the body is the thing that was asked for.
Definition httpclient.h:41
QUrl url
What was finally fetched, after any redirects.
Definition httpclient.h:63
int statusCode
The HTTP status, or 0 when the request never reached a server.
Definition httpclient.h:44
QByteArray body
The body, delivered whether or not the request succeeded.
Definition httpclient.h:57