Sese Framework
3.0.0
A cross-platform framework
Loading...
Searching...
No Matches
HttpClient.h
Go to the documentation of this file.
1
// Copyright 2024 libsese
2
//
3
// Licensed under the Apache License, Version 2.0 (the "License");
4
// you may not use this file except in compliance with the License.
5
// You may obtain a copy of the License at
6
//
7
// http://www.apache.org/licenses/LICENSE-2.0
8
//
9
// Unless required by applicable law or agreed to in writing, software
10
// distributed under the License is distributed on an "AS IS" BASIS,
11
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
// See the License for the specific language governing permissions and
13
// limitations under the License.
14
19
20
#pragma once
21
22
#include <
sese/net/http/Request.h
>
23
#include <
sese/net/http/Response.h
>
24
#include <
sese/io/PeekableStream.h
>
25
#include <
sese/io/OutputStream.h
>
26
27
#include <functional>
28
29
namespace
sese::net::http
{
31
class
HttpClient
{
32
public
:
33
using
WriteCallback
= std::function<int64_t(
const
void
*,
size_t
)>;
34
using
ReadCallback
= std::function<int64_t(
void
*,
size_t
)>;
35
using
Ptr
= std::unique_ptr<HttpClient>;
36
41
static
Ptr
create
(
const
std::string &url,
const
std::string &proxy =
""
);
42
43
~HttpClient
();
44
47
bool
request
()
const
;
48
51
int
getLastError
()
const
;
52
55
std::string
getLastErrorString
()
const
;
56
57
int64_t
read
(
void
*buf,
size_t
len)
const
;
58
59
int64_t
write
(
const
void
*buf,
size_t
len)
const
;
60
63
Request::Ptr
&
getRequest
()
const
;
64
67
Response::Ptr
&
getResponse
()
const
;
68
72
void
setReadData
(
io::PeekableStream
*read_data,
size_t
expect_total)
const
;
73
76
void
setWriteData
(
io::OutputStream
*write_data)
const
;
77
81
void
setReadCallback
(
const
ReadCallback
&read_callback,
size_t
expect_total)
const
;
82
85
void
setWriteCallback
(
const
WriteCallback
&write_callback)
const
;
86
87
private
:
88
HttpClient
() =
default
;
89
90
class
Impl
;
91
class
SSLImpl
;
92
std::unique_ptr<Impl>
impl
;
93
};
94
}
// namespace sese::net::http
sese
net
http
HttpClient.h
Generated on Sun Feb 2 2025 15:46:44 for Sese Framework by
1.11.0