1 /* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
3 * Copyright (C) 2000-2003, Ximian, Inc.
7 #define SOUP_MESSAGE_H 1
9 #include <libsoup/soup-types.h>
10 #include <libsoup/soup-method.h>
12 #define SOUP_TYPE_MESSAGE (soup_message_get_type ())
13 #define SOUP_MESSAGE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SOUP_TYPE_MESSAGE, SoupMessage))
14 #define SOUP_MESSAGE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SOUP_TYPE_MESSAGE, SoupMessageClass))
15 #define SOUP_IS_MESSAGE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SOUP_TYPE_MESSAGE))
16 #define SOUP_IS_MESSAGE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((obj), SOUP_TYPE_MESSAGE))
17 #define SOUP_MESSAGE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), SOUP_TYPE_MESSAGE, SoupMessageClass))
19 typedef struct SoupMessagePrivate SoupMessagePrivate;
22 SOUP_MESSAGE_STATUS_IDLE,
23 SOUP_MESSAGE_STATUS_QUEUED,
24 SOUP_MESSAGE_STATUS_CONNECTING,
25 SOUP_MESSAGE_STATUS_RUNNING,
26 SOUP_MESSAGE_STATUS_FINISHED,
29 #define SOUP_MESSAGE_IS_STARTING(msg) (msg->status == SOUP_MESSAGE_STATUS_QUEUED || msg->status == SOUP_MESSAGE_STATUS_CONNECTING)
32 SOUP_TRANSFER_UNKNOWN = 0,
33 SOUP_TRANSFER_CHUNKED,
34 SOUP_TRANSFER_CONTENT_LENGTH,
35 } SoupTransferEncoding;
38 SOUP_BUFFER_SYSTEM_OWNED = 0,
39 SOUP_BUFFER_USER_OWNED,
52 SoupMessagePrivate *priv;
57 const char *reason_phrase;
59 SoupDataBuffer request;
60 GHashTable *request_headers;
62 SoupDataBuffer response;
63 GHashTable *response_headers;
65 SoupMessageStatus status;
69 GObjectClass parent_class;
72 void (*wrote_headers) (SoupMessage *msg);
73 void (*wrote_chunk) (SoupMessage *msg);
74 void (*wrote_body) (SoupMessage *msg);
75 void (*got_headers) (SoupMessage *msg);
76 void (*got_chunk) (SoupMessage *msg);
77 void (*got_body) (SoupMessage *msg);
78 void (*finished) (SoupMessage *msg);
81 GType soup_message_get_type (void);
83 typedef void (*SoupMessageCallbackFn) (SoupMessage *req, gpointer user_data);
85 SoupMessage *soup_message_new (const char *method,
87 SoupMessage *soup_message_new_from_uri (const char *method,
90 void soup_message_set_request (SoupMessage *msg,
91 const char *content_type,
92 SoupOwnership req_owner,
96 void soup_message_set_response (SoupMessage *msg,
97 const char *content_type,
98 SoupOwnership resp_owner,
102 void soup_message_cancel (SoupMessage *req);
104 void soup_message_prepare (SoupMessage *req);
106 void soup_message_add_header (GHashTable *hash,
110 const char *soup_message_get_header (GHashTable *hash,
113 const GSList *soup_message_get_header_list (GHashTable *hash,
116 void soup_message_foreach_header (GHashTable *hash,
120 void soup_message_remove_header (GHashTable *hash,
123 void soup_message_clear_headers (GHashTable *hash);
130 void soup_message_set_http_version (SoupMessage *msg,
131 SoupHttpVersion version);
132 SoupHttpVersion soup_message_get_http_version (SoupMessage *msg);
134 gboolean soup_message_is_keepalive (SoupMessage *msg);
136 const SoupUri *soup_message_get_uri (SoupMessage *msg);
137 void soup_message_set_uri (SoupMessage *msg,
142 * SOUP_MESSAGE_NO_PIPELINE:
143 * Use a currently unused connection or establish a new
144 * connection when issuing this request.
146 SOUP_MESSAGE_NO_PIPELINE = (1 << 0),
149 * SOUP_MESSAGE_NO_REDIRECT:
150 * Do not follow redirection responses.
152 SOUP_MESSAGE_NO_REDIRECT = (1 << 1),
155 * SOUP_MESSAGE_NO_COOKIE:
156 * Do not send cookie information with request, and do not
157 * store cookie information from the response.
159 SOUP_MESSAGE_NO_COOKIE = (1 << 2),
162 * SOUP_MESSAGE_OVERWRITE_CHUNKS:
163 * Downloaded data chunks should not be stored in the response
164 * data buffer. Instead only send data to SOUP_HANDLER_BODY_CHUNK
165 * handlers, then truncate the data buffer.
167 * Useful when the response is expected to be very large, and
168 * storage in memory is not desired.
170 SOUP_MESSAGE_OVERWRITE_CHUNKS = (1 << 3),
173 * SOUP_MESSAGE_EXPECT_CONTINUE:
174 * The message includes an "Expect: 100-continue" header, and we
175 * should not send the body until the Continue response has been
176 * received. (This should be synchronized with the existence
177 * of the "Expect: 100-continue" header. FIXME!)
179 SOUP_MESSAGE_EXPECT_CONTINUE = (1 << 4)
182 void soup_message_set_flags (SoupMessage *msg,
185 guint soup_message_get_flags (SoupMessage *msg);
188 * Handler Registration
191 SOUP_HANDLER_PRE_BODY = 1,
192 SOUP_HANDLER_BODY_CHUNK,
193 SOUP_HANDLER_POST_BODY
196 void soup_message_add_handler (SoupMessage *msg,
197 SoupHandlerPhase type,
198 SoupMessageCallbackFn handler_cb,
201 void soup_message_add_header_handler (SoupMessage *msg,
203 SoupHandlerPhase type,
204 SoupMessageCallbackFn,
207 void soup_message_add_status_code_handler (
210 SoupHandlerPhase type,
211 SoupMessageCallbackFn,
214 void soup_message_add_status_class_handler (
216 SoupStatusClass status_class,
217 SoupHandlerPhase type,
218 SoupMessageCallbackFn,
221 void soup_message_remove_handler (SoupMessage *msg,
222 SoupHandlerPhase type,
223 SoupMessageCallbackFn,
229 void soup_message_set_status (SoupMessage *msg,
232 void soup_message_set_status_full (SoupMessage *msg,
234 const char *reason_phrase);
237 /* Chunked encoding */
238 void soup_message_add_chunk (SoupMessage *msg,
242 void soup_message_add_final_chunk (SoupMessage *msg);
244 SoupDataBuffer*soup_message_pop_chunk (SoupMessage *msg);
248 void soup_message_send_request (SoupMessage *req,
251 void soup_message_read_request (SoupMessage *req,
253 void soup_message_io_cancel (SoupMessage *msg);;
254 void soup_message_io_pause (SoupMessage *msg);
255 void soup_message_io_unpause (SoupMessage *msg);
258 void soup_message_wrote_headers (SoupMessage *msg);
259 void soup_message_wrote_chunk (SoupMessage *msg);
260 void soup_message_wrote_body (SoupMessage *msg);
261 void soup_message_got_headers (SoupMessage *msg);
262 void soup_message_got_chunk (SoupMessage *msg);
263 void soup_message_got_body (SoupMessage *msg);
264 void soup_message_finished (SoupMessage *msg);
266 #endif /*SOUP_MESSAGE_H*/