1#ifndef LIBFILEZILLA_HTTP_CLIENT_RESPONSE_HEADER
2#define LIBFILEZILLA_HTTP_CLIENT_RESPONSE_HEADER
12namespace fz::http::client {
15typedef std::shared_ptr<request_response_interface> shared_request_response;
27 enum flags :
unsigned {
29 flag_got_header = 0x02,
33 unsigned int flags_{};
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; }
51 std::function<continuation(std::shared_ptr<request_response_interface>
const&)>
on_header_;
62 bool success()
const {
63 return code_ >= 200 && code_ < 300;
66 bool is_redirect()
const {
67 return code_ >= 300 && code_ < 400 && code_ != 304 && code_ != 305 && code_ != 306;
72 return (code_ >= 100 && code_ < 200) || code_ == 304 || code_ == 204;
Definition buffer.hpp:360
Used for type erasure, so the internals don't need to know the full request/response.
Definition client.hpp:24
A single HTTP response received by the client.
Definition client_response.hpp:22
size_t max_body_size_
Only if body_ is used. Has no effect if writers are used.
Definition client_response.hpp:60
fz::buffer body_
Holds error body and success body if there is no writer.
Definition client_response.hpp:57
std::unique_ptr< fz::writer_base > writer_
Writer isn't used if !success(), failure responses always go into body_.
Definition client_response.hpp:54
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
bool code_prohobits_body() const
Some HTTP responses cannot possibly have a body.
Definition client_response.hpp:71
Classes for writing data asynchronously into files.