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_informational) (SoupMessage *msg);
73 void (*wrote_headers) (SoupMessage *msg);
74 void (*wrote_chunk) (SoupMessage *msg);
75 void (*wrote_body) (SoupMessage *msg);
76 void (*got_informational) (SoupMessage *msg);
77 void (*got_headers) (SoupMessage *msg);
78 void (*got_chunk) (SoupMessage *msg);
79 void (*got_body) (SoupMessage *msg);
80 void (*restarted) (SoupMessage *msg);
81 void (*finished) (SoupMessage *msg);
84 GType soup_message_get_type (void);
86 typedef void (*SoupMessageCallbackFn) (SoupMessage *req, gpointer user_data);
88 SoupMessage *soup_message_new (const char *method,
89 const char *uri_string);
90 SoupMessage *soup_message_new_from_uri (const char *method,
93 void soup_message_set_request (SoupMessage *msg,
94 const char *content_type,
95 SoupOwnership req_owner,
99 void soup_message_set_response (SoupMessage *msg,
100 const char *content_type,
101 SoupOwnership resp_owner,
105 void soup_message_cancel (SoupMessage *msg);
107 void soup_message_add_header (GHashTable *hash,
111 const char *soup_message_get_header (GHashTable *hash,
114 const GSList *soup_message_get_header_list (GHashTable *hash,
117 void soup_message_foreach_header (GHashTable *hash,
121 void soup_message_remove_header (GHashTable *hash,
124 void soup_message_clear_headers (GHashTable *hash);
131 void soup_message_set_http_version (SoupMessage *msg,
132 SoupHttpVersion version);
133 SoupHttpVersion soup_message_get_http_version (SoupMessage *msg);
135 gboolean soup_message_is_keepalive (SoupMessage *msg);
137 const SoupUri *soup_message_get_uri (SoupMessage *msg);
138 void soup_message_set_uri (SoupMessage *msg,
143 * SOUP_MESSAGE_NO_PIPELINE:
144 * Use a currently unused connection or establish a new
145 * connection when issuing this request.
147 SOUP_MESSAGE_NO_PIPELINE = (1 << 0),
150 * SOUP_MESSAGE_NO_REDIRECT:
151 * Do not follow redirection responses.
153 SOUP_MESSAGE_NO_REDIRECT = (1 << 1),
156 * SOUP_MESSAGE_NO_COOKIE:
157 * Do not send cookie information with request, and do not
158 * store cookie information from the response.
160 SOUP_MESSAGE_NO_COOKIE = (1 << 2),
163 * SOUP_MESSAGE_OVERWRITE_CHUNKS:
164 * Downloaded data chunks should not be stored in the response
165 * data buffer. Instead only send data to SOUP_HANDLER_BODY_CHUNK
166 * handlers, then truncate the data buffer.
168 * Useful when the response is expected to be very large, and
169 * storage in memory is not desired.
171 SOUP_MESSAGE_OVERWRITE_CHUNKS = (1 << 3),
174 * SOUP_MESSAGE_EXPECT_CONTINUE: The message includes an
175 * "Expect: 100-continue" header, and we should not send the
176 * body until the Continue response has been received. (This
177 * is automatically set if there is an "Expect: 100-continue"
180 SOUP_MESSAGE_EXPECT_CONTINUE = (1 << 4)
183 void soup_message_set_flags (SoupMessage *msg,
186 guint soup_message_get_flags (SoupMessage *msg);
189 * Handler Registration
192 SOUP_HANDLER_POST_REQUEST = 1,
193 SOUP_HANDLER_PRE_BODY,
194 SOUP_HANDLER_BODY_CHUNK,
195 SOUP_HANDLER_POST_BODY
198 void soup_message_add_handler (SoupMessage *msg,
199 SoupHandlerPhase type,
200 SoupMessageCallbackFn handler_cb,
203 void soup_message_add_header_handler (SoupMessage *msg,
205 SoupHandlerPhase type,
206 SoupMessageCallbackFn,
209 void soup_message_add_status_code_handler (
212 SoupHandlerPhase type,
213 SoupMessageCallbackFn,
216 void soup_message_add_status_class_handler (
218 SoupStatusClass status_class,
219 SoupHandlerPhase type,
220 SoupMessageCallbackFn,
223 void soup_message_remove_handler (SoupMessage *msg,
224 SoupHandlerPhase type,
225 SoupMessageCallbackFn,
231 void soup_message_set_status (SoupMessage *msg,
234 void soup_message_set_status_full (SoupMessage *msg,
236 const char *reason_phrase);
239 /* Chunked encoding */
240 void soup_message_add_chunk (SoupMessage *msg,
244 void soup_message_add_final_chunk (SoupMessage *msg);
246 SoupDataBuffer*soup_message_pop_chunk (SoupMessage *msg);
250 void soup_message_send_request (SoupMessage *req,
253 void soup_message_read_request (SoupMessage *req,
255 void soup_message_io_cancel (SoupMessage *msg);
256 void soup_message_io_pause (SoupMessage *msg);
257 void soup_message_io_unpause (SoupMessage *msg);
260 void soup_message_wrote_informational (SoupMessage *msg);
261 void soup_message_wrote_headers (SoupMessage *msg);
262 void soup_message_wrote_chunk (SoupMessage *msg);
263 void soup_message_wrote_body (SoupMessage *msg);
264 void soup_message_got_informational (SoupMessage *msg);
265 void soup_message_got_headers (SoupMessage *msg);
266 void soup_message_got_chunk (SoupMessage *msg);
267 void soup_message_got_body (SoupMessage *msg);
268 void soup_message_restarted (SoupMessage *msg);
269 void soup_message_finished (SoupMessage *msg);
271 #endif /*SOUP_MESSAGE_H*/