libfilezilla
0.59.0
A cross-platform C++ library for asynchronous and networked applications
Toggle main menu visibility
Loading...
Searching...
No Matches
lib
libfilezilla
http
client_response.hpp
Go to the documentation of this file.
1
#ifndef LIBFILEZILLA_HTTP_CLIENT_RESPONSE_HEADER
2
#define LIBFILEZILLA_HTTP_CLIENT_RESPONSE_HEADER
3
7
8
#include "
headers.hpp
"
9
#include "
../aio/writer.hpp
"
10
#include "
../buffer.hpp
"
11
12
namespace
fz::http::client {
13
14
class
request_response_interface
;
15
typedef
std::shared_ptr<request_response_interface> shared_request_response;
16
21
class
FZ_PUBLIC_SYMBOL
response
:
public
with_headers
22
{
23
public
:
24
unsigned
int
code_{};
25
std::string reason_;
26
27
enum
flags :
unsigned
{
28
flag_got_code = 0x01,
29
flag_got_header = 0x02,
30
flag_got_body = 0x04,
31
flag_no_body = 0x08,
// e.g. on HEAD requests, or 204/304 responses
32
};
33
unsigned
int
flags_{};
34
35
bool
got_code()
const
{
return
flags_ & flag_got_code; }
36
bool
got_header()
const
{
return
flags_ & flag_got_header; }
37
bool
got_body()
const
{
return
(flags_ & (flag_got_body | flag_no_body)) == flag_got_body; }
38
bool
no_body()
const
{
return
flags_ & flag_no_body; }
39
51
std::function<continuation(std::shared_ptr<request_response_interface>
const
&)>
on_header_
;
52
54
std::unique_ptr<fz::writer_base>
writer_
;
55
57
fz::buffer
body_
;
58
60
size_t
max_body_size_
{16 * 1024 * 1024};
61
62
bool
success()
const
{
63
return
code_ >= 200 && code_ < 300;
64
}
65
66
bool
is_redirect()
const
{
67
return
code_ >= 300 && code_ < 400 && code_ != 304 && code_ != 305 && code_ != 306;
68
}
69
71
bool
code_prohobits_body
()
const
{
72
return
(code_ >= 100 && code_ < 200) || code_ == 304 || code_ == 204;
73
}
74
75
virtual
bool
reset();
76
};
77
}
78
79
#endif
buffer.hpp
Declares fz::buffer.
fz::buffer
Definition
buffer.hpp:360
fz::http::client::request_response_interface
Used for type erasure, so the internals don't need to know the full request/response.
Definition
client.hpp:24
fz::http::client::response
A single HTTP response received by the client.
Definition
client_response.hpp:22
fz::http::client::response::max_body_size_
size_t max_body_size_
Only if body_ is used. Has no effect if writers are used.
Definition
client_response.hpp:60
fz::http::client::response::body_
fz::buffer body_
Holds error body and success body if there is no writer.
Definition
client_response.hpp:57
fz::http::client::response::writer_
std::unique_ptr< fz::writer_base > writer_
Writer isn't used if !success(), failure responses always go into body_.
Definition
client_response.hpp:54
fz::http::client::response::on_header_
std::function< continuation(std::shared_ptr< request_response_interface > const &)> on_header_
Called once the complete header has been received.
Definition
client_response.hpp:51
fz::http::client::response::code_prohobits_body
bool code_prohobits_body() const
Some HTTP responses cannot possibly have a body.
Definition
client_response.hpp:71
fz::http::with_headers
Definition
headers.hpp:30
headers.hpp
Declares fz::with_headers as base for HTTP requests/responses.
writer.hpp
Classes for writing data asynchronously into files.
Generated by
1.18.0