summaryrefslogtreecommitdiff
path: root/src/libwaitress
diff options
context:
space:
mode:
Diffstat (limited to 'src/libwaitress')
-rw-r--r--src/libwaitress/waitress.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/src/libwaitress/waitress.c b/src/libwaitress/waitress.c
index 1a6d4cd..d4081ef 100644
--- a/src/libwaitress/waitress.c
+++ b/src/libwaitress/waitress.c
@@ -815,6 +815,21 @@ static WaitressReturn_t WaitressConnect (WaitressHandle_t *waith) {
#ifdef ENABLE_TLS
if (waith->url.tls) {
+ /* set up proxy tunnel */
+ if (WaitressProxyEnabled (waith)) {
+ char buf[256];
+ size_t size;
+ snprintf (buf, sizeof (buf), "CONNECT %s:%s HTTP/1.1\r\n\r\n",
+ waith->url.host, WaitressDefaultPort (&waith->url));
+ WaitressOrdinaryWrite (waith, buf, strlen (buf));
+
+ WaitressOrdinaryRead (waith, buf, sizeof (buf)-1, &size);
+ buf[size] = 0;
+ if (WaitressParseStatusline (buf) != 200) {
+ return WAITRESS_RET_CONNECT_REFUSED;
+ }
+ }
+
if (gnutls_handshake (waith->request.tlsSession) != GNUTLS_E_SUCCESS) {
return WAITRESS_RET_TLS_HANDSHAKE_ERR;
}