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;
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;
}
typedef struct {
GIOChannel channel;
+ gint fd;
GIOChannel *real_sock;
SSL *ssl;
} SoupSSLChannel;
X509_free (cert);
chan = g_new0 (SoupSSLChannel, 1);
+ chan->fd = sockfd;
chan->real_sock = sock;
chan->ssl = ssl;
g_io_channel_ref (sock);
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;
default:
return G_IO_ERROR_UNKNOWN;
}
- } else
+ } else {
+ *bytes_read = result;
return G_IO_ERROR_NONE;
+ }
}
static GIOError
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:
default:
return G_IO_ERROR_UNKNOWN;
}
- } else
+ } else {
+ *bytes_written = result;
return G_IO_ERROR_NONE;
+ }
}
static GIOError
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);
}