Doesn't build.

This commit is contained in:
2025-04-24 01:29:30 -04:00
parent aec0331924
commit 8c127d1c43

View File

@ -93,7 +93,7 @@ static void Http_socket_enqueue(Server_t *srv, SocketData_t* sock);
static Server_t *Http_server_get(const char *host, uint_t port, bool_t https);
static void Http_server_remove(Server_t *srv);
static void Http_connect_socket(ChainLink *Info);
static char *Http_get_connect_str(const DilloUrl *url);
static std::string Http_get_connect_str(const DilloUrl *url);
static void Http_send_query(SocketData_t *S);
static void Http_socket_free(int SKey);
@ -507,8 +507,8 @@ static void Http_connect_tls(ChainLink *info)
SocketData_t *S = reinterpret_cast< SocketData_t * >( a_Klist_get_data(ValidSocks, SKey) );
if (S->flags & HTTP_SOCKET_USE_PROXY) {
char *connect_str = Http_get_connect_str(S->url);
DataBuf *dbuf = a_Chain_dbuf_new(connect_str, strlen(connect_str), 0);
auto connect_str = Http_get_connect_str(S->url);
DataBuf *dbuf = a_Chain_dbuf_new(connect_str.data(), connect_str.size(), 0);
MSG_BW(S->web, 1, "Tunnel secure connection through proxy...");
a_Chain_bfcb(OpSend, info, &S->SockFD, const_cast< void * >( static_cast< const void * >( "FD" ) ));
@ -516,7 +516,6 @@ static void Http_connect_tls(ChainLink *info)
a_Chain_bcb(OpSend, info, dbuf, NULL);
dFree(dbuf);
dFree(connect_str);
} else {
MSG_BW(S->web, 1, "Secure connection negotiation...");
a_Tls_connect(S->SockFD, S->url);
@ -694,42 +693,33 @@ static int Http_must_use_proxy(const char *hostname)
/**
* Return a new string for the request used to tunnel HTTPS through a proxy.
*/
static char *Http_get_connect_str(const DilloUrl *url)
static std::string Http_get_connect_str(const DilloUrl *url)
{
Dstr *dstr;
const char *auth1;
int auth_len;
char *auth2, *proxy_auth, *retstr;
std::string auth2;
std::string proxy_auth;
std::string dstr;
using namespace std::literals::string_literals;
dReturn_val_if_fail(Http_must_use_proxy(URL_HOST(url)), NULL);
dstr = dStr_new("");
auth1 = URL_AUTHORITY(url);
auth_len = strlen(auth1);
if (auth_len > 0 && !isdigit(auth1[auth_len - 1]))
/* if no port number, add HTTPS port */
auth2 = dStrconcat(auth1, ":443", NULL);
auth2 = auth1 + ":443"s;
else
auth2 = dStrdup(auth1);
proxy_auth = HTTP_Proxy_Auth_base64 ?
dStrconcat ("Proxy-Authorization: Basic ",
HTTP_Proxy_Auth_base64, "\r\n", NULL) :
dStrdup("");
dStr_sprintfa(
dstr,
"CONNECT %s HTTP/1.1\r\n"
"Host: %s\r\n"
"%s"
"\r\n",
auth2,
auth2,
proxy_auth);
auth2 = auth1;
if (HTTP_Proxy_Auth_base64)
proxy_auth = "Proxy-Authorization: Basic "s +
HTTP_Proxy_Auth_base64 + "\r\n";
dstr+= "CONNECT " + auth2 + " HTTP/1.1\r\n"
+ "Host: " + auth2 + " \r\n"
+ proxy_auth
+ "\r\n";
dFree(auth2);
dFree(proxy_auth);
retstr = dstr->str;
dStr_free(dstr, 0);
return retstr;
return dstr;
}
/**
@ -784,7 +774,6 @@ static void Http_dns_cb(int Status, Dlist *addr_list, void *data)
static int Http_get(ChainLink *Info, void *Data1)
{
SocketData_t *S;
char *hostname;
const DilloUrl *url;
S = reinterpret_cast< SocketData_t * >( a_Klist_get_data(ValidSocks, VOIDP2INT(Info->LocalKey)) );
@ -800,20 +789,19 @@ static int Http_get(ChainLink *Info, void *Data1)
} else {
url = S->web->url;
}
hostname = dStrdup(URL_HOST(url));
std::string hostname = URL_HOST(url);
S->connect_port = URL_PORT(url);
S->url = a_Url_dup(S->web->url).release();
if (!dStrAsciiCasecmp(URL_SCHEME(S->url), "https"))
S->flags |= HTTP_SOCKET_TLS;
/* Let the user know what we'll do */
MSG_BW(S->web, 1, "DNS resolving %s", hostname);
MSG_BW(S->web, 1, "DNS resolving %s", hostname.c_str());
/* Let the DNS engine resolve the hostname, and when done,
* we'll try to connect the socket from the callback function */
a_Dns_resolve(hostname, Http_dns_cb, Info->LocalKey);
a_Dns_resolve(hostname.c_str(), Http_dns_cb, Info->LocalKey);
dFree(hostname);
return 0;
}