Skip to content

HTTP(S)ClientEx not working -> SendGetRequest #102

@or75

Description

@or75
#include <Windows.h>
#include <iostream>

#include "Include/server/http/https_client.h"
#include "Include/CppCommon/include/string/string_utils.h"

#pragma comment(lib, "cppserver.lib")
#pragma comment(lib, "libcrypto.lib")
#pragma comment(lib, "libssl.lib")
#pragma comment(lib, "asio.lib")
#pragma comment(lib, "fmt.lib")
#pragma comment(lib, "cppcommon.lib")
#pragma comment(lib, "Crypt32.lib")
#pragma comment(lib, "Rpcrt4.lib")

int main( int argc , char** argv )
{
	auto service = std::make_shared<CppServer::Asio::Service>();

	std::cout << "Asio service starting...";
	service->Start();
	std::cout << "Done!" << std::endl;

	auto context = std::make_shared<CppServer::Asio::SSLContext>( asio::ssl::context::tlsv11_client );

	context->set_default_verify_paths();
	context->set_root_certs();

	context->set_verify_mode( asio::ssl::verify_none );

	CppServer::HTTP::HTTPResponse testResponse;

	try
	{
		auto client = std::make_shared<CppServer::HTTP::HTTPSClientEx>( service , context , "github.com" , "https" );

		testResponse = client->SendGetRequest( "/" , CppCommon::Timespan::seconds( 5 ) ).get();

		std::cout << testResponse.string().c_str() << std::endl;
	}
	catch ( const std::exception& ex )
	{
		std::cout << "exception: " << ex.what() << std::endl;
	}

	std::cout << "testResponse" << std::endl;

	// Stop the Asio service
	std::cout << "Asio service stopping...";
	service->Stop();
	std::cout << "Done!" << std::endl;

	system( "pause" );
	return 0;
}

no response wtf:

Image

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions