This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
namespace http = network::http; | |
http::client_options options; | |
options.follow_redirects(true) | |
.accept_encoding({"*/*"}) | |
.version(http::version::http_1_1) | |
.proxy("localhost:8080") | |
.idle_timeout(30); | |
http::client client{options}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
namespace http = network::http; | |
http::request_options ro; | |
ro.timeout(std::chrono::duration(30)) | |
.client_cert("/tmp/my_cert.pem") | |
.accept_transfer_encoding({http::transfer_encodings::gzip, http::transfer_encodings::plain}); | |
auto response = client.get("https://www.example.com/foo", ro); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
namespace http = network::http; | |
http::client client; | |
auto response = client.get("https://www.example.com/foo"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
namespace http = network::http; | |
http::server server_; | |
server_.register_handler( | |
"/hello", [](session& s, std::shared_ptr<connection> c) { | |
c->response().write(s["user"].empty()? string("world!") : s["user"]); | |
}); | |
server_.register_handler( | |
"/echo", [](session& s, std::shared_ptr<connection> c) { | |
if (c->method() != http::server::POST) { | |
c->response().write("echo!"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
namespace http = network::http; | |
std::future<http::response> response_future = | |
client.get("http://www.google.com/"); // returns immediately | |
http::response actual_response = | |
response_future.get(); // will move instead of copy |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
namespace http = network::http; | |
namespace util = network::util; | |
http::client client; | |
auto fr = client.get( | |
{"https://www.myservice.com/", | |
util::gzip_encode(new file_byte_source{"/tmp/data"})} | |
); // we're gzip encoding the request body | |
auto r = fr.get(); | |
std::string data = r.read(getpagesize()).get(); | |
while (!data.empty()) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
class Object { | |
std::string type_name; | |
protected: | |
explicit Object(std::string const& type_name) : type_name{type_name} {} | |
public: | |
Object() : type_name{"Object"} {} | |
Object(Object const &other) : type_name{other.type_name} {} | |
virtual void print() { std::cout << type_name; } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
class Book { | |
std::string author, title; | |
public: | |
Book(std::string const &author, std::string const &title) | |
: author{author}, title{title} | |
{} | |
Book(Book const &other) : author{other.author}, title{other.title} {} | |
Book() : author{}, title{} {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <memory> | |
#include <vector> | |
#include <utility> | |
/* Same definition of Object, Book, and Door as before */ | |
class object_concept_t { | |
public: | |
virtual ~object_concept_t() = default; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.p2align 4, 0x90 | |
.quad Lxray_synthetic_0 | |
.quad Lxray_fn_idx_synth_0 |
OlderNewer