Skip to content

Example WEB‐client

ANYKS edited this page Sep 1, 2025 · 3 revisions
#include <awh/client/awh.hpp>

using namespace awh;

int32_t main(int32_t argc, char * argv[]){
	fmk_t fmk{};
	log_t log(&fmk);
	uri_t uri(&fmk, &log);

	client::core_t core(&fmk, &log);
	client::awh_t awh(&core, &fmk, &log);

	core.proto(awh::engine_t::proto_t::HTTP2);
	// core.proto(awh::engine_t::proto_t::HTTP1_1);

	log.name("WEB Client");
	log.format("%H:%M:%S %d.%m.%Y");

	awh.mode({
		client::web_t::flag_t::NOT_INFO,
		client::web_t::flag_t::REDIRECTS,
		client::web_t::flag_t::CONNECT_METHOD_ENABLE
	});

	node_t::ssl_t ssl;
	ssl.verify = true;
	ssl.ca     = "./certs/ca.pem";
	// ssl.key  = "./certs/certificates/client-key.pem";
	// ssl.cert = "./certs/certificates/client-cert.pem";
	core.ssl(ssl);

	// awh.user("user", "password");
	// awh.authType(auth_t::type_t::BASIC);
	// awh.authType(auth_t::type_t::DIGEST, auth_t::hash_t::MD5);

	// awh.proxy("http://user:[email protected]:port");
	// awh.proxy("https://user:[email protected]:port");
	// awh.proxy("socks5://user:[email protected]:port");

	// awh.proxy(client::scheme_t::work_t::ALLOW);
	// awh.proxy(client::scheme_t::work_t::DISALLOW);

	// awh.authTypeProxy(auth_t::type_t::BASIC);
	// awh.authTypeProxy(auth_t::type_t::DIGEST, auth_t::hash_t::MD5);

	/*
	awh.compressors({
		http_t::compressor_t::ZSTD,
		http_t::compressor_t::BROTLI,
		http_t::compressor_t::GZIP,
		http_t::compressor_t::DEFLATE
	});
	*/

	uri_t::url_t url = uri.parse("https://apple.com/ru/mac");

	const auto & body = awh.GET(url);
	
	if(!body.empty())
		cout << "RESPONSE: " << string(body.begin(), body.end()) << endl;

	return EXIT_SUCCESS;
}
Clone this wiki locally