From 340ada63936ed3164cd82fb989b7797210179cc6 Mon Sep 17 00:00:00 2001 From: Lars-Dominik Braun Date: Sun, 13 Nov 2011 16:28:50 +0100 Subject: waitress: Don’t use OrdinaryRead/Write directly MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/libwaitress/waitress.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/libwaitress/waitress.c b/src/libwaitress/waitress.c index 195f66f..13388c4 100644 --- a/src/libwaitress/waitress.c +++ b/src/libwaitress/waitress.c @@ -806,17 +806,17 @@ static WaitressReturn_t WaitressConnect (WaitressHandle_t *waith) { snprintf (buf, sizeof (buf), "CONNECT %s:%s HTTP/" WAITRESS_HTTP_VERSION "\r\n", waith->url.host, WaitressDefaultPort (&waith->url)); - WaitressOrdinaryWrite (waith, buf, strlen (buf)); + waith->request.write (waith, buf, strlen (buf)); /* write authorization headers */ if (WaitressFormatAuthorization (waith, &waith->proxy, "Proxy-", buf, WAITRESS_BUFFER_SIZE)) { - WaitressOrdinaryWrite (waith, buf, strlen (buf)); + waith->request.write (waith, buf, strlen (buf)); } - WaitressOrdinaryWrite (waith, "\r\n", 2); + waith->request.write (waith, "\r\n", 2); - WaitressOrdinaryRead (waith, buf, sizeof (buf)-1, &size); + waith->request.read (waith, buf, sizeof (buf)-1, &size); buf[size] = 0; if (WaitressParseStatusline (buf) != 200) { return WAITRESS_RET_CONNECT_REFUSED; @@ -830,6 +830,10 @@ static WaitressReturn_t WaitressConnect (WaitressHandle_t *waith) { if (WaitressTlsVerify (waith) != 0) { return WAITRESS_RET_TLS_HANDSHAKE_ERR; } + + /* now we can talk encrypted */ + waith->request.read = WaitressGnutlsRead; + waith->request.write = WaitressGnutlsWrite; } return WAITRESS_RET_OK; @@ -1043,9 +1047,6 @@ WaitressReturn_t WaitressFetchCall (WaitressHandle_t *waith) { waith->request.write = WaitressOrdinaryWrite; if (waith->url.tls) { - waith->request.read = WaitressGnutlsRead; - waith->request.write = WaitressGnutlsWrite; - gnutls_init (&waith->request.tlsSession, GNUTLS_CLIENT); gnutls_set_default_priority (waith->request.tlsSession); -- cgit v1.2.3