From: alex Date: Mon, 8 Jan 2001 06:06:06 +0000 (+0000) Subject: make ssl work. pass the ssl iochannel to the underlying iochannel's X-Git-Tag: SOUP_0_4_1~157 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=ee93b12371e5c5277900eb38a9133dcddcb2bb8b;p=platform%2Fupstream%2Flibsoup.git make ssl work. pass the ssl iochannel to the underlying iochannel's * soup-ssl.c (soup_ssl_add_watch): make ssl work. pass the ssl iochannel to the underlying iochannel's funcs->io_add_watch, so that our ssl functions get called. this is a hack. this will need to be fixed in order to get windows portability, as the SoupSSLChannel struct is mimicing GIOUnixChannel so the add_watch will work correctly. * soup-queue.c (soup_queue_read_async): fix bug when searching for end of http headers where req->priv->header_len was being set whether the end was found or not. --- diff --git a/libsoup/soup-queue.c b/libsoup/soup-queue.c index cc22447..b0f69d3 100644 --- a/libsoup/soup-queue.c +++ b/libsoup/soup-queue.c @@ -272,7 +272,7 @@ soup_queue_read_async (GIOChannel* iochannel, SoupMessage *req) { gchar read_buf [RESPONSE_BLOCK_SIZE]; - guint bytes_read = 0; + gint bytes_read = 0; gboolean read_done = FALSE; gint index = req->priv->header_len; GByteArray *arr = req->priv->recv_buf; @@ -296,9 +296,9 @@ soup_queue_read_async (GIOChannel* iochannel, if (bytes_read) g_byte_array_append (arr, read_buf, bytes_read); if (!index) { - index = req->priv->header_len = - soup_substring_index (arr->data, arr->len, "\r\n\r\n"); - if (!index) return TRUE; + index = soup_substring_index (arr->data, arr->len, "\r\n\r\n"); + if (index < 0) return TRUE; + req->priv->header_len = index; if (!soup_parse_headers (req) || !soup_process_headers (req)) return FALSE; } diff --git a/libsoup/soup-ssl.c b/libsoup/soup-ssl.c index 042753b..b6f9e72 100644 --- a/libsoup/soup-ssl.c +++ b/libsoup/soup-ssl.c @@ -48,6 +48,7 @@ GIOFuncs soup_ssl_channel_funcs = { typedef struct { GIOChannel channel; + gint fd; GIOChannel *real_sock; SSL *ssl; } SoupSSLChannel; @@ -118,6 +119,7 @@ soup_get_ssl_iochannel (GIOChannel *sock) X509_free (cert); chan = g_new0 (SoupSSLChannel, 1); + chan->fd = sockfd; chan->real_sock = sock; chan->ssl = ssl; g_io_channel_ref (sock); @@ -136,14 +138,15 @@ static GIOError soup_ssl_read (GIOChannel *channel, gchar *buf, guint count, - guint *bytes_written) + guint *bytes_read) { SoupSSLChannel *chan = (SoupSSLChannel *) channel; + gint result; - *bytes_written = SSL_read (chan->ssl, buf, count); + result = SSL_read (chan->ssl, buf, count); - if (*bytes_written < 0) { - *bytes_written = 0; + if (result < 0) { + *bytes_read = 0; switch (errno) { case EINVAL: return G_IO_ERROR_INVAL; @@ -153,8 +156,10 @@ soup_ssl_read (GIOChannel *channel, default: return G_IO_ERROR_UNKNOWN; } - } else + } else { + *bytes_read = result; return G_IO_ERROR_NONE; + } } static GIOError @@ -164,10 +169,11 @@ soup_ssl_write (GIOChannel *channel, guint *bytes_written) { SoupSSLChannel *chan = (SoupSSLChannel *) channel; + gint result; - *bytes_written = SSL_write (chan->ssl, buf, count); + result = SSL_write (chan->ssl, buf, count); - if (*bytes_written < 0) { + if (result < 0) { *bytes_written = 0; switch (errno) { case EINVAL: @@ -178,8 +184,10 @@ soup_ssl_write (GIOChannel *channel, default: return G_IO_ERROR_UNKNOWN; } - } else + } else { + *bytes_written = result; return G_IO_ERROR_NONE; + } } static GIOError @@ -214,11 +222,11 @@ soup_ssl_add_watch (GIOChannel *channel, GDestroyNotify notify) { SoupSSLChannel *chan = (SoupSSLChannel *) channel; - return g_io_add_watch_full (chan->real_sock, - priority, - condition, - func, - user_data, - notify); + return chan->real_sock->funcs->io_add_watch (channel, + priority, + condition, + func, + user_data, + notify); }