MCPcopy Create free account
hub / github.com/CalcProgrammer1/OpenRGB / connect_with_proxy

Method connect_with_proxy

dependencies/httplib/httplib.h:7488–7543  ·  view source on GitHub ↗

Assumes that socket_mutex_ is locked and that there are no requests in flight

Source from the content-addressed store, hash-verified

7486
7487// Assumes that socket_mutex_ is locked and that there are no requests in flight
7488inline bool SSLClient::connect_with_proxy(Socket &socket, Response &res,
7489 bool &success, Error &error) {
7490 success = true;
7491 Response res2;
7492 if (!detail::process_client_socket(
7493 socket.sock, read_timeout_sec_, read_timeout_usec_,
7494 write_timeout_sec_, write_timeout_usec_, [&](Stream &strm) {
7495 Request req2;
7496 req2.method = "CONNECT";
7497 req2.path = host_and_port_;
7498 return process_request(strm, req2, res2, false, error);
7499 })) {
7500 // Thread-safe to close everything because we are assuming there are no
7501 // requests in flight
7502 shutdown_ssl(socket, true);
7503 shutdown_socket(socket);
7504 close_socket(socket);
7505 success = false;
7506 return false;
7507 }
7508
7509 if (res2.status == 407) {
7510 if (!proxy_digest_auth_username_.empty() &&
7511 !proxy_digest_auth_password_.empty()) {
7512 std::map<std::string, std::string> auth;
7513 if (detail::parse_www_authenticate(res2, auth, true)) {
7514 Response res3;
7515 if (!detail::process_client_socket(
7516 socket.sock, read_timeout_sec_, read_timeout_usec_,
7517 write_timeout_sec_, write_timeout_usec_, [&](Stream &strm) {
7518 Request req3;
7519 req3.method = "CONNECT";
7520 req3.path = host_and_port_;
7521 req3.headers.insert(detail::make_digest_authentication_header(
7522 req3, auth, 1, detail::random_string(10),
7523 proxy_digest_auth_username_, proxy_digest_auth_password_,
7524 true));
7525 return process_request(strm, req3, res3, false, error);
7526 })) {
7527 // Thread-safe to close everything because we are assuming there are
7528 // no requests in flight
7529 shutdown_ssl(socket, true);
7530 shutdown_socket(socket);
7531 close_socket(socket);
7532 success = false;
7533 return false;
7534 }
7535 }
7536 } else {
7537 res = res2;
7538 return false;
7539 }
7540 }
7541
7542 return true;
7543}
7544
7545inline bool SSLClient::load_certs() {

Callers 1

sendMethod · 0.80

Calls 8

process_client_socketFunction · 0.85
shutdown_socketFunction · 0.85
close_socketFunction · 0.85
parse_www_authenticateFunction · 0.85
random_stringFunction · 0.85
emptyMethod · 0.45
insertMethod · 0.45

Tested by

no test coverage detected