1 /* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
3 * Copyright (C) 2000-2003, Ximian, Inc.
6 #ifndef __SOUP_SERVER_H__
7 #define __SOUP_SERVER_H__ 1
9 #include <libsoup/soup-types.h>
10 #include <libsoup/soup-uri.h>
11 #include <libsoup/soup-websocket-connection.h>
15 #define SOUP_TYPE_SERVER (soup_server_get_type ())
16 #define SOUP_SERVER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SOUP_TYPE_SERVER, SoupServer))
17 #define SOUP_SERVER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SOUP_TYPE_SERVER, SoupServerClass))
18 #define SOUP_IS_SERVER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SOUP_TYPE_SERVER))
19 #define SOUP_IS_SERVER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((obj), SOUP_TYPE_SERVER))
20 #define SOUP_SERVER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), SOUP_TYPE_SERVER, SoupServerClass))
22 typedef struct SoupClientContext SoupClientContext;
24 GType soup_client_context_get_type (void);
25 #define SOUP_TYPE_CLIENT_CONTEXT (soup_client_context_get_type ())
28 SOUP_SERVER_LISTEN_HTTPS = (1 << 0),
29 SOUP_SERVER_LISTEN_IPV4_ONLY = (1 << 1),
30 SOUP_SERVER_LISTEN_IPV6_ONLY = (1 << 2)
31 } SoupServerListenOptions;
39 GObjectClass parent_class;
42 void (*request_started) (SoupServer *server, SoupMessage *msg,
43 SoupClientContext *client);
44 void (*request_read) (SoupServer *server, SoupMessage *msg,
45 SoupClientContext *client);
46 void (*request_finished) (SoupServer *server, SoupMessage *msg,
47 SoupClientContext *client);
48 void (*request_aborted) (SoupServer *server, SoupMessage *msg,
49 SoupClientContext *client);
51 /* Padding for future expansion */
52 void (*_libsoup_reserved1) (void);
53 void (*_libsoup_reserved2) (void);
54 void (*_libsoup_reserved3) (void);
55 void (*_libsoup_reserved4) (void);
59 GType soup_server_get_type (void);
61 #define SOUP_SERVER_TLS_CERTIFICATE "tls-certificate"
62 #define SOUP_SERVER_RAW_PATHS "raw-paths"
63 #define SOUP_SERVER_SERVER_HEADER "server-header"
64 #define SOUP_SERVER_HTTP_ALIASES "http-aliases"
65 #define SOUP_SERVER_HTTPS_ALIASES "https-aliases"
68 SoupServer *soup_server_new (const char *optname1,
69 ...) G_GNUC_NULL_TERMINATED;
71 SOUP_AVAILABLE_IN_2_48
72 gboolean soup_server_set_ssl_cert_file (SoupServer *server,
73 const char *ssl_cert_file,
74 const char *ssl_key_file,
77 gboolean soup_server_is_https (SoupServer *server);
79 SOUP_AVAILABLE_IN_2_48
80 gboolean soup_server_listen (SoupServer *server,
81 GSocketAddress *address,
82 SoupServerListenOptions options,
84 SOUP_AVAILABLE_IN_2_48
85 gboolean soup_server_listen_all (SoupServer *server,
87 SoupServerListenOptions options,
89 SOUP_AVAILABLE_IN_2_48
90 gboolean soup_server_listen_local (SoupServer *server,
92 SoupServerListenOptions options,
94 SOUP_AVAILABLE_IN_2_48
95 gboolean soup_server_listen_socket (SoupServer *server,
97 SoupServerListenOptions options,
99 SOUP_AVAILABLE_IN_2_48
100 gboolean soup_server_listen_fd (SoupServer *server,
102 SoupServerListenOptions options,
104 SOUP_AVAILABLE_IN_2_48
105 GSList *soup_server_get_uris (SoupServer *server);
106 SOUP_AVAILABLE_IN_2_48
107 GSList *soup_server_get_listeners (SoupServer *server);
109 SOUP_AVAILABLE_IN_2_4
110 void soup_server_disconnect (SoupServer *server);
112 SOUP_AVAILABLE_IN_2_50
113 gboolean soup_server_accept_iostream (SoupServer *server,
115 GSocketAddress *local_addr,
116 GSocketAddress *remote_addr,
119 /* Handlers and auth */
121 typedef void (*SoupServerCallback) (SoupServer *server,
125 SoupClientContext *client,
128 SOUP_AVAILABLE_IN_2_4
129 void soup_server_add_handler (SoupServer *server,
131 SoupServerCallback callback,
133 GDestroyNotify destroy);
134 SOUP_AVAILABLE_IN_2_50
135 void soup_server_add_early_handler (SoupServer *server,
137 SoupServerCallback callback,
139 GDestroyNotify destroy);
141 #define SOUP_SERVER_ADD_WEBSOCKET_EXTENSION "add-websocket-extension"
142 #define SOUP_SERVER_REMOVE_WEBSOCKET_EXTENSION "remove-websocket-extension"
144 typedef void (*SoupServerWebsocketCallback) (SoupServer *server,
145 SoupWebsocketConnection *connection,
147 SoupClientContext *client,
149 SOUP_AVAILABLE_IN_2_50
150 void soup_server_add_websocket_handler (SoupServer *server,
154 SoupServerWebsocketCallback callback,
156 GDestroyNotify destroy);
157 SOUP_AVAILABLE_IN_2_68
158 void soup_server_add_websocket_extension (SoupServer *server,
159 GType extension_type);
160 SOUP_AVAILABLE_IN_2_68
161 void soup_server_remove_websocket_extension (SoupServer *server,
162 GType extension_type);
164 SOUP_AVAILABLE_IN_2_4
165 void soup_server_remove_handler (SoupServer *server,
168 SOUP_AVAILABLE_IN_2_4
169 void soup_server_add_auth_domain (SoupServer *server,
170 SoupAuthDomain *auth_domain);
171 SOUP_AVAILABLE_IN_2_4
172 void soup_server_remove_auth_domain (SoupServer *server,
173 SoupAuthDomain *auth_domain);
176 SOUP_AVAILABLE_IN_2_4
177 void soup_server_pause_message (SoupServer *server,
179 SOUP_AVAILABLE_IN_2_4
180 void soup_server_unpause_message (SoupServer *server,
185 SOUP_AVAILABLE_IN_2_48
186 GSocket *soup_client_context_get_gsocket (SoupClientContext *client);
187 SOUP_AVAILABLE_IN_2_48
188 GSocketAddress *soup_client_context_get_local_address (SoupClientContext *client);
189 SOUP_AVAILABLE_IN_2_48
190 GSocketAddress *soup_client_context_get_remote_address (SoupClientContext *client);
191 SOUP_AVAILABLE_IN_2_4
192 const char *soup_client_context_get_host (SoupClientContext *client);
193 SOUP_AVAILABLE_IN_2_4
194 SoupAuthDomain *soup_client_context_get_auth_domain (SoupClientContext *client);
195 SOUP_AVAILABLE_IN_2_4
196 const char *soup_client_context_get_auth_user (SoupClientContext *client);
198 SOUP_AVAILABLE_IN_2_50
199 GIOStream *soup_client_context_steal_connection (SoupClientContext *client);
203 #define SOUP_SERVER_PORT "port"
204 #define SOUP_SERVER_INTERFACE "interface"
205 #define SOUP_SERVER_ASYNC_CONTEXT "async-context"
206 #define SOUP_SERVER_SSL_CERT_FILE "ssl-cert-file"
207 #define SOUP_SERVER_SSL_KEY_FILE "ssl-key-file"
209 SOUP_AVAILABLE_IN_2_4
210 SOUP_DEPRECATED_IN_2_48
211 guint soup_server_get_port (SoupServer *server);
213 SOUP_AVAILABLE_IN_2_4
214 SOUP_DEPRECATED_IN_2_48
215 SoupSocket *soup_server_get_listener (SoupServer *server);
217 SOUP_AVAILABLE_IN_2_4
218 SOUP_DEPRECATED_IN_2_48
219 GMainContext *soup_server_get_async_context (SoupServer *server);
221 SOUP_AVAILABLE_IN_2_4
222 SOUP_DEPRECATED_IN_2_48
223 void soup_server_run (SoupServer *server);
224 SOUP_AVAILABLE_IN_2_4
225 SOUP_DEPRECATED_IN_2_48
226 void soup_server_run_async (SoupServer *server);
227 SOUP_AVAILABLE_IN_2_4
228 SOUP_DEPRECATED_IN_2_48
229 void soup_server_quit (SoupServer *server);
231 SOUP_AVAILABLE_IN_2_4
232 SOUP_DEPRECATED_IN_2_48
233 SoupAddress *soup_client_context_get_address (SoupClientContext *client);
234 SOUP_AVAILABLE_IN_2_4
235 SOUP_DEPRECATED_IN_2_48
236 SoupSocket *soup_client_context_get_socket (SoupClientContext *client);
240 #endif /* __SOUP_SERVER_H__ */