1 /* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
3 * soup-message.h: Asyncronous Callback-based SOAP Request Queue.
6 * Alex Graveley (alex@ximian.com)
8 * Copyright (C) 2000, Ximian, Inc.
11 #ifndef SOUP_MESSAGE_H
12 #define SOUP_MESSAGE_H 1
15 #include <libsoup/soup-context.h>
16 #include <libsoup/soup-error.h>
21 SOUP_STATUS_CONNECTING,
22 SOUP_STATUS_SENDING_REQUEST,
23 SOUP_STATUS_READING_RESPONSE,
28 SOUP_BUFFER_SYSTEM_OWNED = 0,
29 SOUP_BUFFER_USER_OWNED,
39 #define SOUP_METHOD_POST "POST"
40 #define SOUP_METHOD_GET "GET"
41 #define SOUP_METHOD_HEAD "HEAD"
42 #define SOUP_METHOD_OPTIONS "OPTIONS"
43 #define SOUP_METHOD_PUT "PUT"
44 #define SOUP_METHOD_MOVE "MOVE"
45 #define SOUP_METHOD_COPY "COPY"
46 #define SOUP_METHOD_DELETE "DELETE"
47 #define SOUP_METHOD_TRACE "TRACE"
48 #define SOUP_METHOD_CONNECT "CONNECT"
49 #define SOUP_METHOD_MKCOL "MKCOL"
50 #define SOUP_METHOD_PROPPATCH "PROPPATCH"
51 #define SOUP_METHOD_PROPFIND "PROPFIND"
52 #define SOUP_METHOD_SEARCH "SEARCH"
54 typedef struct _SoupMessage SoupMessage;
55 typedef struct _SoupMessagePrivate SoupMessagePrivate;
58 SoupMessagePrivate *priv;
61 SoupConnection *connection;
65 SoupTransferStatus status;
68 SoupErrorClass errorclass;
69 const gchar *errorphrase;
71 SoupDataBuffer request;
72 GHashTable *request_headers;
74 SoupDataBuffer response;
75 GHashTable *response_headers;
78 #define SOUP_MESSAGE_IS_ERROR(_msg) \
79 (_msg->errorclass && \
80 _msg->errorclass != SOUP_ERROR_CLASS_SUCCESS && \
81 _msg->errorclass != SOUP_ERROR_CLASS_INFORMATIONAL && \
82 _msg->errorclass != SOUP_ERROR_CLASS_UNKNOWN)
84 typedef void (*SoupCallbackFn) (SoupMessage *req, gpointer user_data);
86 SoupMessage *soup_message_new (SoupContext *context,
89 SoupMessage *soup_message_new_full (SoupContext *context,
91 SoupOwnership req_owner,
95 void soup_message_free (SoupMessage *req);
97 void soup_message_cancel (SoupMessage *req);
99 SoupErrorClass soup_message_send (SoupMessage *msg);
101 void soup_message_queue (SoupMessage *req,
102 SoupCallbackFn callback,
105 void soup_message_add_header (GHashTable *hash,
109 const gchar *soup_message_get_header (GHashTable *hash,
112 const GSList *soup_message_get_header_list (GHashTable *hash,
115 void soup_message_foreach_header (GHashTable *hash,
119 void soup_message_foreach_remove_header (
124 void soup_message_remove_header (GHashTable *hash,
127 void soup_message_clear_headers (GHashTable *hash);
134 void soup_message_set_http_version (SoupMessage *msg,
135 SoupHttpVersion version);
137 SoupHttpVersion soup_message_get_http_version (SoupMessage *msg);
139 void soup_message_set_context (SoupMessage *msg,
140 SoupContext *new_ctx);
142 SoupContext *soup_message_get_context (SoupMessage *msg);
146 * SOUP_MESSAGE_NO_PIPELINE:
147 * Use a currently unused connection or establish a new
148 * connection when issuing this request.
150 SOUP_MESSAGE_NO_PIPELINE = (1 << 0),
153 * SOUP_MESSAGE_NO_REDIRECT:
154 * Do not follow redirection responses.
156 SOUP_MESSAGE_NO_REDIRECT = (1 << 1),
159 * SOUP_MESSAGE_NO_COOKIE:
160 * Do not send cookie information with request, and do not
161 * store cookie information from the response.
163 SOUP_MESSAGE_NO_COOKIE = (1 << 2),
166 * SOUP_MESSAGE_OVERWRITE_CHUNKS:
167 * Downloaded data chunks should not be stored in the response
168 * data buffer. Instead only send data to SOUP_HANDLER_BODY_CHUNK
169 * handlers, then truncate the data buffer.
171 * Useful when the response is expected to be very large, and
172 * storage in memory is not desired.
174 SOUP_MESSAGE_OVERWRITE_CHUNKS = (1 << 3)
177 void soup_message_set_flags (SoupMessage *msg,
180 guint soup_message_get_flags (SoupMessage *msg);
183 * Handler Registration
189 SOUP_HANDLER_PREPARE = 0,
190 SOUP_HANDLER_HEADERS,
192 SOUP_HANDLER_FINISHED,
197 SOUP_HANDLER_DATA_SENT
201 SOUP_FILTER_HEADER = (1 << 0),
202 SOUP_FILTER_ERROR_CODE = (1 << 1),
203 SOUP_FILTER_ERROR_CLASS = (1 << 2),
204 SOUP_FILTER_TIMEOUT = (1 << 3),
205 } SoupHandlerFilterType;
212 SoupErrorClass errorclass;
220 * Continue processing as normal.
222 SOUP_HANDLER_CONTINUE,
225 * Do not process further handlers. Continue receiving data.
230 * do not process further handlers. Stop receiving data and
231 * issue final callback.
236 * Restart handler processing. This should be returned if a
237 * handler changes the message's errorcode.
239 SOUP_HANDLER_RESTART,
242 * Requeue the request immediately. Stop processing handlers
243 * and do not issue final callback.
248 typedef SoupHandlerResult (*SoupHandlerFn) (SoupMessage *req,
251 void soup_message_add_handler (SoupMessage *msg,
252 SoupHandlerEvent type,
253 SoupHandlerFilter *filter,
254 SoupHandlerFn handler_cb,
259 * Run before global handlers and previously registered message
265 * Run after global handlers and previously registered message
271 void soup_message_add_handler_full (SoupMessage *msg,
273 SoupHandlerEvent type,
274 SoupHandlerWhen order,
275 SoupHandlerFilter *filter,
276 SoupHandlerFn handler_cb,
279 GSList *soup_message_list_handlers (SoupMessage *msg);
281 void soup_message_remove_handler (SoupMessage *msg,
284 void soup_message_remove_handler_by_func (
286 SoupHandlerFn handler_cb);
288 void soup_message_remove_handler_by_func_and_data (
290 SoupHandlerFn handler_cb,
294 * Error Setting (for use by Handlers)
296 void soup_message_set_error (SoupMessage *msg,
297 SoupKnownErrorCode errcode);
299 void soup_message_set_error_full (SoupMessage *msg,
301 const gchar *errphrase);
303 void soup_message_set_handler_error (SoupMessage *msg,
305 const gchar *errphrase);
307 #endif /*SOUP_MESSAGE_H*/