Doesn't build.
This commit is contained in:
@ -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 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_server_remove(Server_t *srv);
|
||||||
static void Http_connect_socket(ChainLink *Info);
|
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_send_query(SocketData_t *S);
|
||||||
static void Http_socket_free(int SKey);
|
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) );
|
SocketData_t *S = reinterpret_cast< SocketData_t * >( a_Klist_get_data(ValidSocks, SKey) );
|
||||||
|
|
||||||
if (S->flags & HTTP_SOCKET_USE_PROXY) {
|
if (S->flags & HTTP_SOCKET_USE_PROXY) {
|
||||||
char *connect_str = Http_get_connect_str(S->url);
|
auto connect_str = Http_get_connect_str(S->url);
|
||||||
DataBuf *dbuf = a_Chain_dbuf_new(connect_str, strlen(connect_str), 0);
|
DataBuf *dbuf = a_Chain_dbuf_new(connect_str.data(), connect_str.size(), 0);
|
||||||
|
|
||||||
MSG_BW(S->web, 1, "Tunnel secure connection through proxy...");
|
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" ) ));
|
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);
|
a_Chain_bcb(OpSend, info, dbuf, NULL);
|
||||||
|
|
||||||
dFree(dbuf);
|
dFree(dbuf);
|
||||||
dFree(connect_str);
|
|
||||||
} else {
|
} else {
|
||||||
MSG_BW(S->web, 1, "Secure connection negotiation...");
|
MSG_BW(S->web, 1, "Secure connection negotiation...");
|
||||||
a_Tls_connect(S->SockFD, S->url);
|
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.
|
* 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;
|
const char *auth1;
|
||||||
int auth_len;
|
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);
|
dReturn_val_if_fail(Http_must_use_proxy(URL_HOST(url)), NULL);
|
||||||
|
|
||||||
dstr = dStr_new("");
|
|
||||||
auth1 = URL_AUTHORITY(url);
|
auth1 = URL_AUTHORITY(url);
|
||||||
auth_len = strlen(auth1);
|
auth_len = strlen(auth1);
|
||||||
if (auth_len > 0 && !isdigit(auth1[auth_len - 1]))
|
if (auth_len > 0 && !isdigit(auth1[auth_len - 1]))
|
||||||
/* if no port number, add HTTPS port */
|
/* if no port number, add HTTPS port */
|
||||||
auth2 = dStrconcat(auth1, ":443", NULL);
|
auth2 = auth1 + ":443"s;
|
||||||
else
|
else
|
||||||
auth2 = dStrdup(auth1);
|
auth2 = auth1;
|
||||||
proxy_auth = HTTP_Proxy_Auth_base64 ?
|
if (HTTP_Proxy_Auth_base64)
|
||||||
dStrconcat ("Proxy-Authorization: Basic ",
|
proxy_auth = "Proxy-Authorization: Basic "s +
|
||||||
HTTP_Proxy_Auth_base64, "\r\n", NULL) :
|
HTTP_Proxy_Auth_base64 + "\r\n";
|
||||||
dStrdup("");
|
dstr+= "CONNECT " + auth2 + " HTTP/1.1\r\n"
|
||||||
dStr_sprintfa(
|
+ "Host: " + auth2 + " \r\n"
|
||||||
dstr,
|
+ proxy_auth
|
||||||
"CONNECT %s HTTP/1.1\r\n"
|
+ "\r\n";
|
||||||
"Host: %s\r\n"
|
|
||||||
"%s"
|
|
||||||
"\r\n",
|
|
||||||
auth2,
|
|
||||||
auth2,
|
|
||||||
proxy_auth);
|
|
||||||
|
|
||||||
dFree(auth2);
|
return dstr;
|
||||||
dFree(proxy_auth);
|
|
||||||
retstr = dstr->str;
|
|
||||||
dStr_free(dstr, 0);
|
|
||||||
return retstr;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -784,7 +774,6 @@ static void Http_dns_cb(int Status, Dlist *addr_list, void *data)
|
|||||||
static int Http_get(ChainLink *Info, void *Data1)
|
static int Http_get(ChainLink *Info, void *Data1)
|
||||||
{
|
{
|
||||||
SocketData_t *S;
|
SocketData_t *S;
|
||||||
char *hostname;
|
|
||||||
const DilloUrl *url;
|
const DilloUrl *url;
|
||||||
|
|
||||||
S = reinterpret_cast< SocketData_t * >( a_Klist_get_data(ValidSocks, VOIDP2INT(Info->LocalKey)) );
|
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 {
|
} else {
|
||||||
url = S->web->url;
|
url = S->web->url;
|
||||||
}
|
}
|
||||||
hostname = dStrdup(URL_HOST(url));
|
std::string hostname = URL_HOST(url);
|
||||||
S->connect_port = URL_PORT(url);
|
S->connect_port = URL_PORT(url);
|
||||||
S->url = a_Url_dup(S->web->url).release();
|
S->url = a_Url_dup(S->web->url).release();
|
||||||
if (!dStrAsciiCasecmp(URL_SCHEME(S->url), "https"))
|
if (!dStrAsciiCasecmp(URL_SCHEME(S->url), "https"))
|
||||||
S->flags |= HTTP_SOCKET_TLS;
|
S->flags |= HTTP_SOCKET_TLS;
|
||||||
|
|
||||||
/* Let the user know what we'll do */
|
/* 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,
|
/* Let the DNS engine resolve the hostname, and when done,
|
||||||
* we'll try to connect the socket from the callback function */
|
* 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;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user