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 | |
14 | G_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 | |
23 | struct _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 *; |
34 | |
35 | SoupMessageBody *response_body; |
36 | SoupMessageHeaders *; |
37 | }; |
38 | |
39 | typedef struct { |
40 | GObjectClass parent_class; |
41 | |
42 | /* signals */ |
43 | void (*wrote_informational) (SoupMessage *msg); |
44 | void (*) (SoupMessage *msg); |
45 | void (*wrote_chunk) (SoupMessage *msg); |
46 | void (*wrote_body) (SoupMessage *msg); |
47 | void (*got_informational) (SoupMessage *msg); |
48 | void (*) (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 | |
61 | SOUP_AVAILABLE_IN_2_4 |
62 | GType 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 "request-headers" |
75 | #define SOUP_MESSAGE_RESPONSE_BODY "response-body" |
76 | #define SOUP_MESSAGE_RESPONSE_BODY_DATA "response-body-data" |
77 | #define "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 | |
82 | SOUP_AVAILABLE_IN_2_4 |
83 | SoupMessage *soup_message_new (const char *method, |
84 | const char *uri_string); |
85 | SOUP_AVAILABLE_IN_2_4 |
86 | SoupMessage *soup_message_new_from_uri (const char *method, |
87 | SoupURI *uri); |
88 | |
89 | SOUP_AVAILABLE_IN_2_4 |
90 | void soup_message_set_request (SoupMessage *msg, |
91 | const char *content_type, |
92 | SoupMemoryUse req_use, |
93 | const char *req_body, |
94 | gsize req_length); |
95 | SOUP_AVAILABLE_IN_2_4 |
96 | void 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 | |
102 | typedef enum { |
103 | SOUP_HTTP_1_0 = 0, /*< nick=http-1-0 >*/ |
104 | SOUP_HTTP_1_1 = 1 /*< nick=http-1-1 >*/ |
105 | } SoupHTTPVersion; |
106 | |
107 | SOUP_AVAILABLE_IN_2_4 |
108 | void soup_message_set_http_version (SoupMessage *msg, |
109 | SoupHTTPVersion version); |
110 | SOUP_AVAILABLE_IN_2_4 |
111 | SoupHTTPVersion soup_message_get_http_version (SoupMessage *msg); |
112 | |
113 | SOUP_AVAILABLE_IN_2_4 |
114 | gboolean soup_message_is_keepalive (SoupMessage *msg); |
115 | |
116 | SOUP_AVAILABLE_IN_2_4 |
117 | SoupURI *soup_message_get_uri (SoupMessage *msg); |
118 | SOUP_AVAILABLE_IN_2_4 |
119 | void soup_message_set_uri (SoupMessage *msg, |
120 | SoupURI *uri); |
121 | SOUP_AVAILABLE_IN_2_26 |
122 | SoupAddress *soup_message_get_address (SoupMessage *msg); |
123 | |
124 | SOUP_AVAILABLE_IN_2_30 |
125 | SoupURI *soup_message_get_first_party (SoupMessage *msg); |
126 | SOUP_AVAILABLE_IN_2_30 |
127 | void soup_message_set_first_party (SoupMessage *msg, |
128 | SoupURI *first_party); |
129 | |
130 | typedef 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 | |
144 | SOUP_AVAILABLE_IN_2_4 |
145 | void soup_message_set_flags (SoupMessage *msg, |
146 | SoupMessageFlags flags); |
147 | |
148 | SOUP_AVAILABLE_IN_2_4 |
149 | SoupMessageFlags soup_message_get_flags (SoupMessage *msg); |
150 | |
151 | SOUP_AVAILABLE_IN_2_34 |
152 | gboolean soup_message_get_https_status (SoupMessage *msg, |
153 | GTlsCertificate **certificate, |
154 | GTlsCertificateFlags *errors); |
155 | |
156 | |
157 | /* Specialized signal handlers */ |
158 | SOUP_AVAILABLE_IN_2_4 |
159 | guint soup_message_add_header_handler (SoupMessage *msg, |
160 | const char *signal, |
161 | const char *, |
162 | GCallback callback, |
163 | gpointer user_data); |
164 | |
165 | SOUP_AVAILABLE_IN_2_4 |
166 | guint 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 | */ |
176 | SOUP_AVAILABLE_IN_2_4 |
177 | void soup_message_set_status (SoupMessage *msg, |
178 | guint status_code); |
179 | |
180 | SOUP_AVAILABLE_IN_2_4 |
181 | void soup_message_set_status_full (SoupMessage *msg, |
182 | guint status_code, |
183 | const char *reason_phrase); |
184 | |
185 | SOUP_AVAILABLE_IN_2_38 |
186 | void soup_message_set_redirect (SoupMessage *msg, |
187 | guint status_code, |
188 | const char *redirect_uri); |
189 | |
190 | /* I/O */ |
191 | #ifndef SOUP_DISABLE_DEPRECATED |
192 | typedef SoupBuffer * (*SoupChunkAllocator) (SoupMessage *msg, |
193 | gsize max_len, |
194 | gpointer user_data); |
195 | |
196 | SOUP_AVAILABLE_IN_2_4 |
197 | SOUP_DEPRECATED_IN_2_42_FOR(SoupRequest) |
198 | void soup_message_set_chunk_allocator (SoupMessage *msg, |
199 | SoupChunkAllocator allocator, |
200 | gpointer user_data, |
201 | GDestroyNotify destroy_notify); |
202 | #endif |
203 | |
204 | SOUP_AVAILABLE_IN_2_28 |
205 | void soup_message_disable_feature (SoupMessage *msg, |
206 | GType feature_type); |
207 | |
208 | SOUP_AVAILABLE_IN_2_42 |
209 | SoupRequest *soup_message_get_soup_request (SoupMessage *msg); |
210 | |
211 | |
212 | typedef 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 | |
220 | SOUP_AVAILABLE_IN_2_44 |
221 | void soup_message_set_priority (SoupMessage *msg, |
222 | SoupMessagePriority priority); |
223 | |
224 | |
225 | SOUP_AVAILABLE_IN_2_44 |
226 | SoupMessagePriority soup_message_get_priority (SoupMessage *msg); |
227 | |
228 | SOUP_AVAILABLE_IN_2_4 |
229 | void soup_message_wrote_informational (SoupMessage *msg); |
230 | SOUP_AVAILABLE_IN_2_4 |
231 | void (SoupMessage *msg); |
232 | SOUP_AVAILABLE_IN_2_4 |
233 | void soup_message_wrote_chunk (SoupMessage *msg); |
234 | SOUP_AVAILABLE_IN_2_4 |
235 | void soup_message_wrote_body_data (SoupMessage *msg, SoupBuffer *chunk); |
236 | SOUP_AVAILABLE_IN_2_4 |
237 | void soup_message_wrote_body (SoupMessage *msg); |
238 | SOUP_AVAILABLE_IN_2_4 |
239 | void soup_message_got_informational (SoupMessage *msg); |
240 | SOUP_AVAILABLE_IN_2_4 |
241 | void (SoupMessage *msg); |
242 | SOUP_AVAILABLE_IN_2_4 |
243 | void soup_message_got_chunk (SoupMessage *msg, SoupBuffer *chunk); |
244 | SOUP_AVAILABLE_IN_2_4 |
245 | void soup_message_got_body (SoupMessage *msg); |
246 | SOUP_AVAILABLE_IN_2_4 |
247 | void soup_message_content_sniffed (SoupMessage *msg, const char *content_type, GHashTable *params); |
248 | |
249 | SOUP_AVAILABLE_IN_2_50 |
250 | void soup_message_starting (SoupMessage *msg); |
251 | |
252 | SOUP_AVAILABLE_IN_2_4 |
253 | void soup_message_restarted (SoupMessage *msg); |
254 | SOUP_AVAILABLE_IN_2_4 |
255 | void soup_message_finished (SoupMessage *msg); |
256 | |
257 | G_END_DECLS |
258 | |
259 | #endif /* __SOUP_MESSAGE_H__ */ |
260 | |