blob: 9df41c66ee5e7d3fa0da3e8516d3fe92c4aa23e8 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
|
/* Copyright (C) 2022 The Qt Company Ltd.
*
* SPDX-License-Identifier: GPL-3.0-only WITH Qt-GPL-exception-1.0
*/
#pragma once
#include <iostream>
#include <sstream>
#include <map>
#define SERVER_CONN_TIMEOUT 10
#if _WIN32
#include "curl/curl.h"
#else
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <unistd.h>
#include <netdb.h>
#include <curl/curl.h>
#endif
namespace QLicenseService {
struct HttpRequest {
std::string payload;
std::string url;
std::string reply;
curl_slist *headers = nullptr;
};
/*********************
HttpClient class
*/
class HttpClient
{
public:
explicit HttpClient(const std::string &serverUrl);
~HttpClient() {}
int sendAndReceive(std::string &reply, const std::string &payload,
const std::string &accessPoint, const std::string &server,
const std::string &authKey="");
private:
std::string m_serverUrl;
std::string m_userAgent = "License daemon / ";
int doRequest(CURL *curl, HttpRequest &request);
};
} // namespace QLicenseService
|