summaryrefslogtreecommitdiff
path: root/src/libwaitress
diff options
context:
space:
mode:
authorLars-Dominik Braun <lars@6xq.net>2011-11-13 16:28:50 +0100
committerLars-Dominik Braun <lars@6xq.net>2011-11-13 16:28:50 +0100
commit340ada63936ed3164cd82fb989b7797210179cc6 (patch)
tree11c06131aa2ba14b6c10b709e117a0dabc8114cb /src/libwaitress
parente57457361c2ea9038e1b81e8cd28c1a1237d6fb9 (diff)
downloadpianobar-340ada63936ed3164cd82fb989b7797210179cc6.tar.gz
pianobar-340ada63936ed3164cd82fb989b7797210179cc6.tar.bz2
pianobar-340ada63936ed3164cd82fb989b7797210179cc6.zip
waitress: Don’t use OrdinaryRead/Write directly
Diffstat (limited to 'src/libwaitress')
-rw-r--r--src/libwaitress/waitress.c15
1 files 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);