Remove build warning
[platform/upstream/libsoup.git] / libsoup / soup-message.h
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 *request_headers;
34
35         SoupMessageBody    *response_body;
36         SoupMessageHeaders *response_headers;
37 };
38
39 typedef 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 /* #if ENABLE(TIZEN_ON_AUTHENTICATION_REQUESTED) */
54         void     (*authenticate)        (SoupMessage *msg, SoupAuth *auth, gboolean retrying);
55 /* #endif */
56
57         /* Padding for future expansion */
58         void (*_libsoup_reserved1) (void);
59         void (*_libsoup_reserved2) (void);
60         void (*_libsoup_reserved3) (void);
61         void (*_libsoup_reserved4) (void);
62 } SoupMessageClass;
63
64 GType soup_message_get_type (void);
65
66 #define SOUP_MESSAGE_METHOD             "method"
67 #define SOUP_MESSAGE_URI                "uri"
68 #define SOUP_MESSAGE_HTTP_VERSION       "http-version"
69 #define SOUP_MESSAGE_FLAGS              "flags"
70 #define SOUP_MESSAGE_SERVER_SIDE        "server-side"
71 #define SOUP_MESSAGE_STATUS_CODE        "status-code"
72 #define SOUP_MESSAGE_REASON_PHRASE      "reason-phrase"
73 #define SOUP_MESSAGE_FIRST_PARTY        "first-party"
74 #define SOUP_MESSAGE_REQUEST_BODY       "request-body"
75 #define SOUP_MESSAGE_REQUEST_BODY_DATA  "request-body-data"
76 #define SOUP_MESSAGE_REQUEST_HEADERS    "request-headers"
77 #define SOUP_MESSAGE_RESPONSE_BODY      "response-body"
78 #define SOUP_MESSAGE_RESPONSE_BODY_DATA "response-body-data"
79 #define SOUP_MESSAGE_RESPONSE_HEADERS   "response-headers"
80 #define SOUP_MESSAGE_TLS_CERTIFICATE    "tls-certificate"
81 #define SOUP_MESSAGE_TLS_ERRORS         "tls-errors"
82 #define SOUP_MESSAGE_PRIORITY           "priority"
83
84 SoupMessage   *soup_message_new                 (const char        *method,
85                                                  const char        *uri_string);
86 SoupMessage   *soup_message_new_from_uri        (const char        *method,
87                                                  SoupURI           *uri);
88
89 void           soup_message_set_request         (SoupMessage       *msg,
90                                                  const char        *content_type,
91                                                  SoupMemoryUse      req_use,
92                                                  const char        *req_body,
93                                                  gsize              req_length);
94 void           soup_message_set_response        (SoupMessage       *msg,
95                                                  const char        *content_type,
96                                                  SoupMemoryUse      resp_use,
97                                                  const char        *resp_body,
98                                                  gsize              resp_length);
99
100 typedef enum {
101         SOUP_HTTP_1_0 = 0, /*< nick=http-1-0 >*/
102         SOUP_HTTP_1_1 = 1  /*< nick=http-1-1 >*/
103 } SoupHTTPVersion;
104
105 void             soup_message_set_http_version    (SoupMessage       *msg,
106                                                    SoupHTTPVersion    version);
107 SoupHTTPVersion  soup_message_get_http_version    (SoupMessage       *msg);
108
109 gboolean         soup_message_is_keepalive        (SoupMessage       *msg);
110
111 SoupURI         *soup_message_get_uri             (SoupMessage       *msg);
112 void             soup_message_set_uri             (SoupMessage       *msg,
113                                                    SoupURI           *uri);
114 SOUP_AVAILABLE_IN_2_26
115 SoupAddress     *soup_message_get_address         (SoupMessage       *msg);
116
117 SOUP_AVAILABLE_IN_2_30
118 SoupURI         *soup_message_get_first_party     (SoupMessage       *msg);
119 SOUP_AVAILABLE_IN_2_30
120 void             soup_message_set_first_party     (SoupMessage       *msg,
121                                                    SoupURI           *first_party);
122
123 typedef enum {
124         SOUP_MESSAGE_NO_REDIRECT          = (1 << 1),
125         SOUP_MESSAGE_CAN_REBUILD          = (1 << 2),
126 #ifndef SOUP_DISABLE_DEPRECATED
127         SOUP_MESSAGE_OVERWRITE_CHUNKS     = (1 << 3),
128 #endif
129         SOUP_MESSAGE_CONTENT_DECODED      = (1 << 4),
130         SOUP_MESSAGE_CERTIFICATE_TRUSTED  = (1 << 5),
131         SOUP_MESSAGE_NEW_CONNECTION       = (1 << 6),
132         SOUP_MESSAGE_IDEMPOTENT           = (1 << 7)
133 } SoupMessageFlags;
134
135 void             soup_message_set_flags           (SoupMessage           *msg,
136                                                    SoupMessageFlags       flags);
137
138 SoupMessageFlags soup_message_get_flags           (SoupMessage           *msg);
139
140 SOUP_AVAILABLE_IN_2_34
141 gboolean         soup_message_get_https_status    (SoupMessage           *msg,
142                                                    GTlsCertificate      **certificate,
143                                                    GTlsCertificateFlags  *errors);
144
145
146 /* Specialized signal handlers */
147 guint          soup_message_add_header_handler  (SoupMessage       *msg,
148                                                  const char        *signal,
149                                                  const char        *header,
150                                                  GCallback          callback,
151                                                  gpointer           user_data);
152
153 guint          soup_message_add_status_code_handler (
154                                                  SoupMessage       *msg,
155                                                  const char        *signal,
156                                                  guint              status_code,
157                                                  GCallback          callback,
158                                                  gpointer           user_data);
159
160 /*
161  * Status Setting
162  */
163 void           soup_message_set_status          (SoupMessage       *msg, 
164                                                  guint              status_code);
165
166 void           soup_message_set_status_full     (SoupMessage       *msg, 
167                                                  guint              status_code, 
168                                                  const char        *reason_phrase);
169
170 SOUP_AVAILABLE_IN_2_38
171 void           soup_message_set_redirect        (SoupMessage       *msg,
172                                                  guint              status_code,
173                                                  const char        *redirect_uri);
174
175 /* I/O */
176 #ifndef SOUP_DISABLE_DEPRECATED
177 typedef SoupBuffer * (*SoupChunkAllocator)      (SoupMessage       *msg,
178                                                  gsize              max_len,
179                                                  gpointer           user_data);
180
181 SOUP_DEPRECATED_IN_2_42_FOR(SoupRequest)
182 void           soup_message_set_chunk_allocator (SoupMessage       *msg,
183                                                  SoupChunkAllocator allocator,
184                                                  gpointer           user_data,
185                                                  GDestroyNotify     destroy_notify);
186 #endif
187
188 SOUP_AVAILABLE_IN_2_28
189 void           soup_message_disable_feature     (SoupMessage       *msg,
190                                                  GType              feature_type);
191
192 SOUP_AVAILABLE_IN_2_42
193 SoupRequest   *soup_message_get_soup_request    (SoupMessage       *msg);
194
195
196 typedef enum {
197         SOUP_MESSAGE_PRIORITY_VERY_LOW = 0,
198         SOUP_MESSAGE_PRIORITY_LOW,
199         SOUP_MESSAGE_PRIORITY_NORMAL,
200         SOUP_MESSAGE_PRIORITY_HIGH,
201         SOUP_MESSAGE_PRIORITY_VERY_HIGH
202 } SoupMessagePriority;
203
204 SOUP_AVAILABLE_IN_2_44
205 void                soup_message_set_priority   (SoupMessage        *msg,
206                                                  SoupMessagePriority priority);
207
208
209 SOUP_AVAILABLE_IN_2_44
210 SoupMessagePriority soup_message_get_priority   (SoupMessage        *msg);
211
212 void soup_message_wrote_informational (SoupMessage *msg);
213 void soup_message_wrote_headers       (SoupMessage *msg);
214 void soup_message_wrote_chunk         (SoupMessage *msg);
215 void soup_message_wrote_body_data     (SoupMessage *msg, SoupBuffer *chunk);
216 void soup_message_wrote_body          (SoupMessage *msg);
217 void soup_message_got_informational   (SoupMessage *msg);
218 void soup_message_got_headers         (SoupMessage *msg);
219 void soup_message_got_chunk           (SoupMessage *msg, SoupBuffer *chunk);
220 void soup_message_got_body            (SoupMessage *msg);
221 void soup_message_content_sniffed     (SoupMessage *msg, const char *content_type, GHashTable *params);
222 void soup_message_restarted           (SoupMessage *msg);
223 void soup_message_finished            (SoupMessage *msg);
224 /* #if ENABLE(TIZEN_ON_AUTHENTICATION_REQUESTED) */
225 void soup_message_authenticate        (SoupMessage *msg, SoupAuth *auth, gboolean retrying);
226 /* #endif */
227
228 G_END_DECLS
229
230 #endif /*SOUP_MESSAGE_H*/