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 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_SITE_FOR_COOKIES "site-for-cookies" 73 #define SOUP_MESSAGE_REQUEST_BODY "request-body" 74 #define SOUP_MESSAGE_REQUEST_BODY_DATA "request-body-data" 75 #define SOUP_MESSAGE_REQUEST_HEADERS "request-headers" 76 #define SOUP_MESSAGE_RESPONSE_BODY "response-body" 77 #define SOUP_MESSAGE_RESPONSE_BODY_DATA "response-body-data" 78 #define SOUP_MESSAGE_RESPONSE_HEADERS "response-headers" 79 #define SOUP_MESSAGE_TLS_CERTIFICATE "tls-certificate" 80 #define SOUP_MESSAGE_TLS_ERRORS "tls-errors" 81 #define SOUP_MESSAGE_PRIORITY "priority" 82 #define SOUP_MESSAGE_IS_TOP_LEVEL_NAVIGATION "is-top-level-navigation" 83 84 SOUP_AVAILABLE_IN_2_4 85 SoupMessage *soup_message_new (const char *method, 86 const char *uri_string); 87 SOUP_AVAILABLE_IN_2_4 88 SoupMessage *soup_message_new_from_uri (const char *method, 89 SoupURI *uri); 90 91 SOUP_AVAILABLE_IN_2_4 92 void soup_message_set_request (SoupMessage *msg, 93 const char *content_type, 94 SoupMemoryUse req_use, 95 const char *req_body, 96 gsize req_length); 97 SOUP_AVAILABLE_IN_2_4 98 void soup_message_set_response (SoupMessage *msg, 99 const char *content_type, 100 SoupMemoryUse resp_use, 101 const char *resp_body, 102 gsize resp_length); 103 104 typedef enum { 105 SOUP_HTTP_1_0 = 0, /*< nick=http-1-0 >*/ 106 SOUP_HTTP_1_1 = 1 /*< nick=http-1-1 >*/ 107 } SoupHTTPVersion; 108 109 SOUP_AVAILABLE_IN_2_4 110 void soup_message_set_http_version (SoupMessage *msg, 111 SoupHTTPVersion version); 112 SOUP_AVAILABLE_IN_2_4 113 SoupHTTPVersion soup_message_get_http_version (SoupMessage *msg); 114 115 SOUP_AVAILABLE_IN_2_4 116 gboolean soup_message_is_keepalive (SoupMessage *msg); 117 118 SOUP_AVAILABLE_IN_2_4 119 SoupURI *soup_message_get_uri (SoupMessage *msg); 120 SOUP_AVAILABLE_IN_2_4 121 void soup_message_set_uri (SoupMessage *msg, 122 SoupURI *uri); 123 SOUP_AVAILABLE_IN_2_26 124 SoupAddress *soup_message_get_address (SoupMessage *msg); 125 126 SOUP_AVAILABLE_IN_2_30 127 SoupURI *soup_message_get_first_party (SoupMessage *msg); 128 SOUP_AVAILABLE_IN_2_30 129 void soup_message_set_first_party (SoupMessage *msg, 130 SoupURI *first_party); 131 SOUP_AVAILABLE_IN_2_70 132 SoupURI *soup_message_get_site_for_cookies (SoupMessage *msg); 133 SOUP_AVAILABLE_IN_2_70 134 void soup_message_set_site_for_cookies (SoupMessage *msg, 135 SoupURI *site_for_cookies); 136 SOUP_AVAILABLE_IN_2_70 137 void soup_message_set_is_top_level_navigation (SoupMessage *msg, 138 gboolean is_top_level_navigation); 139 SOUP_AVAILABLE_IN_2_70 140 gboolean soup_message_get_is_top_level_navigation (SoupMessage *msg); 141 142 typedef enum { 143 SOUP_MESSAGE_NO_REDIRECT = (1 << 1), 144 SOUP_MESSAGE_CAN_REBUILD = (1 << 2), 145 #ifndef SOUP_DISABLE_DEPRECATED 146 SOUP_MESSAGE_OVERWRITE_CHUNKS = (1 << 3), 147 #endif 148 SOUP_MESSAGE_CONTENT_DECODED = (1 << 4), 149 SOUP_MESSAGE_CERTIFICATE_TRUSTED = (1 << 5), 150 SOUP_MESSAGE_NEW_CONNECTION = (1 << 6), 151 SOUP_MESSAGE_IDEMPOTENT = (1 << 7), 152 SOUP_MESSAGE_IGNORE_CONNECTION_LIMITS = (1 << 8), 153 SOUP_MESSAGE_DO_NOT_USE_AUTH_CACHE = (1 << 9) 154 } SoupMessageFlags; 155 156 SOUP_AVAILABLE_IN_2_4 157 void soup_message_set_flags (SoupMessage *msg, 158 SoupMessageFlags flags); 159 160 SOUP_AVAILABLE_IN_2_4 161 SoupMessageFlags soup_message_get_flags (SoupMessage *msg); 162 163 SOUP_AVAILABLE_IN_2_34 164 gboolean soup_message_get_https_status (SoupMessage *msg, 165 GTlsCertificate **certificate, 166 GTlsCertificateFlags *errors); 167 168 169 /* Specialized signal handlers */ 170 SOUP_AVAILABLE_IN_2_4 171 guint soup_message_add_header_handler (SoupMessage *msg, 172 const char *signal, 173 const char *header, 174 GCallback callback, 175 gpointer user_data); 176 177 SOUP_AVAILABLE_IN_2_4 178 guint soup_message_add_status_code_handler ( 179 SoupMessage *msg, 180 const char *signal, 181 guint status_code, 182 GCallback callback, 183 gpointer user_data); 184 185 /* 186 * Status Setting 187 */ 188 SOUP_AVAILABLE_IN_2_4 189 void soup_message_set_status (SoupMessage *msg, 190 guint status_code); 191 192 SOUP_AVAILABLE_IN_2_4 193 void soup_message_set_status_full (SoupMessage *msg, 194 guint status_code, 195 const char *reason_phrase); 196 197 SOUP_AVAILABLE_IN_2_38 198 void soup_message_set_redirect (SoupMessage *msg, 199 guint status_code, 200 const char *redirect_uri); 201 202 /* I/O */ 203 #ifndef SOUP_DISABLE_DEPRECATED 204 typedef SoupBuffer * (*SoupChunkAllocator) (SoupMessage *msg, 205 gsize max_len, 206 gpointer user_data); 207 208 SOUP_AVAILABLE_IN_2_4 209 SOUP_DEPRECATED_IN_2_42_FOR(SoupRequest) 210 void soup_message_set_chunk_allocator (SoupMessage *msg, 211 SoupChunkAllocator allocator, 212 gpointer user_data, 213 GDestroyNotify destroy_notify); 214 #endif 215 216 SOUP_AVAILABLE_IN_2_28 217 void soup_message_disable_feature (SoupMessage *msg, 218 GType feature_type); 219 220 SOUP_AVAILABLE_IN_2_72 221 gboolean soup_message_is_feature_disabled (SoupMessage *msg, 222 GType feature_type); 223 224 SOUP_AVAILABLE_IN_2_42 225 SoupRequest *soup_message_get_soup_request (SoupMessage *msg); 226 227 228 typedef enum { 229 SOUP_MESSAGE_PRIORITY_VERY_LOW = 0, 230 SOUP_MESSAGE_PRIORITY_LOW, 231 SOUP_MESSAGE_PRIORITY_NORMAL, 232 SOUP_MESSAGE_PRIORITY_HIGH, 233 SOUP_MESSAGE_PRIORITY_VERY_HIGH 234 } SoupMessagePriority; 235 236 SOUP_AVAILABLE_IN_2_44 237 void soup_message_set_priority (SoupMessage *msg, 238 SoupMessagePriority priority); 239 240 241 SOUP_AVAILABLE_IN_2_44 242 SoupMessagePriority soup_message_get_priority (SoupMessage *msg); 243 244 SOUP_AVAILABLE_IN_2_4 245 void soup_message_wrote_informational (SoupMessage *msg); 246 SOUP_AVAILABLE_IN_2_4 247 void soup_message_wrote_headers (SoupMessage *msg); 248 SOUP_AVAILABLE_IN_2_4 249 void soup_message_wrote_chunk (SoupMessage *msg); 250 SOUP_AVAILABLE_IN_2_4 251 void soup_message_wrote_body_data (SoupMessage *msg, SoupBuffer *chunk); 252 SOUP_AVAILABLE_IN_2_4 253 void soup_message_wrote_body (SoupMessage *msg); 254 SOUP_AVAILABLE_IN_2_4 255 void soup_message_got_informational (SoupMessage *msg); 256 SOUP_AVAILABLE_IN_2_4 257 void soup_message_got_headers (SoupMessage *msg); 258 SOUP_AVAILABLE_IN_2_4 259 void soup_message_got_chunk (SoupMessage *msg, SoupBuffer *chunk); 260 SOUP_AVAILABLE_IN_2_4 261 void soup_message_got_body (SoupMessage *msg); 262 SOUP_AVAILABLE_IN_2_4 263 void soup_message_content_sniffed (SoupMessage *msg, const char *content_type, GHashTable *params); 264 265 SOUP_AVAILABLE_IN_2_50 266 void soup_message_starting (SoupMessage *msg); 267 268 SOUP_AVAILABLE_IN_2_4 269 void soup_message_restarted (SoupMessage *msg); 270 SOUP_AVAILABLE_IN_2_4 271 void soup_message_finished (SoupMessage *msg); 272 273 G_END_DECLS 274 275 #endif /* __SOUP_MESSAGE_H__ */ 276