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_SESSION_H__
7#define __SOUP_SESSION_H__ 1
8
9#include <libsoup/soup-types.h>
10#include <libsoup/soup-address.h>
11#include <libsoup/soup-message.h>
12#include <libsoup/soup-websocket-connection.h>
13
14G_BEGIN_DECLS
15
16#define SOUP_TYPE_SESSION (soup_session_get_type ())
17#define SOUP_SESSION(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SOUP_TYPE_SESSION, SoupSession))
18#define SOUP_SESSION_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SOUP_TYPE_SESSION, SoupSessionClass))
19#define SOUP_IS_SESSION(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SOUP_TYPE_SESSION))
20#define SOUP_IS_SESSION_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((obj), SOUP_TYPE_SESSION))
21#define SOUP_SESSION_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), SOUP_TYPE_SESSION, SoupSessionClass))
22
23typedef void (*SoupSessionCallback) (SoupSession *session,
24 SoupMessage *msg,
25 gpointer user_data);
26
27struct _SoupSession {
28 GObject parent;
29
30};
31
32typedef struct {
33 GObjectClass parent_class;
34
35 /* signals */
36 void (*request_started) (SoupSession *session, SoupMessage *msg,
37 SoupSocket *socket);
38 void (*authenticate) (SoupSession *session, SoupMessage *msg,
39 SoupAuth *auth, gboolean retrying);
40
41 /* methods */
42 void (*queue_message) (SoupSession *session, SoupMessage *msg,
43 SoupSessionCallback callback,
44 gpointer user_data);
45 void (*requeue_message) (SoupSession *session, SoupMessage *msg);
46 guint (*send_message) (SoupSession *session, SoupMessage *msg);
47
48 void (*cancel_message) (SoupSession *session, SoupMessage *msg,
49 guint status_code);
50
51 void (*auth_required) (SoupSession *session, SoupMessage *msg,
52 SoupAuth *auth, gboolean retrying);
53
54 void (*flush_queue) (SoupSession *session);
55
56 void (*kick) (SoupSession *session);
57
58 /* Padding for future expansion */
59 void (*_libsoup_reserved4) (void);
60} SoupSessionClass;
61
62SOUP_AVAILABLE_IN_2_42
63GType soup_session_get_type (void);
64
65#define SOUP_SESSION_LOCAL_ADDRESS "local-address"
66#define SOUP_SESSION_PROXY_URI "proxy-uri"
67#define SOUP_SESSION_PROXY_RESOLVER "proxy-resolver"
68#define SOUP_SESSION_MAX_CONNS "max-conns"
69#define SOUP_SESSION_MAX_CONNS_PER_HOST "max-conns-per-host"
70#define SOUP_SESSION_USE_NTLM "use-ntlm"
71#define SOUP_SESSION_SSL_CA_FILE "ssl-ca-file"
72#define SOUP_SESSION_SSL_USE_SYSTEM_CA_FILE "ssl-use-system-ca-file"
73#define SOUP_SESSION_TLS_DATABASE "tls-database"
74#define SOUP_SESSION_SSL_STRICT "ssl-strict"
75#define SOUP_SESSION_TLS_INTERACTION "tls-interaction"
76#define SOUP_SESSION_ASYNC_CONTEXT "async-context"
77#define SOUP_SESSION_USE_THREAD_CONTEXT "use-thread-context"
78#define SOUP_SESSION_TIMEOUT "timeout"
79#define SOUP_SESSION_USER_AGENT "user-agent"
80#define SOUP_SESSION_ACCEPT_LANGUAGE "accept-language"
81#define SOUP_SESSION_ACCEPT_LANGUAGE_AUTO "accept-language-auto"
82#define SOUP_SESSION_IDLE_TIMEOUT "idle-timeout"
83#define SOUP_SESSION_ADD_FEATURE "add-feature"
84#define SOUP_SESSION_ADD_FEATURE_BY_TYPE "add-feature-by-type"
85#define SOUP_SESSION_REMOVE_FEATURE_BY_TYPE "remove-feature-by-type"
86#define SOUP_SESSION_HTTP_ALIASES "http-aliases"
87#define SOUP_SESSION_HTTPS_ALIASES "https-aliases"
88
89SOUP_AVAILABLE_IN_2_42
90SoupSession *soup_session_new (void);
91
92SOUP_AVAILABLE_IN_2_42
93SoupSession *soup_session_new_with_options (const char *optname1,
94 ...) G_GNUC_NULL_TERMINATED;
95
96SOUP_AVAILABLE_IN_2_4
97void soup_session_queue_message (SoupSession *session,
98 SoupMessage *msg,
99 SoupSessionCallback callback,
100 gpointer user_data);
101SOUP_AVAILABLE_IN_2_4
102void soup_session_requeue_message (SoupSession *session,
103 SoupMessage *msg);
104
105SOUP_AVAILABLE_IN_2_4
106guint soup_session_send_message (SoupSession *session,
107 SoupMessage *msg);
108
109SOUP_AVAILABLE_IN_2_4
110void soup_session_pause_message (SoupSession *session,
111 SoupMessage *msg);
112SOUP_AVAILABLE_IN_2_4
113void soup_session_unpause_message (SoupSession *session,
114 SoupMessage *msg);
115
116SOUP_AVAILABLE_IN_2_4
117void soup_session_cancel_message (SoupSession *session,
118 SoupMessage *msg,
119 guint status_code);
120SOUP_AVAILABLE_IN_2_4
121void soup_session_abort (SoupSession *session);
122
123SOUP_AVAILABLE_IN_2_4
124GMainContext *soup_session_get_async_context(SoupSession *session);
125
126SOUP_AVAILABLE_IN_2_42
127void soup_session_send_async (SoupSession *session,
128 SoupMessage *msg,
129 GCancellable *cancellable,
130 GAsyncReadyCallback callback,
131 gpointer user_data);
132SOUP_AVAILABLE_IN_2_42
133GInputStream *soup_session_send_finish (SoupSession *session,
134 GAsyncResult *result,
135 GError **error);
136SOUP_AVAILABLE_IN_2_42
137GInputStream *soup_session_send (SoupSession *session,
138 SoupMessage *msg,
139 GCancellable *cancellable,
140 GError **error);
141
142#ifndef SOUP_DISABLE_DEPRECATED
143SOUP_AVAILABLE_IN_2_30
144SOUP_DEPRECATED_IN_2_38_FOR (soup_session_prefetch_dns)
145void soup_session_prepare_for_uri (SoupSession *session,
146 SoupURI *uri);
147#endif
148
149SOUP_AVAILABLE_IN_2_38
150void soup_session_prefetch_dns (SoupSession *session,
151 const char *hostname,
152 GCancellable *cancellable,
153 SoupAddressCallback callback,
154 gpointer user_data);
155
156SOUP_AVAILABLE_IN_2_38
157gboolean soup_session_would_redirect (SoupSession *session,
158 SoupMessage *msg);
159SOUP_AVAILABLE_IN_2_38
160gboolean soup_session_redirect_message (SoupSession *session,
161 SoupMessage *msg);
162
163SOUP_AVAILABLE_IN_2_24
164void soup_session_add_feature (SoupSession *session,
165 SoupSessionFeature *feature);
166SOUP_AVAILABLE_IN_2_24
167void soup_session_add_feature_by_type (SoupSession *session,
168 GType feature_type);
169SOUP_AVAILABLE_IN_2_24
170void soup_session_remove_feature (SoupSession *session,
171 SoupSessionFeature *feature);
172SOUP_AVAILABLE_IN_2_24
173void soup_session_remove_feature_by_type (SoupSession *session,
174 GType feature_type);
175SOUP_AVAILABLE_IN_2_42
176gboolean soup_session_has_feature (SoupSession *session,
177 GType feature_type);
178SOUP_AVAILABLE_IN_2_26
179GSList *soup_session_get_features (SoupSession *session,
180 GType feature_type);
181SOUP_AVAILABLE_IN_2_26
182SoupSessionFeature *soup_session_get_feature (SoupSession *session,
183 GType feature_type);
184SOUP_AVAILABLE_IN_2_28
185SoupSessionFeature *soup_session_get_feature_for_message(SoupSession *session,
186 GType feature_type,
187 SoupMessage *msg);
188
189SOUP_AVAILABLE_IN_2_42
190SoupRequest *soup_session_request (SoupSession *session,
191 const char *uri_string,
192 GError **error);
193SOUP_AVAILABLE_IN_2_42
194SoupRequest *soup_session_request_uri (SoupSession *session,
195 SoupURI *uri,
196 GError **error);
197SOUP_AVAILABLE_IN_2_42
198SoupRequestHTTP *soup_session_request_http (SoupSession *session,
199 const char *method,
200 const char *uri_string,
201 GError **error);
202SOUP_AVAILABLE_IN_2_42
203SoupRequestHTTP *soup_session_request_http_uri (SoupSession *session,
204 const char *method,
205 SoupURI *uri,
206 GError **error);
207
208SOUP_AVAILABLE_IN_2_42
209GQuark soup_request_error_quark (void);
210#define SOUP_REQUEST_ERROR soup_request_error_quark ()
211
212typedef enum {
213 SOUP_REQUEST_ERROR_BAD_URI,
214 SOUP_REQUEST_ERROR_UNSUPPORTED_URI_SCHEME,
215 SOUP_REQUEST_ERROR_PARSING,
216 SOUP_REQUEST_ERROR_ENCODING
217} SoupRequestError;
218
219SOUP_AVAILABLE_IN_2_50
220GIOStream *soup_session_steal_connection (SoupSession *session,
221 SoupMessage *msg);
222
223SOUP_AVAILABLE_IN_2_50
224void soup_session_websocket_connect_async (SoupSession *session,
225 SoupMessage *msg,
226 const char *origin,
227 char **protocols,
228 GCancellable *cancellable,
229 GAsyncReadyCallback callback,
230 gpointer user_data);
231
232SOUP_AVAILABLE_IN_2_50
233SoupWebsocketConnection *soup_session_websocket_connect_finish (SoupSession *session,
234 GAsyncResult *result,
235 GError **error);
236
237typedef void (*SoupSessionConnectProgressCallback) (SoupSession *session,
238 GSocketClientEvent event,
239 GIOStream *connection,
240 gpointer user_data);
241
242SOUP_AVAILABLE_IN_2_62
243void soup_session_connect_async (SoupSession *session,
244 SoupURI *uri,
245 GCancellable *cancellable,
246 SoupSessionConnectProgressCallback progress_callback,
247 GAsyncReadyCallback callback,
248 gpointer user_data);
249
250SOUP_AVAILABLE_IN_2_62
251GIOStream *soup_session_connect_finish (SoupSession *session,
252 GAsyncResult *result,
253 GError **error);
254
255G_END_DECLS
256
257#endif /* __SOUP_SESSION_H__ */
258