1/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
2/*
3 * Copyright (C) 2000-2003, Ximian, Inc.
4 */
5
6#ifndef __SOUP_MESSAGE_H__
7#define __SOUP_MESSAGE_H__ 1
8
9#include <libsoup/soup-types.h>
10#include <libsoup/soup-message-body.h>
11#include <libsoup/soup-message-headers.h>
12#include <libsoup/soup-method.h>
13
14G_BEGIN_DECLS
15
16#define SOUP_TYPE_MESSAGE (soup_message_get_type ())
17#define SOUP_MESSAGE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SOUP_TYPE_MESSAGE, SoupMessage))
18#define SOUP_MESSAGE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SOUP_TYPE_MESSAGE, SoupMessageClass))
19#define SOUP_IS_MESSAGE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SOUP_TYPE_MESSAGE))
20#define SOUP_IS_MESSAGE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((obj), SOUP_TYPE_MESSAGE))
21#define SOUP_MESSAGE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), SOUP_TYPE_MESSAGE, SoupMessageClass))
22
23struct _SoupMessage {
24 GObject parent;
25
26 /*< public >*/
27 const char *method;
28
29 guint status_code;
30 char *reason_phrase;
31
32 SoupMessageBody *request_body;
33 SoupMessageHeaders *request_headers;
34
35 SoupMessageBody *response_body;
36 SoupMessageHeaders *response_headers;
37};
38
39typedef struct {
40 GObjectClass parent_class;
41
42 /* signals */
43 void (*wrote_informational) (SoupMessage *msg);
44 void (*wrote_headers) (SoupMessage *msg);
45 void (*wrote_chunk) (SoupMessage *msg);
46 void (*wrote_body) (SoupMessage *msg);
47 void (*got_informational) (SoupMessage *msg);
48 void (*got_headers) (SoupMessage *msg);
49 void (*got_chunk) (SoupMessage *msg, SoupBuffer *chunk);
50 void (*got_body) (SoupMessage *msg);
51 void (*restarted) (SoupMessage *msg);
52 void (*finished) (SoupMessage *msg);
53 void (*starting) (SoupMessage *msg);
54
55 /* Padding for future expansion */
56 void (*_libsoup_reserved1) (void);
57 void (*_libsoup_reserved2) (void);
58 void (*_libsoup_reserved3) (void);
59} SoupMessageClass;
60
61SOUP_AVAILABLE_IN_2_4
62GType soup_message_get_type (void);
63
64#define SOUP_MESSAGE_METHOD "method"
65#define SOUP_MESSAGE_URI "uri"
66#define SOUP_MESSAGE_HTTP_VERSION "http-version"
67#define SOUP_MESSAGE_FLAGS "flags"
68#define SOUP_MESSAGE_SERVER_SIDE "server-side"
69#define SOUP_MESSAGE_STATUS_CODE "status-code"
70#define SOUP_MESSAGE_REASON_PHRASE "reason-phrase"
71#define SOUP_MESSAGE_FIRST_PARTY "first-party"
72#define SOUP_MESSAGE_REQUEST_BODY "request-body"
73#define SOUP_MESSAGE_REQUEST_BODY_DATA "request-body-data"
74#define SOUP_MESSAGE_REQUEST_HEADERS "request-headers"
75#define SOUP_MESSAGE_RESPONSE_BODY "response-body"
76#define SOUP_MESSAGE_RESPONSE_BODY_DATA "response-body-data"
77#define SOUP_MESSAGE_RESPONSE_HEADERS "response-headers"
78#define SOUP_MESSAGE_TLS_CERTIFICATE "tls-certificate"
79#define SOUP_MESSAGE_TLS_ERRORS "tls-errors"
80#define SOUP_MESSAGE_PRIORITY "priority"
81
82SOUP_AVAILABLE_IN_2_4
83SoupMessage *soup_message_new (const char *method,
84 const char *uri_string);
85SOUP_AVAILABLE_IN_2_4
86SoupMessage *soup_message_new_from_uri (const char *method,
87 SoupURI *uri);
88
89SOUP_AVAILABLE_IN_2_4
90void soup_message_set_request (SoupMessage *msg,
91 const char *content_type,
92 SoupMemoryUse req_use,
93 const char *req_body,
94 gsize req_length);
95SOUP_AVAILABLE_IN_2_4
96void soup_message_set_response (SoupMessage *msg,
97 const char *content_type,
98 SoupMemoryUse resp_use,
99 const char *resp_body,
100 gsize resp_length);
101
102typedef enum {
103 SOUP_HTTP_1_0 = 0, /*< nick=http-1-0 >*/
104 SOUP_HTTP_1_1 = 1 /*< nick=http-1-1 >*/
105} SoupHTTPVersion;
106
107SOUP_AVAILABLE_IN_2_4
108void soup_message_set_http_version (SoupMessage *msg,
109 SoupHTTPVersion version);
110SOUP_AVAILABLE_IN_2_4
111SoupHTTPVersion soup_message_get_http_version (SoupMessage *msg);
112
113SOUP_AVAILABLE_IN_2_4
114gboolean soup_message_is_keepalive (SoupMessage *msg);
115
116SOUP_AVAILABLE_IN_2_4
117SoupURI *soup_message_get_uri (SoupMessage *msg);
118SOUP_AVAILABLE_IN_2_4
119void soup_message_set_uri (SoupMessage *msg,
120 SoupURI *uri);
121SOUP_AVAILABLE_IN_2_26
122SoupAddress *soup_message_get_address (SoupMessage *msg);
123
124SOUP_AVAILABLE_IN_2_30
125SoupURI *soup_message_get_first_party (SoupMessage *msg);
126SOUP_AVAILABLE_IN_2_30
127void soup_message_set_first_party (SoupMessage *msg,
128 SoupURI *first_party);
129
130typedef enum {
131 SOUP_MESSAGE_NO_REDIRECT = (1 << 1),
132 SOUP_MESSAGE_CAN_REBUILD = (1 << 2),
133#ifndef SOUP_DISABLE_DEPRECATED
134 SOUP_MESSAGE_OVERWRITE_CHUNKS = (1 << 3),
135#endif
136 SOUP_MESSAGE_CONTENT_DECODED = (1 << 4),
137 SOUP_MESSAGE_CERTIFICATE_TRUSTED = (1 << 5),
138 SOUP_MESSAGE_NEW_CONNECTION = (1 << 6),
139 SOUP_MESSAGE_IDEMPOTENT = (1 << 7),
140 SOUP_MESSAGE_IGNORE_CONNECTION_LIMITS = (1 << 8),
141 SOUP_MESSAGE_DO_NOT_USE_AUTH_CACHE = (1 << 9)
142} SoupMessageFlags;
143
144SOUP_AVAILABLE_IN_2_4
145void soup_message_set_flags (SoupMessage *msg,
146 SoupMessageFlags flags);
147
148SOUP_AVAILABLE_IN_2_4
149SoupMessageFlags soup_message_get_flags (SoupMessage *msg);
150
151SOUP_AVAILABLE_IN_2_34
152gboolean soup_message_get_https_status (SoupMessage *msg,
153 GTlsCertificate **certificate,
154 GTlsCertificateFlags *errors);
155
156
157/* Specialized signal handlers */
158SOUP_AVAILABLE_IN_2_4
159guint soup_message_add_header_handler (SoupMessage *msg,
160 const char *signal,
161 const char *header,
162 GCallback callback,
163 gpointer user_data);
164
165SOUP_AVAILABLE_IN_2_4
166guint soup_message_add_status_code_handler (
167 SoupMessage *msg,
168 const char *signal,
169 guint status_code,
170 GCallback callback,
171 gpointer user_data);
172
173/*
174 * Status Setting
175 */
176SOUP_AVAILABLE_IN_2_4
177void soup_message_set_status (SoupMessage *msg,
178 guint status_code);
179
180SOUP_AVAILABLE_IN_2_4
181void soup_message_set_status_full (SoupMessage *msg,
182 guint status_code,
183 const char *reason_phrase);
184
185SOUP_AVAILABLE_IN_2_38
186void soup_message_set_redirect (SoupMessage *msg,
187 guint status_code,
188 const char *redirect_uri);
189
190/* I/O */
191#ifndef SOUP_DISABLE_DEPRECATED
192typedef SoupBuffer * (*SoupChunkAllocator) (SoupMessage *msg,
193 gsize max_len,
194 gpointer user_data);
195
196SOUP_AVAILABLE_IN_2_4
197SOUP_DEPRECATED_IN_2_42_FOR(SoupRequest)
198void soup_message_set_chunk_allocator (SoupMessage *msg,
199 SoupChunkAllocator allocator,
200 gpointer user_data,
201 GDestroyNotify destroy_notify);
202#endif
203
204SOUP_AVAILABLE_IN_2_28
205void soup_message_disable_feature (SoupMessage *msg,
206 GType feature_type);
207
208SOUP_AVAILABLE_IN_2_42
209SoupRequest *soup_message_get_soup_request (SoupMessage *msg);
210
211
212typedef enum {
213 SOUP_MESSAGE_PRIORITY_VERY_LOW = 0,
214 SOUP_MESSAGE_PRIORITY_LOW,
215 SOUP_MESSAGE_PRIORITY_NORMAL,
216 SOUP_MESSAGE_PRIORITY_HIGH,
217 SOUP_MESSAGE_PRIORITY_VERY_HIGH
218} SoupMessagePriority;
219
220SOUP_AVAILABLE_IN_2_44
221void soup_message_set_priority (SoupMessage *msg,
222 SoupMessagePriority priority);
223
224
225SOUP_AVAILABLE_IN_2_44
226SoupMessagePriority soup_message_get_priority (SoupMessage *msg);
227
228SOUP_AVAILABLE_IN_2_4
229void soup_message_wrote_informational (SoupMessage *msg);
230SOUP_AVAILABLE_IN_2_4
231void soup_message_wrote_headers (SoupMessage *msg);
232SOUP_AVAILABLE_IN_2_4
233void soup_message_wrote_chunk (SoupMessage *msg);
234SOUP_AVAILABLE_IN_2_4
235void soup_message_wrote_body_data (SoupMessage *msg, SoupBuffer *chunk);
236SOUP_AVAILABLE_IN_2_4
237void soup_message_wrote_body (SoupMessage *msg);
238SOUP_AVAILABLE_IN_2_4
239void soup_message_got_informational (SoupMessage *msg);
240SOUP_AVAILABLE_IN_2_4
241void soup_message_got_headers (SoupMessage *msg);
242SOUP_AVAILABLE_IN_2_4
243void soup_message_got_chunk (SoupMessage *msg, SoupBuffer *chunk);
244SOUP_AVAILABLE_IN_2_4
245void soup_message_got_body (SoupMessage *msg);
246SOUP_AVAILABLE_IN_2_4
247void soup_message_content_sniffed (SoupMessage *msg, const char *content_type, GHashTable *params);
248
249SOUP_AVAILABLE_IN_2_50
250void soup_message_starting (SoupMessage *msg);
251
252SOUP_AVAILABLE_IN_2_4
253void soup_message_restarted (SoupMessage *msg);
254SOUP_AVAILABLE_IN_2_4
255void soup_message_finished (SoupMessage *msg);
256
257G_END_DECLS
258
259#endif /* __SOUP_MESSAGE_H__ */
260