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_clear_headers (GHashTable *hash);
126 void soup_message_set_http_version (SoupMessage *msg,
127 SoupHttpVersion version);
129 void soup_message_set_context (SoupMessage *msg,
130 SoupContext *new_ctx);
132 SoupContext *soup_message_get_context (SoupMessage *msg);
136 * SOUP_MESSAGE_NO_PIPELINE:
137 * Use a currently unused connection or establish a new
138 * connection when issuing this request.
140 SOUP_MESSAGE_NO_PIPELINE = (1 << 0),
143 * SOUP_MESSAGE_NO_REDIRECT:
144 * Do not follow redirection responses.
146 SOUP_MESSAGE_NO_REDIRECT = (1 << 1),
149 * SOUP_MESSAGE_NO_COOKIE:
150 * Do not send cookie information with request, and do not
151 * store cookie information from the response.
153 SOUP_MESSAGE_NO_COOKIE = (1 << 2),
156 * SOUP_MESSAGE_OVERWRITE_CHUNKS:
157 * Downloaded data chunks should not be stored in the response
158 * data buffer. Instead only send data to SOUP_HANDLER_BODY_CHUNK
159 * handlers, then truncate the data buffer.
161 * Useful when the response is expected to be very large, and
162 * storage in memory is not desired.
164 SOUP_MESSAGE_OVERWRITE_CHUNKS = (1 << 3)
167 void soup_message_set_flags (SoupMessage *msg,
170 guint soup_message_get_flags (SoupMessage *msg);
173 * Handler Registration
176 SOUP_HANDLER_PRE_BODY = 1,
177 SOUP_HANDLER_BODY_CHUNK,
178 SOUP_HANDLER_POST_BODY
181 void soup_message_add_handler (SoupMessage *msg,
182 SoupHandlerType type,
183 SoupCallbackFn handler_cb,
186 void soup_message_add_header_handler (SoupMessage *msg,
188 SoupHandlerType type,
189 SoupCallbackFn handler_cb,
192 void soup_message_add_error_code_handler (
195 SoupHandlerType type,
196 SoupCallbackFn handler_cb,
199 void soup_message_add_error_class_handler (
201 SoupErrorClass errorclass,
202 SoupHandlerType type,
203 SoupCallbackFn handler_cb,
206 void soup_message_remove_handler (SoupMessage *msg,
207 SoupHandlerType type,
208 SoupCallbackFn handler_cb,
212 * Error Setting (for use by Handlers)
214 void soup_message_set_error (SoupMessage *msg,
215 SoupKnownErrorCode errcode);
217 void soup_message_set_error_full (SoupMessage *msg,
219 const gchar *errphrase);
221 void soup_message_set_handler_error (SoupMessage *msg,
223 const gchar *errphrase);
225 /** DEPRECATED API **/
228 void soup_message_set_request_header (SoupMessage *req,
233 const gchar *soup_message_get_request_header (SoupMessage *req,
237 void soup_message_set_response_header (SoupMessage *req,
242 const gchar *soup_message_get_response_header (SoupMessage *req,
245 #endif /*SOUP_MESSAGE_H*/