+2003-09-10 Dan Winship <danw@ximian.com>
+
+ * libsoup/soup-message-private.h (SoupMessagePrivate): Remove the
+ "status" field from here, since it's mostly used by SoupSession,
+ which shouldn't need access to SoupMessagePrivate.
+
+ * libsoup/soup-message.h (SoupMessage): Move it here.
+ (SoupCallbackFn): Remove this alias for SoupMessageCallbackFn.
+ (soup_message_set_uri): also moved from soup-message-private.h
+
+ * libsoup/soup-message.c: s/msg->priv->status/msg->status/.
+
+ * libsoup/soup-message-handlers.c:
+ s/SoupCallbackFn/SoupMessageCallbackFn/ everywhere.
+
+ * libsoup/soup-message-io.c (soup_message_io_client,
+ soup_message_io_server, soup_message_io_unpause): Don't set up an
+ idle handler, just jump right in to reading/writing; if this is a
+ synchronous socket, then the caller wants to block, and if it's
+ not, then we'll quickly get an EAGAIN anyway.
+
+ * libsoup/soup-session.c: (queue_message): Likewise.
+ (*) Update for SoupMessageStatus move and remove
+ soup-message-private.h include.
+
+ * libsoup/soup-server-message.c: Remove soup-message-private.h
+ include.
+
+ * libsoup/soup-server.c: Likewise.
+
+ * libsoup/soup-connection.c (soup_connection_is_connected,
+ soup_connection_is_new): Remove these, since they weren't being
+ used.
+
+ * libsoup/soup-md5-utils.c: Moved from md5-utils.c and renamed, to
+ avoid namespace pollution.
+
+ * libsoup/soup-auth-digest.c: Update for that.
+ * libsoup/soup-server-auth.c: Likewise
+
+ * tests/auth-test.c: Remove soup-message-private.h include
+
2003-09-09 Dan Winship <danw@ximian.com>
Beginnings of improved synchronous API support
libsoup_2_2_la_SOURCES = \
$(MARSHAL_GENERATED) \
- md5-utils.h \
- md5-utils.c \
soup-address.c \
soup-auth.h \
soup-auth.c \
soup-gnutls.h \
soup-gnutls.c \
soup-headers.c \
+ soup-md5-utils.h \
+ soup-md5-utils.c \
soup-message.c \
soup-message-client-io.c \
soup-message-handlers.c \
#include "soup-auth-digest.h"
#include "soup-headers.h"
+#include "soup-md5-utils.h"
#include "soup-message.h"
#include "soup-misc.h"
#include "soup-private.h"
#include "soup-uri.h"
-#include "md5-utils.h"
static void construct (SoupAuth *auth, const char *header);
static GSList *get_protection_space (SoupAuth *auth, const SoupUri *source_uri);
authenticate (SoupAuth *auth, const char *username, const char *password)
{
SoupAuthDigest *digest = SOUP_AUTH_DIGEST (auth);
- MD5Context ctx;
+ SoupMD5Context ctx;
guchar d[16];
char *bgen;
digest->priv->user = g_strdup (username);
/* compute A1 */
- md5_init (&ctx);
+ soup_md5_init (&ctx);
- md5_update (&ctx, username, strlen (username));
+ soup_md5_update (&ctx, username, strlen (username));
- md5_update (&ctx, ":", 1);
- if (digest->priv->realm)
- md5_update (&ctx, digest->priv->realm, strlen (digest->priv->realm));
+ soup_md5_update (&ctx, ":", 1);
+ if (digest->priv->realm) {
+ soup_md5_update (&ctx, digest->priv->realm,
+ strlen (digest->priv->realm));
+ }
- md5_update (&ctx, ":", 1);
+ soup_md5_update (&ctx, ":", 1);
if (password)
- md5_update (&ctx, password, strlen (password));
+ soup_md5_update (&ctx, password, strlen (password));
if (digest->priv->algorithm == ALGORITHM_MD5_SESS) {
- md5_final (&ctx, d);
-
- md5_init (&ctx);
- md5_update (&ctx, d, 16);
- md5_update (&ctx, ":", 1);
- md5_update (&ctx, digest->priv->nonce, strlen (digest->priv->nonce));
- md5_update (&ctx, ":", 1);
- md5_update (&ctx, digest->priv->cnonce, strlen (digest->priv->cnonce));
+ soup_md5_final (&ctx, d);
+
+ soup_md5_init (&ctx);
+ soup_md5_update (&ctx, d, 16);
+ soup_md5_update (&ctx, ":", 1);
+ soup_md5_update (&ctx, digest->priv->nonce,
+ strlen (digest->priv->nonce));
+ soup_md5_update (&ctx, ":", 1);
+ soup_md5_update (&ctx, digest->priv->cnonce,
+ strlen (digest->priv->cnonce));
}
/* hexify A1 */
- md5_final (&ctx, d);
+ soup_md5_final (&ctx, d);
digest_hex (d, digest->priv->hex_a1);
}
{
guchar hex_a2[33], o[33];
guchar d[16];
- MD5Context md5;
+ SoupMD5Context md5;
char *url;
const SoupUri *uri;
url = soup_uri_to_string (uri, TRUE);
/* compute A2 */
- md5_init (&md5);
- md5_update (&md5, msg->method, strlen (msg->method));
- md5_update (&md5, ":", 1);
- md5_update (&md5, url, strlen (url));
+ soup_md5_init (&md5);
+ soup_md5_update (&md5, msg->method, strlen (msg->method));
+ soup_md5_update (&md5, ":", 1);
+ soup_md5_update (&md5, url, strlen (url));
g_free (url);
if (digest->priv->qop == QOP_AUTH_INT) {
/* FIXME: Actually implement. Ugh. */
- md5_update (&md5, ":", 1);
- md5_update (&md5, "00000000000000000000000000000000", 32);
+ soup_md5_update (&md5, ":", 1);
+ soup_md5_update (&md5, "00000000000000000000000000000000", 32);
}
/* now hexify A2 */
- md5_final (&md5, d);
+ soup_md5_final (&md5, d);
digest_hex (d, hex_a2);
/* compute KD */
- md5_init (&md5);
- md5_update (&md5, digest->priv->hex_a1, 32);
- md5_update (&md5, ":", 1);
- md5_update (&md5, digest->priv->nonce, strlen (digest->priv->nonce));
- md5_update (&md5, ":", 1);
+ soup_md5_init (&md5);
+ soup_md5_update (&md5, digest->priv->hex_a1, 32);
+ soup_md5_update (&md5, ":", 1);
+ soup_md5_update (&md5, digest->priv->nonce,
+ strlen (digest->priv->nonce));
+ soup_md5_update (&md5, ":", 1);
if (digest->priv->qop) {
char *tmp;
tmp = g_strdup_printf ("%.8x", digest->priv->nc);
- md5_update (&md5, tmp, strlen (tmp));
+ soup_md5_update (&md5, tmp, strlen (tmp));
g_free (tmp);
- md5_update (&md5, ":", 1);
- md5_update (&md5, digest->priv->cnonce, strlen (digest->priv->cnonce));
- md5_update (&md5, ":", 1);
+ soup_md5_update (&md5, ":", 1);
+ soup_md5_update (&md5, digest->priv->cnonce,
+ strlen (digest->priv->cnonce));
+ soup_md5_update (&md5, ":", 1);
if (digest->priv->qop == QOP_AUTH)
tmp = "auth";
else
g_assert_not_reached ();
- md5_update (&md5, tmp, strlen (tmp));
- md5_update (&md5, ":", 1);
+ soup_md5_update (&md5, tmp, strlen (tmp));
+ soup_md5_update (&md5, ":", 1);
}
- md5_update (&md5, hex_a2, 32);
- md5_final (&md5, d);
+ soup_md5_update (&md5, hex_a2, 32);
+ soup_md5_final (&md5, d);
digest_hex (d, o);
g_signal_emit (conn, signals[DISCONNECTED], 0);
}
-gboolean
-soup_connection_is_connected (SoupConnection *conn)
-{
- g_return_val_if_fail (SOUP_IS_CONNECTION (conn), FALSE);
-
- return conn->priv->socket != NULL;
-}
-
-
/**
* soup_connection_is_in_use:
* @conn: a connection
return conn->priv->last_used;
}
-/**
- * soup_connection_is_new:
- * @conn: a connection
- *
- * Return value: whether or not @conn is "new". (That is, it has not
- * yet completed a whole HTTP transaction.)
- **/
-gboolean
-soup_connection_is_new (SoupConnection *conn)
-{
- g_return_val_if_fail (SOUP_IS_CONNECTION (conn), FALSE);
-
- return conn->priv->last_used == 0;
-}
-
-
static void
request_done (SoupMessage *req, gpointer user_data)
{
guint soup_connection_connect_sync (SoupConnection *conn);
void soup_connection_disconnect (SoupConnection *conn);
-gboolean soup_connection_is_connected (SoupConnection *conn);
-gboolean soup_connection_is_new (SoupConnection *conn);
gboolean soup_connection_is_in_use (SoupConnection *conn);
time_t soup_connection_last_used (SoupConnection *conn);
* with every copy.
*
* To compute the message digest of a chunk of bytes, declare an
- * MD5Context structure, pass it to md5_init, call md5_update as
- * needed on buffers full of bytes, and then call md5_Final, which
+ * SoupMD5Context structure, pass it to soup_md5_init, call soup_md5_update as
+ * needed on buffers full of bytes, and then call soup_md5_Final, which
* will fill a supplied 16-byte array with the digest.
*/
*/
-#include "md5-utils.h"
-#include <stdio.h>
+#include "soup-md5-utils.h"
#include <string.h>
-static void md5_transform (guint32 buf[4], const guint32 in[16]);
-
-static gint _ie = 0x44332211;
-static union _endian { gint i; gchar b[4]; } *_endian = (union _endian *)&_ie;
-#define IS_BIG_ENDIAN() (_endian->b[0] == '\x44')
-#define IS_LITTLE_ENDIAN() (_endian->b[0] == '\x11')
-
+static void soup_md5_transform (guint32 buf[4], const guint32 in[16]);
/*
* Note: this code is harmless on little-endian machines.
*/
static void
-_byte_reverse (guchar *buf, guint32 longs)
+byte_reverse (guchar *buf, guint32 longs)
{
guint32 t;
do {
}
/**
- * md5_init: Initialise an md5 context object
+ * soup_md5_init: Initialise an md5 context object
* @ctx: md5 context
*
* Initialise an md5 buffer.
*
**/
void
-md5_init (MD5Context *ctx)
+soup_md5_init (SoupMD5Context *ctx)
{
ctx->buf[0] = 0x67452301;
ctx->buf[1] = 0xefcdab89;
ctx->bits[0] = 0;
ctx->bits[1] = 0;
- if (IS_BIG_ENDIAN())
- ctx->doByteReverse = 1;
- else
- ctx->doByteReverse = 0;
+ ctx->doByteReverse = (G_BYTE_ORDER == G_BIG_ENDIAN);
}
/**
- * md5_update: add a buffer to md5 hash computation
+ * soup_md5_update: add a buffer to md5 hash computation
* @ctx: conetxt object used for md5 computaion
* @buf: buffer to add
* @len: buffer length
* of bytes. Use this to progressively construct an md5 hash.
**/
void
-md5_update (MD5Context *ctx, const guchar *buf, guint32 len)
+soup_md5_update (SoupMD5Context *ctx, const guchar *buf, guint32 len)
{
guint32 t;
}
memcpy (p, buf, t);
if (ctx->doByteReverse)
- _byte_reverse (ctx->in, 16);
- md5_transform (ctx->buf, (guint32 *) ctx->in);
+ byte_reverse (ctx->in, 16);
+ soup_md5_transform (ctx->buf, (guint32 *) ctx->in);
buf += t;
len -= t;
}
while (len >= 64) {
memcpy (ctx->in, buf, 64);
if (ctx->doByteReverse)
- _byte_reverse (ctx->in, 16);
- md5_transform (ctx->buf, (guint32 *) ctx->in);
+ byte_reverse (ctx->in, 16);
+ soup_md5_transform (ctx->buf, (guint32 *) ctx->in);
buf += 64;
len -= 64;
}
memcpy (ctx->in, buf, len);
}
-
-
-
-
/*
* Final wrapup - pad to 64-byte boundary with the bit pattern
* 1 0* (64-bit count of bits processed, MSB-first)
*/
/**
- * md5_final: copy the final md5 hash to a bufer
+ * soup_md5_final: copy the final md5 hash to a bufer
* @digest: 16 bytes buffer
* @ctx: context containing the calculated md5
*
* copy the final md5 hash to a bufer
**/
void
-md5_final (MD5Context *ctx, guchar digest[16])
+soup_md5_final (SoupMD5Context *ctx, guchar digest[16])
{
guint32 count;
guchar *p;
/* Two lots of padding: Pad the first block to 64 bytes */
memset (p, 0, count);
if (ctx->doByteReverse)
- _byte_reverse (ctx->in, 16);
- md5_transform (ctx->buf, (guint32 *) ctx->in);
+ byte_reverse (ctx->in, 16);
+ soup_md5_transform (ctx->buf, (guint32 *) ctx->in);
/* Now fill the next block with 56 bytes */
memset (ctx->in, 0, 56);
memset (p, 0, count - 8);
}
if (ctx->doByteReverse)
- _byte_reverse (ctx->in, 14);
+ byte_reverse (ctx->in, 14);
/* Append length in bits and transform */
((guint32 *) ctx->in)[14] = ctx->bits[0];
((guint32 *) ctx->in)[15] = ctx->bits[1];
- md5_transform (ctx->buf, (guint32 *) ctx->in);
+ soup_md5_transform (ctx->buf, (guint32 *) ctx->in);
if (ctx->doByteReverse)
- _byte_reverse ((guchar *) ctx->buf, 4);
+ byte_reverse ((guchar *) ctx->buf, 4);
memcpy (digest, ctx->buf, 16);
}
/*
* The core of the MD5 algorithm, this alters an existing MD5 hash to
- * reflect the addition of 16 longwords of new data. md5_Update blocks
+ * reflect the addition of 16 longwords of new data. soup_md5_Update blocks
* the data and converts bytes into longwords for this routine.
*/
static void
-md5_transform (guint32 buf[4], const guint32 in[16])
+soup_md5_transform (guint32 buf[4], const guint32 in[16])
{
register guint32 a, b, c, d;
buf[2] += c;
buf[3] += d;
}
-
-
-
-
-/**
- * md5_get_digest: get the md5 hash of a buffer
- * @buffer: byte buffer
- * @buffer_size: buffer size (in bytes)
- * @digest: 16 bytes buffer receiving the hash code.
- *
- * Get the md5 hash of a buffer. The result is put in
- * the 16 bytes buffer @digest .
- **/
-void
-md5_get_digest (const gchar *buffer, gint buffer_size, guchar digest[16])
-{
- MD5Context ctx;
-
- md5_init (&ctx);
- md5_update (&ctx, buffer, buffer_size);
- md5_final (&ctx, digest);
-
-}
-
-
-/**
- * md5_get_digest_from_file: get the md5 hash of a file
- * @filename: file name
- * @digest: 16 bytes buffer receiving the hash code.
- *
- * Get the md5 hash of a file. The result is put in
- * the 16 bytes buffer @digest .
- **/
-void
-md5_get_digest_from_file (const gchar *filename, guchar digest[16])
-{
- MD5Context ctx;
- guchar tmp_buf[1024];
- gint nb_bytes_read;
- FILE *fp;
-
- printf("generating checksum\n");
-
- md5_init (&ctx);
- fp = fopen(filename, "r");
- if (!fp) {
- return;
- }
-
- while ((nb_bytes_read = fread (tmp_buf, sizeof (guchar), 1024, fp)) > 0)
- md5_update (&ctx, tmp_buf, nb_bytes_read);
-
- if (ferror(fp)) {
- fclose(fp);
- return;
- }
-
-
- md5_final (&ctx, digest);
-
- printf("checksum done\n");
-}
-
-
-
-
*/
-#ifndef MD5_UTILS_H
-#define MD5_UTILS_H
+#ifndef SOUP_MD5_UTILS_H
+#define SOUP_MD5_UTILS_H
#include <glib.h>
typedef struct {
- guint32 buf[4];
- guint32 bits[2];
- guchar in[64];
- gint doByteReverse;
+ guint32 buf[4];
+ guint32 bits[2];
+ guchar in[64];
+ gboolean doByteReverse;
+} SoupMD5Context;
-} MD5Context ;
+void soup_md5_init (SoupMD5Context *ctx);
+void soup_md5_update (SoupMD5Context *ctx,
+ const guchar *buf,
+ guint32 len);
+void soup_md5_final (SoupMD5Context *ctx,
+ guchar digest[16]);
-void md5_get_digest (const gchar *buffer, gint buffer_size, guchar digest[16]);
-
-/* use this one when speed is needed */
-/* for use in provider code only */
-void md5_get_digest_from_file (const gchar *filename, guchar digest[16]);
-
-/* raw routines */
-void md5_init (MD5Context *ctx);
-void md5_update (MD5Context *ctx, const guchar *buf, guint32 len);
-void md5_final (MD5Context *ctx, guchar digest[16]);
-
-
-#endif /* MD5_UTILS_H */
+#endif /* SOUP_MD5_UTILS_H */
} SoupHandlerKind;
typedef struct {
- SoupHandlerPhase phase;
- SoupCallbackFn handler_cb;
- gpointer user_data;
+ SoupHandlerPhase phase;
+ SoupMessageCallbackFn handler_cb;
+ gpointer user_data;
- SoupHandlerKind kind;
+ SoupHandlerKind kind;
union {
guint status_code;
SoupStatusClass status_class;
}
static void
-add_handler (SoupMessage *msg,
- SoupHandlerPhase phase,
- SoupCallbackFn handler_cb,
- gpointer user_data,
- SoupHandlerKind kind,
- const char *header,
- guint status_code,
- SoupStatusClass status_class)
+add_handler (SoupMessage *msg,
+ SoupHandlerPhase phase,
+ SoupMessageCallbackFn handler_cb,
+ gpointer user_data,
+ SoupHandlerKind kind,
+ const char *header,
+ guint status_code,
+ SoupStatusClass status_class)
{
SoupHandlerData *data;
}
void
-soup_message_add_header_handler (SoupMessage *msg,
- const char *header,
- SoupHandlerPhase phase,
- SoupCallbackFn handler_cb,
- gpointer user_data)
+soup_message_add_header_handler (SoupMessage *msg,
+ const char *header,
+ SoupHandlerPhase phase,
+ SoupMessageCallbackFn handler_cb,
+ gpointer user_data)
{
g_return_if_fail (SOUP_IS_MESSAGE (msg));
g_return_if_fail (header != NULL);
}
void
-soup_message_add_status_code_handler (SoupMessage *msg,
- guint status_code,
- SoupHandlerPhase phase,
- SoupCallbackFn handler_cb,
- gpointer user_data)
+soup_message_add_status_code_handler (SoupMessage *msg,
+ guint status_code,
+ SoupHandlerPhase phase,
+ SoupMessageCallbackFn handler_cb,
+ gpointer user_data)
{
g_return_if_fail (SOUP_IS_MESSAGE (msg));
g_return_if_fail (status_code != 0);
}
void
-soup_message_add_status_class_handler (SoupMessage *msg,
- SoupStatusClass status_class,
- SoupHandlerPhase phase,
- SoupCallbackFn handler_cb,
- gpointer user_data)
+soup_message_add_status_class_handler (SoupMessage *msg,
+ SoupStatusClass status_class,
+ SoupHandlerPhase phase,
+ SoupMessageCallbackFn handler_cb,
+ gpointer user_data)
{
g_return_if_fail (SOUP_IS_MESSAGE (msg));
g_return_if_fail (status_class != 0);
void
soup_message_add_handler (SoupMessage *msg,
SoupHandlerPhase phase,
- SoupCallbackFn handler_cb,
+ SoupMessageCallbackFn handler_cb,
gpointer user_data)
{
g_return_if_fail (SOUP_IS_MESSAGE (msg));
}
void
-soup_message_remove_handler (SoupMessage *msg,
- SoupHandlerPhase phase,
- SoupCallbackFn handler_cb,
- gpointer user_data)
+soup_message_remove_handler (SoupMessage *msg,
+ SoupHandlerPhase phase,
+ SoupMessageCallbackFn handler_cb,
+ gpointer user_data)
{
GSList *iter = msg->priv->content_handlers;
SoupDataBuffer *write_body;
guint written;
- guint read_tag, write_tag, err_tag, idle_tag;
+ guint read_tag, write_tag, err_tag;
SoupMessageGetHeadersFn get_headers_cb;
SoupMessageParseHeadersFn parse_headers_cb;
if (!io)
return;
- if (io->idle_tag)
- g_source_remove (io->idle_tag);
if (io->read_tag)
g_signal_handler_disconnect (io->sock, io->read_tag);
if (io->write_tag)
return io;
}
-static gboolean
-idle_io (gpointer user_data)
-{
- SoupMessage *msg = user_data;
- SoupMessageIOData *io = msg->priv->io_data;
-
- io->idle_tag = 0;
- if (io->write_state != SOUP_MESSAGE_IO_STATE_NOT_STARTED &&
- io->write_state != SOUP_MESSAGE_IO_STATE_BLOCKING)
- io_write (io->sock, msg);
- else
- io_read (io->sock, msg);
- return FALSE;
-}
-
void
soup_message_io_client (SoupMessage *msg, SoupSocket *sock,
SoupMessageGetHeadersFn get_headers_cb,
io->write_body = &msg->request;
io->write_state = SOUP_MESSAGE_IO_STATE_HEADERS;
- io->idle_tag = g_idle_add (idle_io, msg);
+ io_write (sock, msg);
}
void
io->write_body = &msg->response;
io->read_state = SOUP_MESSAGE_IO_STATE_HEADERS;
- io->idle_tag = g_idle_add (idle_io, msg);
+ io_read (sock, msg);
}
void
g_signal_handler_disconnect (io->sock, io->read_tag);
io->read_tag = 0;
}
- if (io->idle_tag) {
- g_source_remove (io->idle_tag);
- io->idle_tag = 0;
- }
}
void
g_return_if_fail (io != NULL);
- if (io->write_tag || io->read_tag || io->idle_tag)
+ if (io->write_tag || io->read_tag)
return;
io->write_tag = g_signal_connect (io->sock, "writable",
io->read_tag = g_signal_connect (io->sock, "readable",
G_CALLBACK (io_read), msg);
- io->idle_tag = g_idle_add (idle_io, msg);
+ if (io->write_state != SOUP_MESSAGE_IO_STATE_NOT_STARTED &&
+ io->write_state != SOUP_MESSAGE_IO_STATE_BLOCKING)
+ io_write (io->sock, msg);
+ else
+ io_read (io->sock, msg);
}
#include <libsoup/soup-message.h>
-typedef enum {
- SOUP_MESSAGE_STATUS_IDLE,
- SOUP_MESSAGE_STATUS_QUEUED,
- SOUP_MESSAGE_STATUS_CONNECTING,
- SOUP_MESSAGE_STATUS_RUNNING,
- SOUP_MESSAGE_STATUS_FINISHED,
-} SoupMessageStatus;
-
-#define SOUP_MESSAGE_IS_STARTING(msg) (msg->priv->status == SOUP_MESSAGE_STATUS_QUEUED || msg->priv->status == SOUP_MESSAGE_STATUS_CONNECTING)
-
struct SoupMessagePrivate {
- SoupMessageStatus status;
-
gpointer io_data;
guint msg_flags;
gboolean soup_message_is_keepalive (SoupMessage *msg);
-void soup_message_set_uri (SoupMessage *msg,
- const SoupUri *uri);
-
typedef void (*SoupMessageGetHeadersFn) (SoupMessage *msg,
GString *headers,
msg->priv = g_new0 (SoupMessagePrivate, 1);
- msg->priv->status = SOUP_MESSAGE_STATUS_IDLE;
+ msg->status = SOUP_MESSAGE_STATUS_IDLE;
msg->request_headers = g_hash_table_new (soup_str_case_hash,
soup_str_case_equal);
{
soup_message_io_cancel (req);
- if (req->priv->status != SOUP_MESSAGE_STATUS_IDLE)
- req->priv->status = SOUP_MESSAGE_STATUS_IDLE;
+ if (req->status != SOUP_MESSAGE_STATUS_IDLE)
+ req->status = SOUP_MESSAGE_STATUS_IDLE;
if (req->response.owner == SOUP_BUFFER_SYSTEM_OWNED)
g_free (req->response.body);
typedef struct SoupMessagePrivate SoupMessagePrivate;
typedef enum {
+ SOUP_MESSAGE_STATUS_IDLE,
+ SOUP_MESSAGE_STATUS_QUEUED,
+ SOUP_MESSAGE_STATUS_CONNECTING,
+ SOUP_MESSAGE_STATUS_RUNNING,
+ SOUP_MESSAGE_STATUS_FINISHED,
+} SoupMessageStatus;
+
+#define SOUP_MESSAGE_IS_STARTING(msg) (msg->status == SOUP_MESSAGE_STATUS_QUEUED || msg->status == SOUP_MESSAGE_STATUS_CONNECTING)
+
+typedef enum {
SOUP_TRANSFER_UNKNOWN = 0,
SOUP_TRANSFER_CHUNKED,
SOUP_TRANSFER_CONTENT_LENGTH,
SoupDataBuffer response;
GHashTable *response_headers;
+
+ SoupMessageStatus status;
};
typedef struct {
GType soup_message_get_type (void);
typedef void (*SoupMessageCallbackFn) (SoupMessage *req, gpointer user_data);
-/* Backward compat; FIXME */
-typedef SoupMessageCallbackFn SoupCallbackFn;
SoupMessage *soup_message_new (const char *method,
const char *uri);
gboolean soup_message_is_keepalive (SoupMessage *msg);
const SoupUri *soup_message_get_uri (SoupMessage *msg);
+void soup_message_set_uri (SoupMessage *msg,
+ const SoupUri *uri);
typedef enum {
/*
void soup_message_add_handler (SoupMessage *msg,
SoupHandlerPhase type,
- SoupCallbackFn handler_cb,
+ SoupMessageCallbackFn handler_cb,
gpointer user_data);
void soup_message_add_header_handler (SoupMessage *msg,
const char *header,
SoupHandlerPhase type,
- SoupCallbackFn handler_cb,
+ SoupMessageCallbackFn,
gpointer user_data);
void soup_message_add_status_code_handler (
SoupMessage *msg,
guint status_code,
SoupHandlerPhase type,
- SoupCallbackFn handler_cb,
+ SoupMessageCallbackFn,
gpointer user_data);
void soup_message_add_status_class_handler (
SoupMessage *msg,
SoupStatusClass status_class,
SoupHandlerPhase type,
- SoupCallbackFn handler_cb,
+ SoupMessageCallbackFn,
gpointer user_data);
void soup_message_remove_handler (SoupMessage *msg,
SoupHandlerPhase type,
- SoupCallbackFn handler_cb,
+ SoupMessageCallbackFn,
gpointer user_data);
/*
#include "soup-server-auth.h"
-#include "md5-utils.h"
#include "soup-headers.h"
+#include "soup-md5-utils.h"
#include "soup-misc.h"
#include "soup-uri.h"
check_digest_passwd (SoupServerAuthDigest *digest,
gchar *passwd)
{
- MD5Context ctx;
+ SoupMD5Context ctx;
guchar d[16];
guchar hex_a1 [33], hex_a2[33], o[33];
gchar *tmp;
/* compute A1 */
- md5_init (&ctx);
- md5_update (&ctx, digest->user, strlen (digest->user));
- md5_update (&ctx, ":", 1);
- md5_update (&ctx, digest->realm, strlen (digest->realm));
- md5_update (&ctx, ":", 1);
+ soup_md5_init (&ctx);
+ soup_md5_update (&ctx, digest->user, strlen (digest->user));
+ soup_md5_update (&ctx, ":", 1);
+ soup_md5_update (&ctx, digest->realm, strlen (digest->realm));
+ soup_md5_update (&ctx, ":", 1);
if (passwd)
- md5_update (&ctx, passwd, strlen (passwd));
+ soup_md5_update (&ctx, passwd, strlen (passwd));
if (digest->algorithm == SOUP_ALGORITHM_MD5_SESS) {
- md5_final (&ctx, d);
-
- md5_init (&ctx);
- md5_update (&ctx, d, 16);
- md5_update (&ctx, ":", 1);
- md5_update (&ctx, digest->nonce, strlen (digest->nonce));
- md5_update (&ctx, ":", 1);
- md5_update (&ctx, digest->cnonce, strlen (digest->cnonce));
+ soup_md5_final (&ctx, d);
+
+ soup_md5_init (&ctx);
+ soup_md5_update (&ctx, d, 16);
+ soup_md5_update (&ctx, ":", 1);
+ soup_md5_update (&ctx, digest->nonce, strlen (digest->nonce));
+ soup_md5_update (&ctx, ":", 1);
+ soup_md5_update (&ctx, digest->cnonce, strlen (digest->cnonce));
}
/* hexify A1 */
- md5_final (&ctx, d);
+ soup_md5_final (&ctx, d);
digest_hex (d, hex_a1);
/* compute A2 */
- md5_init (&ctx);
- md5_update (&ctx,
+ soup_md5_init (&ctx);
+ soup_md5_update (&ctx,
digest->request_method,
strlen (digest->request_method));
- md5_update (&ctx, ":", 1);
- md5_update (&ctx, digest->digest_uri, strlen (digest->digest_uri));
+ soup_md5_update (&ctx, ":", 1);
+ soup_md5_update (&ctx, digest->digest_uri, strlen (digest->digest_uri));
if (digest->integrity) {
/* FIXME: Actually implement. Ugh. */
- md5_update (&ctx, ":", 1);
- md5_update (&ctx, "00000000000000000000000000000000", 32);
+ soup_md5_update (&ctx, ":", 1);
+ soup_md5_update (&ctx, "00000000000000000000000000000000", 32);
}
/* hexify A2 */
- md5_final (&ctx, d);
+ soup_md5_final (&ctx, d);
digest_hex (d, hex_a2);
/* compute KD */
- md5_init (&ctx);
- md5_update (&ctx, hex_a1, 32);
- md5_update (&ctx, ":", 1);
- md5_update (&ctx, digest->nonce, strlen (digest->nonce));
- md5_update (&ctx, ":", 1);
+ soup_md5_init (&ctx);
+ soup_md5_update (&ctx, hex_a1, 32);
+ soup_md5_update (&ctx, ":", 1);
+ soup_md5_update (&ctx, digest->nonce, strlen (digest->nonce));
+ soup_md5_update (&ctx, ":", 1);
tmp = g_strdup_printf ("%.8x", digest->nonce_count);
- md5_update (&ctx, tmp, strlen (tmp));
+ soup_md5_update (&ctx, tmp, strlen (tmp));
g_free (tmp);
- md5_update (&ctx, ":", 1);
- md5_update (&ctx, digest->cnonce, strlen (digest->cnonce));
- md5_update (&ctx, ":", 1);
+ soup_md5_update (&ctx, ":", 1);
+ soup_md5_update (&ctx, digest->cnonce, strlen (digest->cnonce));
+ soup_md5_update (&ctx, ":", 1);
if (digest->integrity)
tmp = "auth-int";
else
tmp = "auth";
- md5_update (&ctx, tmp, strlen (tmp));
- md5_update (&ctx, ":", 1);
+ soup_md5_update (&ctx, tmp, strlen (tmp));
+ soup_md5_update (&ctx, ":", 1);
- md5_update (&ctx, hex_a2, 32);
- md5_final (&ctx, d);
+ soup_md5_update (&ctx, hex_a2, 32);
+ soup_md5_final (&ctx, d);
digest_hex (d, o);
#include <unistd.h>
#include "soup-server-message.h"
-#include "soup-message-private.h"
#include "soup-private.h"
#include "soup-server.h"
#include "soup-address.h"
#include "soup-headers.h"
#include "soup-private.h"
-#include "soup-message-private.h"
#include "soup-server-auth.h"
#include "soup-server-message.h"
#include "soup-socket.h"
#include "soup-session.h"
#include "soup-connection.h"
-#include "soup-message-private.h"
#include "soup-message-queue.h"
#include "soup-private.h"
guint max_conns, max_conns_per_host;
SoupMessageQueue *queue;
- guint queue_idle_tag;
GHashTable *hosts; /* SoupUri -> SoupSessionHost */
GHashTable *conns; /* SoupConnection -> SoupSessionHost */
SoupMessageQueueIter iter;
SoupMessage *msg;
- if (session->priv->queue_idle_tag)
- g_source_remove (session->priv->queue_idle_tag);
-
for (msg = soup_message_queue_first (session->priv->queue, &iter); msg;
msg = soup_message_queue_next (session->priv->queue, &iter)) {
soup_message_queue_remove (session->priv->queue, &iter);
SoupSession *session = user_data;
soup_message_queue_remove_message (session->priv->queue, req);
- req->priv->status = SOUP_MESSAGE_STATUS_FINISHED;
+ req->status = SOUP_MESSAGE_STATUS_FINISHED;
}
static void
static void
send_request (SoupSession *session, SoupMessage *req, SoupConnection *conn)
{
- req->priv->status = SOUP_MESSAGE_STATUS_RUNNING;
+ req->status = SOUP_MESSAGE_STATUS_RUNNING;
add_auth (session, req, FALSE);
if (session->priv->proxy_uri)
continue;
}
- if (msg->priv->status == SOUP_MESSAGE_STATUS_CONNECTING) {
+ if (msg->status == SOUP_MESSAGE_STATUS_CONNECTING) {
/* We already started a connection for this
* message, so don't start another one.
*/
/* Mark the request as connecting, so we don't try to
* open another new connection for it next time around.
*/
- msg->priv->status = SOUP_MESSAGE_STATUS_CONNECTING;
+ msg->status = SOUP_MESSAGE_STATUS_CONNECTING;
started_any = TRUE;
}
return started_any;
}
-static gboolean
-idle_run_queue (gpointer user_data)
-{
- SoupSession *session = user_data;
-
- session->priv->queue_idle_tag = 0;
- run_queue (session, TRUE);
- return FALSE;
-}
-
static void
queue_message (SoupSession *session, SoupMessage *req, gboolean requeue)
{
soup_message_prepare (req);
- req->priv->status = SOUP_MESSAGE_STATUS_QUEUED;
+ req->status = SOUP_MESSAGE_STATUS_QUEUED;
if (!requeue)
soup_message_queue_append (session->priv->queue, req);
- if (!session->priv->queue_idle_tag) {
- session->priv->queue_idle_tag =
- g_idle_add (idle_run_queue, session);
- }
+ run_queue (session, TRUE);
}
/**
* soup_session_queue_message:
* @session: a #SoupSession
* @req: the message to queue
- * @callback: a #SoupCallbackFn which will be called after the message
- * completes or when an unrecoverable error occurs.
+ * @callback: a #SoupMessageCallbackFn which will be called after the
+ * message completes or when an unrecoverable error occurs.
* @user_data: a pointer passed to @callback.
*
* Queues the message @req for sending. All messages are processed
*/
void
soup_session_queue_message (SoupSession *session, SoupMessage *req,
- SoupCallbackFn callback, gpointer user_data)
+ SoupMessageCallbackFn callback, gpointer user_data)
{
g_return_if_fail (SOUP_IS_SESSION (session));
g_return_if_fail (SOUP_IS_MESSAGE (req));
SOUP_HANDLER_POST_BODY,
authorize_handler, session);
- if (!(req->priv->msg_flags & SOUP_MESSAGE_NO_REDIRECT)) {
+ if (!(soup_message_get_flags (req) & SOUP_MESSAGE_NO_REDIRECT)) {
soup_message_add_status_class_handler (
req, SOUP_STATUS_CLASS_REDIRECT,
SOUP_HANDLER_POST_BODY,
while (1) {
g_main_iteration (TRUE);
- if (req->priv->status == SOUP_MESSAGE_STATUS_FINISHED ||
+ if (req->status == SOUP_MESSAGE_STATUS_FINISHED ||
SOUP_STATUS_IS_TRANSPORT (req->status_code))
break;
}
#include "libsoup/soup.h"
#include "libsoup/soup-auth.h"
#include "libsoup/soup-private.h"
-#include "libsoup/soup-message-private.h"
#include "libsoup/soup-session.h"
int errors = 0;