2010-10-13 Sergio Villar Senin <svillar@igalia.com>
[WebKit-https.git] / WebCore / platform / network / soup / cache / soup-request.h
1 /* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
2 /*
3  * Copyright (C) 2009 Red Hat, Inc.
4  * Copyright (C) 2010 Igalia, S.L.
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Library General Public
8  * License as published by the Free Software Foundation; either
9  * version 2 of the License, or (at your option) any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14  * Library General Public License for more details.
15  *
16  * You should have received a copy of the GNU Library General Public License
17  * along with this library; see the file COPYING.LIB.  If not, write to
18  * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
19  * Boston, MA 02110-1301, USA.
20  */
21
22 #ifndef WEBKIT_SOUP_REQUEST_H
23 #define WEBKIT_SOUP_REQUEST_H 1
24
25 #include <libsoup/soup.h>
26 #include <gio/gio.h>
27
28 G_BEGIN_DECLS
29
30 #define WEBKIT_TYPE_SOUP_REQUEST            (webkit_soup_request_get_type ())
31 #define WEBKIT_SOUP_REQUEST(obj)            (G_TYPE_CHECK_INSTANCE_CAST ((obj), WEBKIT_TYPE_SOUP_REQUEST, WebKitSoupRequest))
32 #define WEBKIT_SOUP_REQUEST_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST ((klass), WEBKIT_TYPE_SOUP_REQUEST, WebKitSoupRequestClass))
33 #define WEBKIT_IS_SOUP_REQUEST(obj)         (G_TYPE_CHECK_INSTANCE_TYPE ((obj), WEBKIT_TYPE_SOUP_REQUEST))
34 #define WEBKIT_IS_SOUP_REQUEST_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), WEBKIT_TYPE_SOUP_REQUEST))
35 #define WEBKIT_SOUP_REQUEST_GET_CLASS(obj)  (G_TYPE_INSTANCE_GET_CLASS ((obj), WEBKIT_TYPE_SOUP_REQUEST, WebKitSoupRequestClass))
36
37 typedef struct _WebKitSoupRequest WebKitSoupRequest;
38 typedef struct _WebKitSoupRequestPrivate WebKitSoupRequestPrivate;
39 typedef struct _WebKitSoupRequestClass WebKitSoupRequestClass;
40
41 struct _WebKitSoupRequest {
42         GObject parent;
43
44         WebKitSoupRequestPrivate *priv;
45 };
46
47 struct _WebKitSoupRequestClass {
48         GObjectClass parent;
49
50         gboolean (*check_uri)(WebKitSoupRequest          *req_base,
51                               SoupURI              *uri,
52                               GError              **error);
53
54         GInputStream * (*send)(WebKitSoupRequest          *request,
55                                GCancellable         *cancellable,
56                                GError              **error);
57         void (*send_async)(WebKitSoupRequest          *request,
58                            GCancellable         *cancellable,
59                            GAsyncReadyCallback callback,
60                            gpointer user_data);
61         GInputStream * (*send_finish)(WebKitSoupRequest          *request,
62                                       GAsyncResult         *result,
63                                       GError              **error);
64
65         goffset (*get_content_length)(WebKitSoupRequest   *request);
66         const char *   (*get_content_type)(WebKitSoupRequest   *request);
67 };
68
69 GType webkit_soup_request_get_type (void);
70
71 #define WEBKIT_SOUP_REQUEST_URI     "uri"
72 #define WEBKIT_SOUP_REQUEST_SESSION "session"
73
74 GInputStream *webkit_soup_request_send (WebKitSoupRequest          *request,
75                                         GCancellable         *cancellable,
76                                         GError              **error);
77 void          webkit_soup_request_send_async (WebKitSoupRequest          *request,
78                                               GCancellable         *cancellable,
79                                               GAsyncReadyCallback callback,
80                                               gpointer user_data);
81 GInputStream *webkit_soup_request_send_finish (WebKitSoupRequest          *request,
82                                                GAsyncResult         *result,
83                                                GError              **error);
84
85 SoupURI      *webkit_soup_request_get_uri (WebKitSoupRequest          *request);
86 SoupSession  *webkit_soup_request_get_session (WebKitSoupRequest          *request);
87
88 goffset       webkit_soup_request_get_content_length (WebKitSoupRequest          *request);
89 const char   *webkit_soup_request_get_content_type (WebKitSoupRequest          *request);
90
91 /* Used by WebKitSoupRequestFile and WebKitSoupRequestData. Ideally
92  * should be located in some util file but I'll place it here as it
93  * will be removed with libsoup 2.32.1 that will ship fixed versions
94  * of soup_uri_decode/normalize
95  */
96 gchar *webkit_soup_request_uri_decoded_copy (const char *part, int length);
97
98 G_END_DECLS
99
100 #endif /* WEBKIT_SOUP_REQUEST_H */