Fri, 09 Aug 2013 13:03:26 +0200
HTTP: successful is spelled with one l
|
33425
379bf9ad6973
Initial HTTP API definitions
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
1 | /** |
|
379bf9ad6973
Initial HTTP API definitions
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
2 | * @file http.c HTTP API |
|
379bf9ad6973
Initial HTTP API definitions
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
3 | * @ingroup core |
|
379bf9ad6973
Initial HTTP API definitions
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
4 | */ |
|
379bf9ad6973
Initial HTTP API definitions
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
5 | |
|
379bf9ad6973
Initial HTTP API definitions
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
6 | /* purple |
|
379bf9ad6973
Initial HTTP API definitions
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
7 | * |
|
379bf9ad6973
Initial HTTP API definitions
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
8 | * Purple is the legal property of its developers, whose names are too numerous |
|
379bf9ad6973
Initial HTTP API definitions
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
9 | * to list here. Please refer to the COPYRIGHT file distributed with this |
|
379bf9ad6973
Initial HTTP API definitions
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
10 | * source distribution. |
|
379bf9ad6973
Initial HTTP API definitions
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
11 | * |
|
379bf9ad6973
Initial HTTP API definitions
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
12 | * This program is free software; you can redistribute it and/or modify |
|
379bf9ad6973
Initial HTTP API definitions
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
13 | * it under the terms of the GNU General Public License as published by |
|
379bf9ad6973
Initial HTTP API definitions
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
14 | * the Free Software Foundation; either version 2 of the License, or |
|
379bf9ad6973
Initial HTTP API definitions
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
15 | * (at your option) any later version. |
|
379bf9ad6973
Initial HTTP API definitions
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
16 | * |
|
379bf9ad6973
Initial HTTP API definitions
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
17 | * This program is distributed in the hope that it will be useful, |
|
379bf9ad6973
Initial HTTP API definitions
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
18 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
379bf9ad6973
Initial HTTP API definitions
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
19 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
379bf9ad6973
Initial HTTP API definitions
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
20 | * GNU General Public License for more details. |
|
379bf9ad6973
Initial HTTP API definitions
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
21 | * |
|
379bf9ad6973
Initial HTTP API definitions
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
22 | * You should have received a copy of the GNU General Public License |
|
379bf9ad6973
Initial HTTP API definitions
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
23 | * along with this program; if not, write to the Free Software |
|
379bf9ad6973
Initial HTTP API definitions
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
24 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA |
|
379bf9ad6973
Initial HTTP API definitions
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
25 | */ |
|
379bf9ad6973
Initial HTTP API definitions
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
26 | |
|
379bf9ad6973
Initial HTTP API definitions
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
27 | #include "http.h" |
|
379bf9ad6973
Initial HTTP API definitions
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
28 | |
|
33427
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
29 | #include "internal.h" |
|
33854
5744cfb1c3d1
Fix 3.0.0 compilation for win32, switch gtk (and others) runtimes from gnome.org to opensuse build service
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33626
diff
changeset
|
30 | #include "glibcompat.h" |
|
33453
3cb58ea9667c
HTTP Proxy support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33452
diff
changeset
|
31 | |
|
33427
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
32 | #include "debug.h" |
|
33453
3cb58ea9667c
HTTP Proxy support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33452
diff
changeset
|
33 | #include "ntlm.h" |
|
33427
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
34 | |
|
33439
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
35 | #define PURPLE_HTTP_URL_CREDENTIALS_CHARS "a-z0-9.,~_/*!&%?=+\\^-" |
|
33443
ab563d4c927a
Don't eat resources with malicious http server
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33439
diff
changeset
|
36 | #define PURPLE_HTTP_MAX_RECV_BUFFER_LEN 10240 |
|
33466
918507303f45
HTTP API: PurpleHttpContentReader support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33464
diff
changeset
|
37 | #define PURPLE_HTTP_MAX_READ_BUFFER_LEN 10240 |
|
33439
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
38 | |
|
33444
b3afec292014
New features: http version switching and limits for redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33443
diff
changeset
|
39 | #define PURPLE_HTTP_REQUEST_DEFAULT_MAX_REDIRECTS 20 |
|
33450
4042907bcdf1
Timeout support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33448
diff
changeset
|
40 | #define PURPLE_HTTP_REQUEST_DEFAULT_TIMEOUT 30 |
|
34225
3bba206f27f6
HTTP: migrate purple_util_fetch_url to new API for Pidgin UI
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34219
diff
changeset
|
41 | #define PURPLE_HTTP_REQUEST_DEFAULT_MAX_LENGTH 1048576 |
|
33444
b3afec292014
New features: http version switching and limits for redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33443
diff
changeset
|
42 | |
|
34272
8df870b218ca
HTTP: chop off another HTTP implementation (for xmpp oob file transfers)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34268
diff
changeset
|
43 | #define PURPLE_HTTP_PROGRESS_WATCHER_DEFAULT_INTERVAL 250000 |
|
8df870b218ca
HTTP: chop off another HTTP implementation (for xmpp oob file transfers)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34268
diff
changeset
|
44 | |
|
33430
013c5aebb665
Let's connect
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33429
diff
changeset
|
45 | typedef struct _PurpleHttpSocket PurpleHttpSocket; |
|
013c5aebb665
Let's connect
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33429
diff
changeset
|
46 | |
|
33432
9c4acb75b2e6
Let's parse response headers
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33431
diff
changeset
|
47 | typedef struct _PurpleHttpHeaders PurpleHttpHeaders; |
|
9c4acb75b2e6
Let's parse response headers
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33431
diff
changeset
|
48 | |
|
34263
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
49 | typedef struct _PurpleHttpKeepaliveHost PurpleHttpKeepaliveHost; |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
50 | |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
51 | typedef struct _PurpleHttpKeepaliveRequest PurpleHttpKeepaliveRequest; |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
52 | |
|
34257
935120490eb2
HTTP: isolate socket-related code in http module; initial implementation for keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34234
diff
changeset
|
53 | typedef void (*PurpleHttpSocketConnectCb)(PurpleHttpSocket *hs, |
|
935120490eb2
HTTP: isolate socket-related code in http module; initial implementation for keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34234
diff
changeset
|
54 | const gchar *error, gpointer user_data); |
|
935120490eb2
HTTP: isolate socket-related code in http module; initial implementation for keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34234
diff
changeset
|
55 | |
|
33430
013c5aebb665
Let's connect
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33429
diff
changeset
|
56 | struct _PurpleHttpSocket |
|
013c5aebb665
Let's connect
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33429
diff
changeset
|
57 | { |
|
013c5aebb665
Let's connect
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33429
diff
changeset
|
58 | gboolean is_ssl; |
|
34260
7a55eaa31da6
HTTP: implement keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34257
diff
changeset
|
59 | gboolean is_busy; |
|
34267
7eef0ddc8ab2
Fix win32 build
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34266
diff
changeset
|
60 | guint use_count; |
|
34263
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
61 | PurpleHttpKeepaliveHost *host; |
|
34260
7a55eaa31da6
HTTP: implement keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34257
diff
changeset
|
62 | |
|
33430
013c5aebb665
Let's connect
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33429
diff
changeset
|
63 | PurpleSslConnection *ssl_connection; |
|
013c5aebb665
Let's connect
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33429
diff
changeset
|
64 | PurpleProxyConnectData *raw_connection; |
|
013c5aebb665
Let's connect
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33429
diff
changeset
|
65 | int fd; |
|
013c5aebb665
Let's connect
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33429
diff
changeset
|
66 | guint inpa; |
|
34257
935120490eb2
HTTP: isolate socket-related code in http module; initial implementation for keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34234
diff
changeset
|
67 | PurpleInputFunction watch_cb; |
|
935120490eb2
HTTP: isolate socket-related code in http module; initial implementation for keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34234
diff
changeset
|
68 | PurpleHttpSocketConnectCb connect_cb; |
|
935120490eb2
HTTP: isolate socket-related code in http module; initial implementation for keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34234
diff
changeset
|
69 | gpointer cb_data; |
|
33430
013c5aebb665
Let's connect
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33429
diff
changeset
|
70 | }; |
|
013c5aebb665
Let's connect
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33429
diff
changeset
|
71 | |
|
33427
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
72 | struct _PurpleHttpRequest |
|
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
73 | { |
|
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
74 | int ref_count; |
|
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
75 | |
|
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
76 | gchar *url; |
|
33451
27d0e5dbc2a1
Implement missing getters/setters and corresponding features
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33450
diff
changeset
|
77 | gchar *method; |
|
33447
b890f231e15f
Request headers support, wrapping new API with legacy purple_util_fetch_url
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33446
diff
changeset
|
78 | PurpleHttpHeaders *headers; |
|
33456
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
79 | PurpleHttpCookieJar *cookie_jar; |
|
34257
935120490eb2
HTTP: isolate socket-related code in http module; initial implementation for keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34234
diff
changeset
|
80 | PurpleHttpKeepalivePool *keepalive_pool; |
|
33444
b3afec292014
New features: http version switching and limits for redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33443
diff
changeset
|
81 | |
|
33457
81f92a310aff
Writing request contents
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33456
diff
changeset
|
82 | gchar *contents; |
|
81f92a310aff
Writing request contents
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33456
diff
changeset
|
83 | int contents_length; |
|
33466
918507303f45
HTTP API: PurpleHttpContentReader support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33464
diff
changeset
|
84 | PurpleHttpContentReader contents_reader; |
|
918507303f45
HTTP API: PurpleHttpContentReader support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33464
diff
changeset
|
85 | gpointer contents_reader_data; |
|
33517
ddd9e37c4b07
HTTP: PurpleHttpContentWriter support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33469
diff
changeset
|
86 | PurpleHttpContentWriter response_writer; |
|
ddd9e37c4b07
HTTP: PurpleHttpContentWriter support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33469
diff
changeset
|
87 | gpointer response_writer_data; |
|
33457
81f92a310aff
Writing request contents
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33456
diff
changeset
|
88 | |
|
33450
4042907bcdf1
Timeout support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33448
diff
changeset
|
89 | int timeout; |
|
33444
b3afec292014
New features: http version switching and limits for redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33443
diff
changeset
|
90 | int max_redirects; |
|
b3afec292014
New features: http version switching and limits for redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33443
diff
changeset
|
91 | gboolean http11; |
|
33446
95fda782966c
New feature: setting maximum length of response
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33445
diff
changeset
|
92 | int max_length; |
|
33427
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
93 | }; |
|
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
94 | |
|
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
95 | struct _PurpleHttpConnection |
|
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
96 | { |
|
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
97 | PurpleConnection *gc; |
|
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
98 | PurpleHttpCallback callback; |
|
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
99 | gpointer user_data; |
|
33468
b057fee9d11a
HTTP progress watcher support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33466
diff
changeset
|
100 | gboolean is_reading; |
|
34257
935120490eb2
HTTP: isolate socket-related code in http module; initial implementation for keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34234
diff
changeset
|
101 | gboolean is_keepalive; |
|
34263
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
102 | gboolean is_cancelling; |
|
33427
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
103 | |
|
33429
1ce1faf4e675
Extend URL parsing
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33427
diff
changeset
|
104 | PurpleHttpURL *url; |
|
1ce1faf4e675
Extend URL parsing
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33427
diff
changeset
|
105 | PurpleHttpRequest *request; |
|
33427
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
106 | PurpleHttpResponse *response; |
|
33430
013c5aebb665
Let's connect
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33429
diff
changeset
|
107 | |
|
34263
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
108 | PurpleHttpKeepaliveRequest *socket_request; |
|
34268
cf61366236ee
HTTP: connections set support added; BOSH for xmpp reimplemented, to use http API instead of its own HTTP implementation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34267
diff
changeset
|
109 | PurpleHttpConnectionSet *connection_set; |
|
34257
935120490eb2
HTTP: isolate socket-related code in http module; initial implementation for keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34234
diff
changeset
|
110 | PurpleHttpSocket *socket; |
|
33431
704de181d1d2
Let's request
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33430
diff
changeset
|
111 | GString *request_header; |
|
33457
81f92a310aff
Writing request contents
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33456
diff
changeset
|
112 | int request_header_written, request_contents_written; |
|
33432
9c4acb75b2e6
Let's parse response headers
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33431
diff
changeset
|
113 | gboolean main_header_got, headers_got; |
|
9c4acb75b2e6
Let's parse response headers
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33431
diff
changeset
|
114 | GString *response_buffer; |
|
33433
fb7ac52ed7df
Let's get response contents
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33432
diff
changeset
|
115 | |
|
33466
918507303f45
HTTP API: PurpleHttpContentReader support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33464
diff
changeset
|
116 | GString *contents_reader_buffer; |
|
918507303f45
HTTP API: PurpleHttpContentReader support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33464
diff
changeset
|
117 | gboolean contents_reader_requested; |
|
918507303f45
HTTP API: PurpleHttpContentReader support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33464
diff
changeset
|
118 | |
|
33444
b3afec292014
New features: http version switching and limits for redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33443
diff
changeset
|
119 | int redirects_count; |
|
b3afec292014
New features: http version switching and limits for redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33443
diff
changeset
|
120 | |
|
33433
fb7ac52ed7df
Let's get response contents
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33432
diff
changeset
|
121 | int length_expected, length_got; |
|
33434
ec4f343af107
Chunked file transfers support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33433
diff
changeset
|
122 | |
|
ec4f343af107
Chunked file transfers support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33433
diff
changeset
|
123 | gboolean is_chunked, in_chunk, chunks_done; |
|
ec4f343af107
Chunked file transfers support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33433
diff
changeset
|
124 | int chunk_length, chunk_got; |
|
33448
4d41b1f7b95f
Cancelling all HTTP connections on account disconnect or app shutdown
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33447
diff
changeset
|
125 | |
|
4d41b1f7b95f
Cancelling all HTTP connections on account disconnect or app shutdown
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33447
diff
changeset
|
126 | GList *link_global, *link_gc; |
|
33450
4042907bcdf1
Timeout support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33448
diff
changeset
|
127 | |
|
4042907bcdf1
Timeout support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33448
diff
changeset
|
128 | guint timeout_handle; |
|
33468
b057fee9d11a
HTTP progress watcher support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33466
diff
changeset
|
129 | |
|
b057fee9d11a
HTTP progress watcher support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33466
diff
changeset
|
130 | PurpleHttpProgressWatcher watcher; |
|
b057fee9d11a
HTTP progress watcher support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33466
diff
changeset
|
131 | gpointer watcher_user_data; |
|
b057fee9d11a
HTTP progress watcher support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33466
diff
changeset
|
132 | guint watcher_interval_threshold; |
|
b057fee9d11a
HTTP progress watcher support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33466
diff
changeset
|
133 | gint64 watcher_last_call; |
|
33521
43c34cda245d
HTTP: don't forget to notify about progress before connection freeze
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33517
diff
changeset
|
134 | guint watcher_delayed_handle; |
|
33427
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
135 | }; |
|
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
136 | |
|
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
137 | struct _PurpleHttpResponse |
|
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
138 | { |
|
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
139 | int code; |
|
33430
013c5aebb665
Let's connect
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33429
diff
changeset
|
140 | gchar *error; |
|
33427
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
141 | |
|
33433
fb7ac52ed7df
Let's get response contents
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33432
diff
changeset
|
142 | GString *contents; |
|
33432
9c4acb75b2e6
Let's parse response headers
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33431
diff
changeset
|
143 | PurpleHttpHeaders *headers; |
|
33427
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
144 | }; |
|
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
145 | |
|
33429
1ce1faf4e675
Extend URL parsing
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33427
diff
changeset
|
146 | struct _PurpleHttpURL |
|
1ce1faf4e675
Extend URL parsing
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33427
diff
changeset
|
147 | { |
|
1ce1faf4e675
Extend URL parsing
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33427
diff
changeset
|
148 | gchar *protocol; |
|
34219
eee308def583
HTTP: get rid of purple_url_parse
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34218
diff
changeset
|
149 | gchar *username; |
|
33439
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
150 | gchar *password; |
|
33429
1ce1faf4e675
Extend URL parsing
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33427
diff
changeset
|
151 | gchar *host; |
|
1ce1faf4e675
Extend URL parsing
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33427
diff
changeset
|
152 | int port; |
|
1ce1faf4e675
Extend URL parsing
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33427
diff
changeset
|
153 | gchar *path; |
|
33439
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
154 | gchar *fragment; |
|
33429
1ce1faf4e675
Extend URL parsing
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33427
diff
changeset
|
155 | }; |
|
1ce1faf4e675
Extend URL parsing
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33427
diff
changeset
|
156 | |
|
33432
9c4acb75b2e6
Let's parse response headers
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33431
diff
changeset
|
157 | struct _PurpleHttpHeaders |
|
9c4acb75b2e6
Let's parse response headers
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33431
diff
changeset
|
158 | { |
|
9c4acb75b2e6
Let's parse response headers
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33431
diff
changeset
|
159 | GList *list; |
|
9c4acb75b2e6
Let's parse response headers
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33431
diff
changeset
|
160 | GHashTable *by_name; |
|
9c4acb75b2e6
Let's parse response headers
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33431
diff
changeset
|
161 | }; |
|
9c4acb75b2e6
Let's parse response headers
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33431
diff
changeset
|
162 | |
|
33459
722a6d753cb2
Better cookies, better chunked transfer support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33458
diff
changeset
|
163 | typedef struct |
|
722a6d753cb2
Better cookies, better chunked transfer support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33458
diff
changeset
|
164 | { |
|
722a6d753cb2
Better cookies, better chunked transfer support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33458
diff
changeset
|
165 | time_t expires; |
|
722a6d753cb2
Better cookies, better chunked transfer support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33458
diff
changeset
|
166 | gchar *value; |
|
722a6d753cb2
Better cookies, better chunked transfer support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33458
diff
changeset
|
167 | } PurpleHttpCookie; |
|
722a6d753cb2
Better cookies, better chunked transfer support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33458
diff
changeset
|
168 | |
|
33456
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
169 | struct _PurpleHttpCookieJar |
|
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
170 | { |
|
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
171 | int ref_count; |
|
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
172 | |
|
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
173 | GHashTable *tab; |
|
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
174 | }; |
|
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
175 | |
|
34263
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
176 | struct _PurpleHttpKeepaliveRequest |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
177 | { |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
178 | PurpleConnection *gc; |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
179 | PurpleHttpSocketConnectCb cb; |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
180 | gpointer user_data; |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
181 | |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
182 | PurpleHttpKeepaliveHost *host; |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
183 | PurpleHttpSocket *hs; |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
184 | }; |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
185 | |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
186 | struct _PurpleHttpKeepaliveHost |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
187 | { |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
188 | PurpleHttpKeepalivePool *pool; |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
189 | |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
190 | gchar *host; |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
191 | int port; |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
192 | gboolean is_ssl; |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
193 | |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
194 | GSList *sockets; /* list of PurpleHttpSocket */ |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
195 | |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
196 | GSList *queue; /* list of PurpleHttpKeepaliveRequest */ |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
197 | guint process_queue_timeout; |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
198 | }; |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
199 | |
|
34257
935120490eb2
HTTP: isolate socket-related code in http module; initial implementation for keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34234
diff
changeset
|
200 | struct _PurpleHttpKeepalivePool |
|
935120490eb2
HTTP: isolate socket-related code in http module; initial implementation for keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34234
diff
changeset
|
201 | { |
|
34263
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
202 | gboolean is_destroying; |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
203 | |
|
34257
935120490eb2
HTTP: isolate socket-related code in http module; initial implementation for keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34234
diff
changeset
|
204 | int ref_count; |
|
34260
7a55eaa31da6
HTTP: implement keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34257
diff
changeset
|
205 | |
|
34263
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
206 | guint limit_per_host; |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
207 | |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
208 | /* key: purple_http_socket_hash, value: PurpleHttpKeepaliveHost */ |
|
34260
7a55eaa31da6
HTTP: implement keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34257
diff
changeset
|
209 | GHashTable *by_hash; |
|
34257
935120490eb2
HTTP: isolate socket-related code in http module; initial implementation for keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34234
diff
changeset
|
210 | }; |
|
935120490eb2
HTTP: isolate socket-related code in http module; initial implementation for keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34234
diff
changeset
|
211 | |
|
34268
cf61366236ee
HTTP: connections set support added; BOSH for xmpp reimplemented, to use http API instead of its own HTTP implementation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34267
diff
changeset
|
212 | struct _PurpleHttpConnectionSet |
|
cf61366236ee
HTTP: connections set support added; BOSH for xmpp reimplemented, to use http API instead of its own HTTP implementation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34267
diff
changeset
|
213 | { |
|
cf61366236ee
HTTP: connections set support added; BOSH for xmpp reimplemented, to use http API instead of its own HTTP implementation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34267
diff
changeset
|
214 | gboolean is_destroying; |
|
cf61366236ee
HTTP: connections set support added; BOSH for xmpp reimplemented, to use http API instead of its own HTTP implementation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34267
diff
changeset
|
215 | |
|
cf61366236ee
HTTP: connections set support added; BOSH for xmpp reimplemented, to use http API instead of its own HTTP implementation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34267
diff
changeset
|
216 | GHashTable *connections; |
|
cf61366236ee
HTTP: connections set support added; BOSH for xmpp reimplemented, to use http API instead of its own HTTP implementation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34267
diff
changeset
|
217 | }; |
|
cf61366236ee
HTTP: connections set support added; BOSH for xmpp reimplemented, to use http API instead of its own HTTP implementation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34267
diff
changeset
|
218 | |
| 33462 | 219 | static time_t purple_http_rfc1123_to_time(const gchar *str); |
| 220 | ||
|
34232
a5517f235e0f
HTTP: migrate purple_util_fetch_url_request to new API for GG prpl
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34225
diff
changeset
|
221 | static gboolean purple_http_request_is_method(PurpleHttpRequest *request, |
|
a5517f235e0f
HTTP: migrate purple_util_fetch_url_request to new API for GG prpl
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34225
diff
changeset
|
222 | const gchar *method); |
|
a5517f235e0f
HTTP: migrate purple_util_fetch_url_request to new API for GG prpl
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34225
diff
changeset
|
223 | |
|
33429
1ce1faf4e675
Extend URL parsing
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33427
diff
changeset
|
224 | static PurpleHttpConnection * purple_http_connection_new( |
|
33448
4d41b1f7b95f
Cancelling all HTTP connections on account disconnect or app shutdown
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33447
diff
changeset
|
225 | PurpleHttpRequest *request, PurpleConnection *gc); |
|
33427
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
226 | static void purple_http_connection_terminate(PurpleHttpConnection *hc); |
|
33468
b057fee9d11a
HTTP progress watcher support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33466
diff
changeset
|
227 | static void purple_http_conn_notify_progress_watcher(PurpleHttpConnection *hc); |
|
34260
7a55eaa31da6
HTTP: implement keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34257
diff
changeset
|
228 | static void |
|
7a55eaa31da6
HTTP: implement keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34257
diff
changeset
|
229 | purple_http_conn_retry(PurpleHttpConnection *http_conn); |
|
33427
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
230 | |
|
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
231 | static PurpleHttpResponse * purple_http_response_new(void); |
|
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
232 | static void purple_http_response_free(PurpleHttpResponse *response); |
|
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
233 | |
|
33456
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
234 | static void purple_http_cookie_jar_parse(PurpleHttpCookieJar *cookie_jar, |
|
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
235 | GList *values); |
|
33458
59b3364f690e
Sending cookies
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33457
diff
changeset
|
236 | static gchar * purple_http_cookie_jar_gen(PurpleHttpCookieJar *cookie_jar); |
|
33456
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
237 | gchar * purple_http_cookie_jar_dump(PurpleHttpCookieJar *cjar); |
|
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
238 | |
|
34263
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
239 | static PurpleHttpKeepaliveRequest * |
|
34260
7a55eaa31da6
HTTP: implement keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34257
diff
changeset
|
240 | purple_http_keepalive_pool_request(PurpleHttpKeepalivePool *pool, |
|
7a55eaa31da6
HTTP: implement keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34257
diff
changeset
|
241 | PurpleConnection *gc, const gchar *host, int port, gboolean is_ssl, |
|
7a55eaa31da6
HTTP: implement keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34257
diff
changeset
|
242 | PurpleHttpSocketConnectCb cb, gpointer user_data); |
|
7a55eaa31da6
HTTP: implement keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34257
diff
changeset
|
243 | static void |
|
34263
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
244 | purple_http_keepalive_pool_request_cancel(PurpleHttpKeepaliveRequest *req); |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
245 | static void |
|
34260
7a55eaa31da6
HTTP: implement keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34257
diff
changeset
|
246 | purple_http_keepalive_pool_release(PurpleHttpSocket *hs, gboolean invalidate); |
|
7a55eaa31da6
HTTP: implement keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34257
diff
changeset
|
247 | |
|
34268
cf61366236ee
HTTP: connections set support added; BOSH for xmpp reimplemented, to use http API instead of its own HTTP implementation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34267
diff
changeset
|
248 | static void |
|
cf61366236ee
HTTP: connections set support added; BOSH for xmpp reimplemented, to use http API instead of its own HTTP implementation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34267
diff
changeset
|
249 | purple_http_connection_set_remove(PurpleHttpConnectionSet *set, |
|
cf61366236ee
HTTP: connections set support added; BOSH for xmpp reimplemented, to use http API instead of its own HTTP implementation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34267
diff
changeset
|
250 | PurpleHttpConnection *http_conn); |
|
cf61366236ee
HTTP: connections set support added; BOSH for xmpp reimplemented, to use http API instead of its own HTTP implementation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34267
diff
changeset
|
251 | |
|
33460
c37dd51516aa
Deleting (or expiring) a cookie
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33459
diff
changeset
|
252 | static GRegex *purple_http_re_url, *purple_http_re_url_host, |
|
c37dd51516aa
Deleting (or expiring) a cookie
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33459
diff
changeset
|
253 | *purple_http_re_rfc1123; |
|
33432
9c4acb75b2e6
Let's parse response headers
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33431
diff
changeset
|
254 | |
|
33448
4d41b1f7b95f
Cancelling all HTTP connections on account disconnect or app shutdown
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33447
diff
changeset
|
255 | /** |
|
4d41b1f7b95f
Cancelling all HTTP connections on account disconnect or app shutdown
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33447
diff
changeset
|
256 | * Values: pointers to running PurpleHttpConnection. |
|
4d41b1f7b95f
Cancelling all HTTP connections on account disconnect or app shutdown
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33447
diff
changeset
|
257 | */ |
|
4d41b1f7b95f
Cancelling all HTTP connections on account disconnect or app shutdown
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33447
diff
changeset
|
258 | static GList *purple_http_hc_list; |
|
4d41b1f7b95f
Cancelling all HTTP connections on account disconnect or app shutdown
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33447
diff
changeset
|
259 | |
|
4d41b1f7b95f
Cancelling all HTTP connections on account disconnect or app shutdown
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33447
diff
changeset
|
260 | /** |
|
4d41b1f7b95f
Cancelling all HTTP connections on account disconnect or app shutdown
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33447
diff
changeset
|
261 | * Keys: pointers to PurpleConnection. |
|
4d41b1f7b95f
Cancelling all HTTP connections on account disconnect or app shutdown
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33447
diff
changeset
|
262 | * Values: GList of pointers to running PurpleHttpConnection. |
|
4d41b1f7b95f
Cancelling all HTTP connections on account disconnect or app shutdown
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33447
diff
changeset
|
263 | */ |
|
4d41b1f7b95f
Cancelling all HTTP connections on account disconnect or app shutdown
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33447
diff
changeset
|
264 | static GHashTable *purple_http_hc_by_gc; |
|
4d41b1f7b95f
Cancelling all HTTP connections on account disconnect or app shutdown
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33447
diff
changeset
|
265 | |
|
4d41b1f7b95f
Cancelling all HTTP connections on account disconnect or app shutdown
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33447
diff
changeset
|
266 | /** |
|
34262
3b8ce83bac96
HTTP: get rid of one (of two) msn's own http implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34261
diff
changeset
|
267 | * Keys: pointers to PurpleConnection. |
|
3b8ce83bac96
HTTP: get rid of one (of two) msn's own http implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34261
diff
changeset
|
268 | * Values: gboolean TRUE. |
|
3b8ce83bac96
HTTP: get rid of one (of two) msn's own http implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34261
diff
changeset
|
269 | */ |
|
3b8ce83bac96
HTTP: get rid of one (of two) msn's own http implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34261
diff
changeset
|
270 | static GHashTable *purple_http_cancelling_gc; |
|
3b8ce83bac96
HTTP: get rid of one (of two) msn's own http implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34261
diff
changeset
|
271 | |
|
3b8ce83bac96
HTTP: get rid of one (of two) msn's own http implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34261
diff
changeset
|
272 | /** |
|
33448
4d41b1f7b95f
Cancelling all HTTP connections on account disconnect or app shutdown
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33447
diff
changeset
|
273 | * Keys: pointers to PurpleHttpConnection. |
|
4d41b1f7b95f
Cancelling all HTTP connections on account disconnect or app shutdown
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33447
diff
changeset
|
274 | * Values: pointers to links in purple_http_hc_list. |
|
4d41b1f7b95f
Cancelling all HTTP connections on account disconnect or app shutdown
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33447
diff
changeset
|
275 | */ |
|
4d41b1f7b95f
Cancelling all HTTP connections on account disconnect or app shutdown
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33447
diff
changeset
|
276 | static GHashTable *purple_http_hc_by_ptr; |
|
4d41b1f7b95f
Cancelling all HTTP connections on account disconnect or app shutdown
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33447
diff
changeset
|
277 | |
|
33460
c37dd51516aa
Deleting (or expiring) a cookie
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33459
diff
changeset
|
278 | /*** Helper functions *********************************************************/ |
|
c37dd51516aa
Deleting (or expiring) a cookie
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33459
diff
changeset
|
279 | |
|
c37dd51516aa
Deleting (or expiring) a cookie
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33459
diff
changeset
|
280 | static time_t purple_http_rfc1123_to_time(const gchar *str) |
|
c37dd51516aa
Deleting (or expiring) a cookie
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33459
diff
changeset
|
281 | { |
|
c37dd51516aa
Deleting (or expiring) a cookie
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33459
diff
changeset
|
282 | static const gchar *months[13] = {"jan", "feb", "mar", "apr", "may", "jun", |
|
c37dd51516aa
Deleting (or expiring) a cookie
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33459
diff
changeset
|
283 | "jul", "aug", "sep", "oct", "nov", "dec", NULL}; |
|
c37dd51516aa
Deleting (or expiring) a cookie
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33459
diff
changeset
|
284 | GMatchInfo *match_info; |
|
c37dd51516aa
Deleting (or expiring) a cookie
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33459
diff
changeset
|
285 | gchar *d_date, *d_month, *d_year, *d_time; |
|
c37dd51516aa
Deleting (or expiring) a cookie
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33459
diff
changeset
|
286 | int month; |
|
c37dd51516aa
Deleting (or expiring) a cookie
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33459
diff
changeset
|
287 | gchar *iso_date; |
|
c37dd51516aa
Deleting (or expiring) a cookie
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33459
diff
changeset
|
288 | time_t t; |
|
c37dd51516aa
Deleting (or expiring) a cookie
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33459
diff
changeset
|
289 | |
|
c37dd51516aa
Deleting (or expiring) a cookie
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33459
diff
changeset
|
290 | g_return_val_if_fail(str != NULL, 0); |
|
c37dd51516aa
Deleting (or expiring) a cookie
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33459
diff
changeset
|
291 | |
|
c37dd51516aa
Deleting (or expiring) a cookie
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33459
diff
changeset
|
292 | g_regex_match(purple_http_re_rfc1123, str, 0, &match_info); |
|
c37dd51516aa
Deleting (or expiring) a cookie
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33459
diff
changeset
|
293 | if (!g_match_info_matches(match_info)) { |
|
c37dd51516aa
Deleting (or expiring) a cookie
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33459
diff
changeset
|
294 | g_match_info_free(match_info); |
|
c37dd51516aa
Deleting (or expiring) a cookie
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33459
diff
changeset
|
295 | return 0; |
|
c37dd51516aa
Deleting (or expiring) a cookie
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33459
diff
changeset
|
296 | } |
|
c37dd51516aa
Deleting (or expiring) a cookie
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33459
diff
changeset
|
297 | g_match_info_free(match_info); |
|
c37dd51516aa
Deleting (or expiring) a cookie
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33459
diff
changeset
|
298 | |
|
c37dd51516aa
Deleting (or expiring) a cookie
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33459
diff
changeset
|
299 | d_date = g_match_info_fetch(match_info, 1); |
|
c37dd51516aa
Deleting (or expiring) a cookie
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33459
diff
changeset
|
300 | d_month = g_match_info_fetch(match_info, 2); |
|
c37dd51516aa
Deleting (or expiring) a cookie
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33459
diff
changeset
|
301 | d_year = g_match_info_fetch(match_info, 3); |
|
c37dd51516aa
Deleting (or expiring) a cookie
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33459
diff
changeset
|
302 | d_time = g_match_info_fetch(match_info, 4); |
|
c37dd51516aa
Deleting (or expiring) a cookie
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33459
diff
changeset
|
303 | |
|
c37dd51516aa
Deleting (or expiring) a cookie
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33459
diff
changeset
|
304 | month = 0; |
|
c37dd51516aa
Deleting (or expiring) a cookie
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33459
diff
changeset
|
305 | while (months[month] != NULL) |
|
c37dd51516aa
Deleting (or expiring) a cookie
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33459
diff
changeset
|
306 | { |
|
c37dd51516aa
Deleting (or expiring) a cookie
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33459
diff
changeset
|
307 | if (0 == g_ascii_strcasecmp(d_month, months[month])) |
|
c37dd51516aa
Deleting (or expiring) a cookie
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33459
diff
changeset
|
308 | break; |
|
c37dd51516aa
Deleting (or expiring) a cookie
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33459
diff
changeset
|
309 | month++; |
|
c37dd51516aa
Deleting (or expiring) a cookie
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33459
diff
changeset
|
310 | } |
|
c37dd51516aa
Deleting (or expiring) a cookie
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33459
diff
changeset
|
311 | month++; |
|
c37dd51516aa
Deleting (or expiring) a cookie
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33459
diff
changeset
|
312 | |
|
c37dd51516aa
Deleting (or expiring) a cookie
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33459
diff
changeset
|
313 | iso_date = g_strdup_printf("%s-%02d-%sT%s+00:00", |
|
c37dd51516aa
Deleting (or expiring) a cookie
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33459
diff
changeset
|
314 | d_year, month, d_date, d_time); |
|
c37dd51516aa
Deleting (or expiring) a cookie
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33459
diff
changeset
|
315 | |
|
c37dd51516aa
Deleting (or expiring) a cookie
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33459
diff
changeset
|
316 | g_free(d_date); |
|
c37dd51516aa
Deleting (or expiring) a cookie
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33459
diff
changeset
|
317 | g_free(d_month); |
|
c37dd51516aa
Deleting (or expiring) a cookie
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33459
diff
changeset
|
318 | g_free(d_year); |
|
c37dd51516aa
Deleting (or expiring) a cookie
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33459
diff
changeset
|
319 | g_free(d_time); |
|
c37dd51516aa
Deleting (or expiring) a cookie
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33459
diff
changeset
|
320 | |
|
c37dd51516aa
Deleting (or expiring) a cookie
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33459
diff
changeset
|
321 | if (month > 12) { |
|
c37dd51516aa
Deleting (or expiring) a cookie
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33459
diff
changeset
|
322 | purple_debug_warning("http", "Invalid month: %s\n", d_month); |
|
c37dd51516aa
Deleting (or expiring) a cookie
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33459
diff
changeset
|
323 | g_free(iso_date); |
|
c37dd51516aa
Deleting (or expiring) a cookie
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33459
diff
changeset
|
324 | return 0; |
|
c37dd51516aa
Deleting (or expiring) a cookie
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33459
diff
changeset
|
325 | } |
|
c37dd51516aa
Deleting (or expiring) a cookie
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33459
diff
changeset
|
326 | |
|
c37dd51516aa
Deleting (or expiring) a cookie
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33459
diff
changeset
|
327 | t = purple_str_to_time(iso_date, TRUE, NULL, NULL, NULL); |
|
c37dd51516aa
Deleting (or expiring) a cookie
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33459
diff
changeset
|
328 | |
|
c37dd51516aa
Deleting (or expiring) a cookie
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33459
diff
changeset
|
329 | g_free(iso_date); |
|
c37dd51516aa
Deleting (or expiring) a cookie
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33459
diff
changeset
|
330 | |
|
c37dd51516aa
Deleting (or expiring) a cookie
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33459
diff
changeset
|
331 | return t; |
|
c37dd51516aa
Deleting (or expiring) a cookie
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33459
diff
changeset
|
332 | } |
|
c37dd51516aa
Deleting (or expiring) a cookie
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33459
diff
changeset
|
333 | |
|
34257
935120490eb2
HTTP: isolate socket-related code in http module; initial implementation for keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34234
diff
changeset
|
334 | /*** HTTP Sockets *************************************************************/ |
|
935120490eb2
HTTP: isolate socket-related code in http module; initial implementation for keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34234
diff
changeset
|
335 | |
|
935120490eb2
HTTP: isolate socket-related code in http module; initial implementation for keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34234
diff
changeset
|
336 | static void _purple_http_socket_connected_raw(gpointer _hs, gint fd, |
|
935120490eb2
HTTP: isolate socket-related code in http module; initial implementation for keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34234
diff
changeset
|
337 | const gchar *error_message) |
|
935120490eb2
HTTP: isolate socket-related code in http module; initial implementation for keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34234
diff
changeset
|
338 | { |
|
935120490eb2
HTTP: isolate socket-related code in http module; initial implementation for keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34234
diff
changeset
|
339 | PurpleHttpSocket *hs = _hs; |
|
935120490eb2
HTTP: isolate socket-related code in http module; initial implementation for keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34234
diff
changeset
|
340 | |
|
935120490eb2
HTTP: isolate socket-related code in http module; initial implementation for keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34234
diff
changeset
|
341 | hs->raw_connection = NULL; |
|
935120490eb2
HTTP: isolate socket-related code in http module; initial implementation for keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34234
diff
changeset
|
342 | |
|
935120490eb2
HTTP: isolate socket-related code in http module; initial implementation for keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34234
diff
changeset
|
343 | if (fd == -1 || error_message != NULL) { |
|
935120490eb2
HTTP: isolate socket-related code in http module; initial implementation for keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34234
diff
changeset
|
344 | if (error_message == NULL) |
|
935120490eb2
HTTP: isolate socket-related code in http module; initial implementation for keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34234
diff
changeset
|
345 | error_message = _("Unknown error"); |
|
935120490eb2
HTTP: isolate socket-related code in http module; initial implementation for keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34234
diff
changeset
|
346 | hs->connect_cb(hs, error_message, hs->cb_data); |
|
935120490eb2
HTTP: isolate socket-related code in http module; initial implementation for keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34234
diff
changeset
|
347 | return; |
|
935120490eb2
HTTP: isolate socket-related code in http module; initial implementation for keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34234
diff
changeset
|
348 | } |
|
935120490eb2
HTTP: isolate socket-related code in http module; initial implementation for keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34234
diff
changeset
|
349 | |
|
935120490eb2
HTTP: isolate socket-related code in http module; initial implementation for keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34234
diff
changeset
|
350 | hs->fd = fd; |
|
935120490eb2
HTTP: isolate socket-related code in http module; initial implementation for keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34234
diff
changeset
|
351 | hs->connect_cb(hs, NULL, hs->cb_data); |
|
935120490eb2
HTTP: isolate socket-related code in http module; initial implementation for keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34234
diff
changeset
|
352 | } |
|
935120490eb2
HTTP: isolate socket-related code in http module; initial implementation for keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34234
diff
changeset
|
353 | |
|
935120490eb2
HTTP: isolate socket-related code in http module; initial implementation for keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34234
diff
changeset
|
354 | static void _purple_http_socket_connected_ssl(gpointer _hs, |
|
935120490eb2
HTTP: isolate socket-related code in http module; initial implementation for keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34234
diff
changeset
|
355 | PurpleSslConnection *ssl_connection, PurpleInputCondition cond) |
|
935120490eb2
HTTP: isolate socket-related code in http module; initial implementation for keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34234
diff
changeset
|
356 | { |
|
935120490eb2
HTTP: isolate socket-related code in http module; initial implementation for keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34234
diff
changeset
|
357 | PurpleHttpSocket *hs = _hs; |
|
935120490eb2
HTTP: isolate socket-related code in http module; initial implementation for keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34234
diff
changeset
|
358 | |
|
935120490eb2
HTTP: isolate socket-related code in http module; initial implementation for keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34234
diff
changeset
|
359 | hs->fd = hs->ssl_connection->fd; |
|
935120490eb2
HTTP: isolate socket-related code in http module; initial implementation for keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34234
diff
changeset
|
360 | hs->connect_cb(hs, NULL, hs->cb_data); |
|
935120490eb2
HTTP: isolate socket-related code in http module; initial implementation for keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34234
diff
changeset
|
361 | } |
|
935120490eb2
HTTP: isolate socket-related code in http module; initial implementation for keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34234
diff
changeset
|
362 | |
|
935120490eb2
HTTP: isolate socket-related code in http module; initial implementation for keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34234
diff
changeset
|
363 | static void _purple_http_socket_connected_ssl_error( |
|
935120490eb2
HTTP: isolate socket-related code in http module; initial implementation for keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34234
diff
changeset
|
364 | PurpleSslConnection *ssl_connection, PurpleSslErrorType error, |
|
935120490eb2
HTTP: isolate socket-related code in http module; initial implementation for keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34234
diff
changeset
|
365 | gpointer _hs) |
|
935120490eb2
HTTP: isolate socket-related code in http module; initial implementation for keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34234
diff
changeset
|
366 | { |
|
935120490eb2
HTTP: isolate socket-related code in http module; initial implementation for keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34234
diff
changeset
|
367 | PurpleHttpSocket *hs = _hs; |
|
935120490eb2
HTTP: isolate socket-related code in http module; initial implementation for keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34234
diff
changeset
|
368 | |
|
935120490eb2
HTTP: isolate socket-related code in http module; initial implementation for keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34234
diff
changeset
|
369 | hs->ssl_connection = NULL; |
|
935120490eb2
HTTP: isolate socket-related code in http module; initial implementation for keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34234
diff
changeset
|
370 | hs->connect_cb(hs, purple_ssl_strerror(error), hs->cb_data); |
|
935120490eb2
HTTP: isolate socket-related code in http module; initial implementation for keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34234
diff
changeset
|
371 | } |
|
935120490eb2
HTTP: isolate socket-related code in http module; initial implementation for keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34234
diff
changeset
|
372 | |
|
34260
7a55eaa31da6
HTTP: implement keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34257
diff
changeset
|
373 | static gchar * |
|
7a55eaa31da6
HTTP: implement keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34257
diff
changeset
|
374 | purple_http_socket_hash(const gchar *host, int port, gboolean is_ssl) |
|
7a55eaa31da6
HTTP: implement keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34257
diff
changeset
|
375 | { |
|
7a55eaa31da6
HTTP: implement keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34257
diff
changeset
|
376 | return g_strdup_printf("%c:%s:%d", (is_ssl ? 'S' : 'R'), host, port); |
|
7a55eaa31da6
HTTP: implement keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34257
diff
changeset
|
377 | } |
|
7a55eaa31da6
HTTP: implement keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34257
diff
changeset
|
378 | |
|
34257
935120490eb2
HTTP: isolate socket-related code in http module; initial implementation for keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34234
diff
changeset
|
379 | static PurpleHttpSocket * |
|
935120490eb2
HTTP: isolate socket-related code in http module; initial implementation for keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34234
diff
changeset
|
380 | purple_http_socket_connect_new(PurpleConnection *gc, const gchar *host, int port, gboolean is_ssl, PurpleHttpSocketConnectCb cb, gpointer user_data) |
|
935120490eb2
HTTP: isolate socket-related code in http module; initial implementation for keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34234
diff
changeset
|
381 | { |
|
935120490eb2
HTTP: isolate socket-related code in http module; initial implementation for keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34234
diff
changeset
|
382 | PurpleHttpSocket *hs = g_new0(PurpleHttpSocket, 1); |
|
935120490eb2
HTTP: isolate socket-related code in http module; initial implementation for keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34234
diff
changeset
|
383 | PurpleAccount *account = NULL; |
|
935120490eb2
HTTP: isolate socket-related code in http module; initial implementation for keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34234
diff
changeset
|
384 | |
|
935120490eb2
HTTP: isolate socket-related code in http module; initial implementation for keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34234
diff
changeset
|
385 | if (gc != NULL) |
|
935120490eb2
HTTP: isolate socket-related code in http module; initial implementation for keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34234
diff
changeset
|
386 | account = purple_connection_get_account(gc); |
|
935120490eb2
HTTP: isolate socket-related code in http module; initial implementation for keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34234
diff
changeset
|
387 | |
|
935120490eb2
HTTP: isolate socket-related code in http module; initial implementation for keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34234
diff
changeset
|
388 | hs->is_ssl = is_ssl; |
|
935120490eb2
HTTP: isolate socket-related code in http module; initial implementation for keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34234
diff
changeset
|
389 | hs->connect_cb = cb; |
|
935120490eb2
HTTP: isolate socket-related code in http module; initial implementation for keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34234
diff
changeset
|
390 | hs->cb_data = user_data; |
|
935120490eb2
HTTP: isolate socket-related code in http module; initial implementation for keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34234
diff
changeset
|
391 | hs->fd = -1; |
|
935120490eb2
HTTP: isolate socket-related code in http module; initial implementation for keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34234
diff
changeset
|
392 | |
|
935120490eb2
HTTP: isolate socket-related code in http module; initial implementation for keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34234
diff
changeset
|
393 | if (is_ssl) { |
|
935120490eb2
HTTP: isolate socket-related code in http module; initial implementation for keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34234
diff
changeset
|
394 | if (!purple_ssl_is_supported()) { |
|
935120490eb2
HTTP: isolate socket-related code in http module; initial implementation for keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34234
diff
changeset
|
395 | g_free(hs); |
|
935120490eb2
HTTP: isolate socket-related code in http module; initial implementation for keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34234
diff
changeset
|
396 | return NULL; |
|
935120490eb2
HTTP: isolate socket-related code in http module; initial implementation for keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34234
diff
changeset
|
397 | } |
|
935120490eb2
HTTP: isolate socket-related code in http module; initial implementation for keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34234
diff
changeset
|
398 | |
|
935120490eb2
HTTP: isolate socket-related code in http module; initial implementation for keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34234
diff
changeset
|
399 | hs->ssl_connection = purple_ssl_connect(account, |
|
935120490eb2
HTTP: isolate socket-related code in http module; initial implementation for keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34234
diff
changeset
|
400 | host, port, |
|
935120490eb2
HTTP: isolate socket-related code in http module; initial implementation for keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34234
diff
changeset
|
401 | _purple_http_socket_connected_ssl, |
|
935120490eb2
HTTP: isolate socket-related code in http module; initial implementation for keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34234
diff
changeset
|
402 | _purple_http_socket_connected_ssl_error, hs); |
|
935120490eb2
HTTP: isolate socket-related code in http module; initial implementation for keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34234
diff
changeset
|
403 | /* TODO |
|
935120490eb2
HTTP: isolate socket-related code in http module; initial implementation for keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34234
diff
changeset
|
404 | purple_ssl_set_compatibility_level(hs->ssl_connection, |
|
935120490eb2
HTTP: isolate socket-related code in http module; initial implementation for keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34234
diff
changeset
|
405 | PURPLE_SSL_COMPATIBILITY_SECURE); |
|
935120490eb2
HTTP: isolate socket-related code in http module; initial implementation for keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34234
diff
changeset
|
406 | */ |
|
935120490eb2
HTTP: isolate socket-related code in http module; initial implementation for keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34234
diff
changeset
|
407 | } else { |
|
935120490eb2
HTTP: isolate socket-related code in http module; initial implementation for keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34234
diff
changeset
|
408 | hs->raw_connection = purple_proxy_connect(gc, account, |
|
935120490eb2
HTTP: isolate socket-related code in http module; initial implementation for keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34234
diff
changeset
|
409 | host, port, |
|
935120490eb2
HTTP: isolate socket-related code in http module; initial implementation for keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34234
diff
changeset
|
410 | _purple_http_socket_connected_raw, hs); |
|
935120490eb2
HTTP: isolate socket-related code in http module; initial implementation for keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34234
diff
changeset
|
411 | } |
|
935120490eb2
HTTP: isolate socket-related code in http module; initial implementation for keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34234
diff
changeset
|
412 | |
|
935120490eb2
HTTP: isolate socket-related code in http module; initial implementation for keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34234
diff
changeset
|
413 | if (hs->ssl_connection == NULL && |
|
935120490eb2
HTTP: isolate socket-related code in http module; initial implementation for keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34234
diff
changeset
|
414 | hs->raw_connection == NULL) { |
|
935120490eb2
HTTP: isolate socket-related code in http module; initial implementation for keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34234
diff
changeset
|
415 | g_free(hs); |
|
935120490eb2
HTTP: isolate socket-related code in http module; initial implementation for keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34234
diff
changeset
|
416 | return NULL; |
|
935120490eb2
HTTP: isolate socket-related code in http module; initial implementation for keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34234
diff
changeset
|
417 | } |
|
935120490eb2
HTTP: isolate socket-related code in http module; initial implementation for keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34234
diff
changeset
|
418 | |
|
34260
7a55eaa31da6
HTTP: implement keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34257
diff
changeset
|
419 | if (purple_debug_is_verbose()) |
|
7a55eaa31da6
HTTP: implement keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34257
diff
changeset
|
420 | purple_debug_misc("http", "new socket created: %p\n", hs); |
|
7a55eaa31da6
HTTP: implement keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34257
diff
changeset
|
421 | |
|
34257
935120490eb2
HTTP: isolate socket-related code in http module; initial implementation for keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34234
diff
changeset
|
422 | return hs; |
|
935120490eb2
HTTP: isolate socket-related code in http module; initial implementation for keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34234
diff
changeset
|
423 | } |
|
935120490eb2
HTTP: isolate socket-related code in http module; initial implementation for keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34234
diff
changeset
|
424 | |
|
935120490eb2
HTTP: isolate socket-related code in http module; initial implementation for keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34234
diff
changeset
|
425 | static int |
|
935120490eb2
HTTP: isolate socket-related code in http module; initial implementation for keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34234
diff
changeset
|
426 | purple_http_socket_read(PurpleHttpSocket *hs, gchar *buf, size_t len) |
|
935120490eb2
HTTP: isolate socket-related code in http module; initial implementation for keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34234
diff
changeset
|
427 | { |
|
935120490eb2
HTTP: isolate socket-related code in http module; initial implementation for keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34234
diff
changeset
|
428 | g_return_val_if_fail(hs != NULL, -1); |
|
935120490eb2
HTTP: isolate socket-related code in http module; initial implementation for keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34234
diff
changeset
|
429 | g_return_val_if_fail(buf != NULL, -1); |
|
935120490eb2
HTTP: isolate socket-related code in http module; initial implementation for keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34234
diff
changeset
|
430 | |
|
935120490eb2
HTTP: isolate socket-related code in http module; initial implementation for keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34234
diff
changeset
|
431 | if (hs->is_ssl) |
|
935120490eb2
HTTP: isolate socket-related code in http module; initial implementation for keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34234
diff
changeset
|
432 | return purple_ssl_read(hs->ssl_connection, buf, sizeof(buf)); |
|
935120490eb2
HTTP: isolate socket-related code in http module; initial implementation for keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34234
diff
changeset
|
433 | else |
|
935120490eb2
HTTP: isolate socket-related code in http module; initial implementation for keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34234
diff
changeset
|
434 | return read(hs->fd, buf, sizeof(buf)); |
|
935120490eb2
HTTP: isolate socket-related code in http module; initial implementation for keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34234
diff
changeset
|
435 | } |
|
935120490eb2
HTTP: isolate socket-related code in http module; initial implementation for keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34234
diff
changeset
|
436 | |
|
935120490eb2
HTTP: isolate socket-related code in http module; initial implementation for keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34234
diff
changeset
|
437 | static int |
|
935120490eb2
HTTP: isolate socket-related code in http module; initial implementation for keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34234
diff
changeset
|
438 | purple_http_socket_write(PurpleHttpSocket *hs, const gchar *buf, size_t len) |
|
935120490eb2
HTTP: isolate socket-related code in http module; initial implementation for keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34234
diff
changeset
|
439 | { |
|
935120490eb2
HTTP: isolate socket-related code in http module; initial implementation for keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34234
diff
changeset
|
440 | g_return_val_if_fail(hs != NULL, -1); |
|
935120490eb2
HTTP: isolate socket-related code in http module; initial implementation for keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34234
diff
changeset
|
441 | g_return_val_if_fail(buf != NULL, -1); |
|
935120490eb2
HTTP: isolate socket-related code in http module; initial implementation for keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34234
diff
changeset
|
442 | |
|
935120490eb2
HTTP: isolate socket-related code in http module; initial implementation for keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34234
diff
changeset
|
443 | if (hs->is_ssl) |
|
935120490eb2
HTTP: isolate socket-related code in http module; initial implementation for keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34234
diff
changeset
|
444 | return purple_ssl_write(hs->ssl_connection, buf, len); |
|
935120490eb2
HTTP: isolate socket-related code in http module; initial implementation for keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34234
diff
changeset
|
445 | else |
|
935120490eb2
HTTP: isolate socket-related code in http module; initial implementation for keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34234
diff
changeset
|
446 | return write(hs->fd, buf, len); |
|
935120490eb2
HTTP: isolate socket-related code in http module; initial implementation for keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34234
diff
changeset
|
447 | } |
|
935120490eb2
HTTP: isolate socket-related code in http module; initial implementation for keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34234
diff
changeset
|
448 | |
|
935120490eb2
HTTP: isolate socket-related code in http module; initial implementation for keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34234
diff
changeset
|
449 | static void _purple_http_socket_watch_recv_ssl(gpointer _hs, |
|
935120490eb2
HTTP: isolate socket-related code in http module; initial implementation for keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34234
diff
changeset
|
450 | PurpleSslConnection *ssl_connection, PurpleInputCondition cond) |
|
935120490eb2
HTTP: isolate socket-related code in http module; initial implementation for keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34234
diff
changeset
|
451 | { |
|
935120490eb2
HTTP: isolate socket-related code in http module; initial implementation for keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34234
diff
changeset
|
452 | PurpleHttpSocket *hs = _hs; |
|
935120490eb2
HTTP: isolate socket-related code in http module; initial implementation for keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34234
diff
changeset
|
453 | |
|
935120490eb2
HTTP: isolate socket-related code in http module; initial implementation for keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34234
diff
changeset
|
454 | g_return_if_fail(hs != NULL); |
|
935120490eb2
HTTP: isolate socket-related code in http module; initial implementation for keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34234
diff
changeset
|
455 | |
|
935120490eb2
HTTP: isolate socket-related code in http module; initial implementation for keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34234
diff
changeset
|
456 | hs->watch_cb(hs->cb_data, hs->fd, cond); |
|
935120490eb2
HTTP: isolate socket-related code in http module; initial implementation for keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34234
diff
changeset
|
457 | } |
|
935120490eb2
HTTP: isolate socket-related code in http module; initial implementation for keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34234
diff
changeset
|
458 | |
|
935120490eb2
HTTP: isolate socket-related code in http module; initial implementation for keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34234
diff
changeset
|
459 | static void |
|
935120490eb2
HTTP: isolate socket-related code in http module; initial implementation for keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34234
diff
changeset
|
460 | purple_http_socket_watch(PurpleHttpSocket *hs, PurpleInputCondition cond, |
|
935120490eb2
HTTP: isolate socket-related code in http module; initial implementation for keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34234
diff
changeset
|
461 | PurpleInputFunction func, gpointer user_data) |
|
935120490eb2
HTTP: isolate socket-related code in http module; initial implementation for keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34234
diff
changeset
|
462 | { |
|
935120490eb2
HTTP: isolate socket-related code in http module; initial implementation for keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34234
diff
changeset
|
463 | g_return_if_fail(hs != NULL); |
|
935120490eb2
HTTP: isolate socket-related code in http module; initial implementation for keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34234
diff
changeset
|
464 | |
|
935120490eb2
HTTP: isolate socket-related code in http module; initial implementation for keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34234
diff
changeset
|
465 | if (hs->inpa > 0) |
|
935120490eb2
HTTP: isolate socket-related code in http module; initial implementation for keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34234
diff
changeset
|
466 | purple_input_remove(hs->inpa); |
|
935120490eb2
HTTP: isolate socket-related code in http module; initial implementation for keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34234
diff
changeset
|
467 | hs->inpa = 0; |
|
935120490eb2
HTTP: isolate socket-related code in http module; initial implementation for keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34234
diff
changeset
|
468 | |
|
935120490eb2
HTTP: isolate socket-related code in http module; initial implementation for keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34234
diff
changeset
|
469 | if (cond == PURPLE_INPUT_READ && hs->is_ssl) { |
|
935120490eb2
HTTP: isolate socket-related code in http module; initial implementation for keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34234
diff
changeset
|
470 | hs->watch_cb = func; |
|
935120490eb2
HTTP: isolate socket-related code in http module; initial implementation for keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34234
diff
changeset
|
471 | hs->cb_data = user_data; |
|
935120490eb2
HTTP: isolate socket-related code in http module; initial implementation for keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34234
diff
changeset
|
472 | purple_ssl_input_add(hs->ssl_connection, |
|
935120490eb2
HTTP: isolate socket-related code in http module; initial implementation for keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34234
diff
changeset
|
473 | _purple_http_socket_watch_recv_ssl, hs); |
|
935120490eb2
HTTP: isolate socket-related code in http module; initial implementation for keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34234
diff
changeset
|
474 | } |
|
935120490eb2
HTTP: isolate socket-related code in http module; initial implementation for keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34234
diff
changeset
|
475 | else |
|
935120490eb2
HTTP: isolate socket-related code in http module; initial implementation for keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34234
diff
changeset
|
476 | hs->inpa = purple_input_add(hs->fd, cond, func, user_data); |
|
935120490eb2
HTTP: isolate socket-related code in http module; initial implementation for keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34234
diff
changeset
|
477 | } |
|
935120490eb2
HTTP: isolate socket-related code in http module; initial implementation for keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34234
diff
changeset
|
478 | |
|
935120490eb2
HTTP: isolate socket-related code in http module; initial implementation for keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34234
diff
changeset
|
479 | static void |
|
34260
7a55eaa31da6
HTTP: implement keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34257
diff
changeset
|
480 | purple_http_socket_dontwatch(PurpleHttpSocket *hs) |
|
7a55eaa31da6
HTTP: implement keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34257
diff
changeset
|
481 | { |
|
7a55eaa31da6
HTTP: implement keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34257
diff
changeset
|
482 | g_return_if_fail(hs != NULL); |
|
7a55eaa31da6
HTTP: implement keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34257
diff
changeset
|
483 | |
|
7a55eaa31da6
HTTP: implement keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34257
diff
changeset
|
484 | if (hs->inpa > 0) |
|
7a55eaa31da6
HTTP: implement keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34257
diff
changeset
|
485 | purple_input_remove(hs->inpa); |
|
7a55eaa31da6
HTTP: implement keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34257
diff
changeset
|
486 | hs->inpa = 0; |
|
34262
3b8ce83bac96
HTTP: get rid of one (of two) msn's own http implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34261
diff
changeset
|
487 | if (hs->ssl_connection) |
|
3b8ce83bac96
HTTP: get rid of one (of two) msn's own http implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34261
diff
changeset
|
488 | purple_ssl_input_remove(hs->ssl_connection); |
|
34260
7a55eaa31da6
HTTP: implement keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34257
diff
changeset
|
489 | } |
|
7a55eaa31da6
HTTP: implement keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34257
diff
changeset
|
490 | |
|
7a55eaa31da6
HTTP: implement keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34257
diff
changeset
|
491 | static void |
|
34257
935120490eb2
HTTP: isolate socket-related code in http module; initial implementation for keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34234
diff
changeset
|
492 | purple_http_socket_close_free(PurpleHttpSocket *hs) |
|
935120490eb2
HTTP: isolate socket-related code in http module; initial implementation for keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34234
diff
changeset
|
493 | { |
|
935120490eb2
HTTP: isolate socket-related code in http module; initial implementation for keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34234
diff
changeset
|
494 | if (hs == NULL) |
|
935120490eb2
HTTP: isolate socket-related code in http module; initial implementation for keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34234
diff
changeset
|
495 | return; |
|
935120490eb2
HTTP: isolate socket-related code in http module; initial implementation for keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34234
diff
changeset
|
496 | |
|
34260
7a55eaa31da6
HTTP: implement keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34257
diff
changeset
|
497 | if (purple_debug_is_verbose()) |
|
7a55eaa31da6
HTTP: implement keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34257
diff
changeset
|
498 | purple_debug_misc("http", "destroying socket: %p\n", hs); |
|
7a55eaa31da6
HTTP: implement keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34257
diff
changeset
|
499 | |
|
34257
935120490eb2
HTTP: isolate socket-related code in http module; initial implementation for keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34234
diff
changeset
|
500 | if (hs->inpa != 0) |
|
935120490eb2
HTTP: isolate socket-related code in http module; initial implementation for keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34234
diff
changeset
|
501 | purple_input_remove(hs->inpa); |
|
935120490eb2
HTTP: isolate socket-related code in http module; initial implementation for keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34234
diff
changeset
|
502 | |
|
935120490eb2
HTTP: isolate socket-related code in http module; initial implementation for keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34234
diff
changeset
|
503 | if (hs->is_ssl) { |
|
935120490eb2
HTTP: isolate socket-related code in http module; initial implementation for keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34234
diff
changeset
|
504 | if (hs->ssl_connection != NULL) |
|
935120490eb2
HTTP: isolate socket-related code in http module; initial implementation for keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34234
diff
changeset
|
505 | purple_ssl_close(hs->ssl_connection); |
|
935120490eb2
HTTP: isolate socket-related code in http module; initial implementation for keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34234
diff
changeset
|
506 | } else { |
|
935120490eb2
HTTP: isolate socket-related code in http module; initial implementation for keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34234
diff
changeset
|
507 | if (hs->raw_connection != NULL) |
|
935120490eb2
HTTP: isolate socket-related code in http module; initial implementation for keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34234
diff
changeset
|
508 | purple_proxy_connect_cancel(hs->raw_connection); |
|
935120490eb2
HTTP: isolate socket-related code in http module; initial implementation for keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34234
diff
changeset
|
509 | if (hs->fd > 0) |
|
935120490eb2
HTTP: isolate socket-related code in http module; initial implementation for keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34234
diff
changeset
|
510 | close(hs->fd); |
|
935120490eb2
HTTP: isolate socket-related code in http module; initial implementation for keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34234
diff
changeset
|
511 | } |
|
34260
7a55eaa31da6
HTTP: implement keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34257
diff
changeset
|
512 | |
|
34257
935120490eb2
HTTP: isolate socket-related code in http module; initial implementation for keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34234
diff
changeset
|
513 | g_free(hs); |
|
935120490eb2
HTTP: isolate socket-related code in http module; initial implementation for keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34234
diff
changeset
|
514 | } |
|
935120490eb2
HTTP: isolate socket-related code in http module; initial implementation for keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34234
diff
changeset
|
515 | |
|
33432
9c4acb75b2e6
Let's parse response headers
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33431
diff
changeset
|
516 | /*** Headers collection *******************************************************/ |
|
9c4acb75b2e6
Let's parse response headers
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33431
diff
changeset
|
517 | |
|
9c4acb75b2e6
Let's parse response headers
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33431
diff
changeset
|
518 | static PurpleHttpHeaders * purple_http_headers_new(void); |
|
9c4acb75b2e6
Let's parse response headers
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33431
diff
changeset
|
519 | static void purple_http_headers_free(PurpleHttpHeaders *hdrs); |
|
9c4acb75b2e6
Let's parse response headers
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33431
diff
changeset
|
520 | static void purple_http_headers_add(PurpleHttpHeaders *hdrs, const gchar *key, |
|
9c4acb75b2e6
Let's parse response headers
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33431
diff
changeset
|
521 | const gchar *value); |
|
9c4acb75b2e6
Let's parse response headers
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33431
diff
changeset
|
522 | static const GList * purple_http_headers_get_all(PurpleHttpHeaders *hdrs); |
|
33456
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
523 | static GList * purple_http_headers_get_all_by_name( |
|
33451
27d0e5dbc2a1
Implement missing getters/setters and corresponding features
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33450
diff
changeset
|
524 | PurpleHttpHeaders *hdrs, const gchar *key); |
|
33433
fb7ac52ed7df
Let's get response contents
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33432
diff
changeset
|
525 | static const gchar * purple_http_headers_get(PurpleHttpHeaders *hdrs, |
|
fb7ac52ed7df
Let's get response contents
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33432
diff
changeset
|
526 | const gchar *key); |
|
fb7ac52ed7df
Let's get response contents
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33432
diff
changeset
|
527 | static gboolean purple_http_headers_get_int(PurpleHttpHeaders *hdrs, |
|
fb7ac52ed7df
Let's get response contents
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33432
diff
changeset
|
528 | const gchar *key, int *dst); |
|
33434
ec4f343af107
Chunked file transfers support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33433
diff
changeset
|
529 | static gboolean purple_http_headers_match(PurpleHttpHeaders *hdrs, |
|
ec4f343af107
Chunked file transfers support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33433
diff
changeset
|
530 | const gchar *key, const gchar *value); |
|
33432
9c4acb75b2e6
Let's parse response headers
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33431
diff
changeset
|
531 | static gchar * purple_http_headers_dump(PurpleHttpHeaders *hdrs); |
|
9c4acb75b2e6
Let's parse response headers
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33431
diff
changeset
|
532 | |
|
9c4acb75b2e6
Let's parse response headers
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33431
diff
changeset
|
533 | static PurpleHttpHeaders * purple_http_headers_new(void) |
|
9c4acb75b2e6
Let's parse response headers
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33431
diff
changeset
|
534 | { |
|
9c4acb75b2e6
Let's parse response headers
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33431
diff
changeset
|
535 | PurpleHttpHeaders *hdrs = g_new0(PurpleHttpHeaders, 1); |
|
9c4acb75b2e6
Let's parse response headers
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33431
diff
changeset
|
536 | |
|
33437
fb792f8b6265
Fix leak caused by my previous temporary fix
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33436
diff
changeset
|
537 | hdrs->by_name = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, |
|
fb792f8b6265
Fix leak caused by my previous temporary fix
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33436
diff
changeset
|
538 | (GDestroyNotify)g_list_free); |
|
33432
9c4acb75b2e6
Let's parse response headers
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33431
diff
changeset
|
539 | |
|
9c4acb75b2e6
Let's parse response headers
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33431
diff
changeset
|
540 | return hdrs; |
|
9c4acb75b2e6
Let's parse response headers
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33431
diff
changeset
|
541 | } |
|
9c4acb75b2e6
Let's parse response headers
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33431
diff
changeset
|
542 | |
|
9c4acb75b2e6
Let's parse response headers
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33431
diff
changeset
|
543 | static void purple_http_headers_free_kvp(PurpleKeyValuePair *kvp) |
|
9c4acb75b2e6
Let's parse response headers
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33431
diff
changeset
|
544 | { |
|
9c4acb75b2e6
Let's parse response headers
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33431
diff
changeset
|
545 | g_free(kvp->key); |
|
9c4acb75b2e6
Let's parse response headers
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33431
diff
changeset
|
546 | g_free(kvp->value); |
|
9c4acb75b2e6
Let's parse response headers
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33431
diff
changeset
|
547 | g_free(kvp); |
|
9c4acb75b2e6
Let's parse response headers
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33431
diff
changeset
|
548 | } |
|
9c4acb75b2e6
Let's parse response headers
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33431
diff
changeset
|
549 | |
|
9c4acb75b2e6
Let's parse response headers
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33431
diff
changeset
|
550 | static void purple_http_headers_free(PurpleHttpHeaders *hdrs) |
|
9c4acb75b2e6
Let's parse response headers
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33431
diff
changeset
|
551 | { |
|
9c4acb75b2e6
Let's parse response headers
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33431
diff
changeset
|
552 | if (hdrs == NULL) |
|
9c4acb75b2e6
Let's parse response headers
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33431
diff
changeset
|
553 | return; |
|
9c4acb75b2e6
Let's parse response headers
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33431
diff
changeset
|
554 | |
|
9c4acb75b2e6
Let's parse response headers
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33431
diff
changeset
|
555 | g_hash_table_destroy(hdrs->by_name); |
|
9c4acb75b2e6
Let's parse response headers
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33431
diff
changeset
|
556 | g_list_free_full(hdrs->list, |
|
9c4acb75b2e6
Let's parse response headers
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33431
diff
changeset
|
557 | (GDestroyNotify)purple_http_headers_free_kvp); |
|
9c4acb75b2e6
Let's parse response headers
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33431
diff
changeset
|
558 | g_free(hdrs); |
|
9c4acb75b2e6
Let's parse response headers
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33431
diff
changeset
|
559 | } |
|
9c4acb75b2e6
Let's parse response headers
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33431
diff
changeset
|
560 | |
|
9c4acb75b2e6
Let's parse response headers
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33431
diff
changeset
|
561 | static void purple_http_headers_add(PurpleHttpHeaders *hdrs, const gchar *key, |
|
9c4acb75b2e6
Let's parse response headers
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33431
diff
changeset
|
562 | const gchar *value) |
|
9c4acb75b2e6
Let's parse response headers
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33431
diff
changeset
|
563 | { |
|
9c4acb75b2e6
Let's parse response headers
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33431
diff
changeset
|
564 | PurpleKeyValuePair *kvp; |
|
33437
fb792f8b6265
Fix leak caused by my previous temporary fix
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33436
diff
changeset
|
565 | GList *named_values, *new_values; |
|
33447
b890f231e15f
Request headers support, wrapping new API with legacy purple_util_fetch_url
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33446
diff
changeset
|
566 | gchar *key_low; |
|
33432
9c4acb75b2e6
Let's parse response headers
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33431
diff
changeset
|
567 | |
|
9c4acb75b2e6
Let's parse response headers
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33431
diff
changeset
|
568 | g_return_if_fail(hdrs != NULL); |
|
9c4acb75b2e6
Let's parse response headers
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33431
diff
changeset
|
569 | g_return_if_fail(key != NULL); |
|
9c4acb75b2e6
Let's parse response headers
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33431
diff
changeset
|
570 | g_return_if_fail(value != NULL); |
|
9c4acb75b2e6
Let's parse response headers
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33431
diff
changeset
|
571 | |
|
9c4acb75b2e6
Let's parse response headers
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33431
diff
changeset
|
572 | kvp = g_new0(PurpleKeyValuePair, 1); |
|
33447
b890f231e15f
Request headers support, wrapping new API with legacy purple_util_fetch_url
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33446
diff
changeset
|
573 | kvp->key = g_strdup(key); |
|
33432
9c4acb75b2e6
Let's parse response headers
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33431
diff
changeset
|
574 | kvp->value = g_strdup(value); |
|
9c4acb75b2e6
Let's parse response headers
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33431
diff
changeset
|
575 | hdrs->list = g_list_append(hdrs->list, kvp); |
|
9c4acb75b2e6
Let's parse response headers
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33431
diff
changeset
|
576 | |
|
33447
b890f231e15f
Request headers support, wrapping new API with legacy purple_util_fetch_url
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33446
diff
changeset
|
577 | key_low = g_ascii_strdown(key, -1); |
|
b890f231e15f
Request headers support, wrapping new API with legacy purple_util_fetch_url
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33446
diff
changeset
|
578 | named_values = g_hash_table_lookup(hdrs->by_name, key_low); |
|
33437
fb792f8b6265
Fix leak caused by my previous temporary fix
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33436
diff
changeset
|
579 | new_values = g_list_append(named_values, kvp->value); |
|
33447
b890f231e15f
Request headers support, wrapping new API with legacy purple_util_fetch_url
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33446
diff
changeset
|
580 | if (named_values) |
|
b890f231e15f
Request headers support, wrapping new API with legacy purple_util_fetch_url
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33446
diff
changeset
|
581 | g_free(key_low); |
|
b890f231e15f
Request headers support, wrapping new API with legacy purple_util_fetch_url
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33446
diff
changeset
|
582 | else |
|
b890f231e15f
Request headers support, wrapping new API with legacy purple_util_fetch_url
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33446
diff
changeset
|
583 | g_hash_table_insert(hdrs->by_name, key_low, new_values); |
|
b890f231e15f
Request headers support, wrapping new API with legacy purple_util_fetch_url
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33446
diff
changeset
|
584 | } |
|
b890f231e15f
Request headers support, wrapping new API with legacy purple_util_fetch_url
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33446
diff
changeset
|
585 | |
|
b890f231e15f
Request headers support, wrapping new API with legacy purple_util_fetch_url
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33446
diff
changeset
|
586 | static void purple_http_headers_remove(PurpleHttpHeaders *hdrs, |
|
b890f231e15f
Request headers support, wrapping new API with legacy purple_util_fetch_url
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33446
diff
changeset
|
587 | const gchar *key) |
|
b890f231e15f
Request headers support, wrapping new API with legacy purple_util_fetch_url
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33446
diff
changeset
|
588 | { |
|
b890f231e15f
Request headers support, wrapping new API with legacy purple_util_fetch_url
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33446
diff
changeset
|
589 | GList *it, *curr; |
|
b890f231e15f
Request headers support, wrapping new API with legacy purple_util_fetch_url
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33446
diff
changeset
|
590 | |
|
b890f231e15f
Request headers support, wrapping new API with legacy purple_util_fetch_url
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33446
diff
changeset
|
591 | g_return_if_fail(hdrs != NULL); |
|
b890f231e15f
Request headers support, wrapping new API with legacy purple_util_fetch_url
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33446
diff
changeset
|
592 | g_return_if_fail(key != NULL); |
|
b890f231e15f
Request headers support, wrapping new API with legacy purple_util_fetch_url
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33446
diff
changeset
|
593 | |
|
b890f231e15f
Request headers support, wrapping new API with legacy purple_util_fetch_url
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33446
diff
changeset
|
594 | if (!g_hash_table_remove(hdrs->by_name, key)) |
|
b890f231e15f
Request headers support, wrapping new API with legacy purple_util_fetch_url
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33446
diff
changeset
|
595 | return; |
|
b890f231e15f
Request headers support, wrapping new API with legacy purple_util_fetch_url
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33446
diff
changeset
|
596 | |
|
b890f231e15f
Request headers support, wrapping new API with legacy purple_util_fetch_url
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33446
diff
changeset
|
597 | /* Could be optimized to O(1). */ |
|
b890f231e15f
Request headers support, wrapping new API with legacy purple_util_fetch_url
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33446
diff
changeset
|
598 | it = g_list_first(hdrs->list); |
|
b890f231e15f
Request headers support, wrapping new API with legacy purple_util_fetch_url
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33446
diff
changeset
|
599 | while (it) |
|
b890f231e15f
Request headers support, wrapping new API with legacy purple_util_fetch_url
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33446
diff
changeset
|
600 | { |
|
b890f231e15f
Request headers support, wrapping new API with legacy purple_util_fetch_url
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33446
diff
changeset
|
601 | PurpleKeyValuePair *kvp = it->data; |
|
b890f231e15f
Request headers support, wrapping new API with legacy purple_util_fetch_url
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33446
diff
changeset
|
602 | curr = it; |
|
b890f231e15f
Request headers support, wrapping new API with legacy purple_util_fetch_url
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33446
diff
changeset
|
603 | it = g_list_next(it); |
|
b890f231e15f
Request headers support, wrapping new API with legacy purple_util_fetch_url
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33446
diff
changeset
|
604 | if (g_ascii_strcasecmp(kvp->key, key) != 0) |
|
b890f231e15f
Request headers support, wrapping new API with legacy purple_util_fetch_url
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33446
diff
changeset
|
605 | continue; |
|
b890f231e15f
Request headers support, wrapping new API with legacy purple_util_fetch_url
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33446
diff
changeset
|
606 | |
|
b890f231e15f
Request headers support, wrapping new API with legacy purple_util_fetch_url
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33446
diff
changeset
|
607 | hdrs->list = g_list_delete_link(hdrs->list, curr); |
|
b890f231e15f
Request headers support, wrapping new API with legacy purple_util_fetch_url
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33446
diff
changeset
|
608 | purple_http_headers_free_kvp(kvp); |
|
b890f231e15f
Request headers support, wrapping new API with legacy purple_util_fetch_url
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33446
diff
changeset
|
609 | } |
|
33432
9c4acb75b2e6
Let's parse response headers
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33431
diff
changeset
|
610 | } |
|
9c4acb75b2e6
Let's parse response headers
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33431
diff
changeset
|
611 | |
|
9c4acb75b2e6
Let's parse response headers
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33431
diff
changeset
|
612 | static const GList * purple_http_headers_get_all(PurpleHttpHeaders *hdrs) |
|
9c4acb75b2e6
Let's parse response headers
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33431
diff
changeset
|
613 | { |
|
9c4acb75b2e6
Let's parse response headers
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33431
diff
changeset
|
614 | return hdrs->list; |
|
9c4acb75b2e6
Let's parse response headers
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33431
diff
changeset
|
615 | } |
|
9c4acb75b2e6
Let's parse response headers
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33431
diff
changeset
|
616 | |
|
33456
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
617 | /* return const */ |
|
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
618 | static GList * purple_http_headers_get_all_by_name( |
|
33451
27d0e5dbc2a1
Implement missing getters/setters and corresponding features
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33450
diff
changeset
|
619 | PurpleHttpHeaders *hdrs, const gchar *key) |
|
33433
fb7ac52ed7df
Let's get response contents
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33432
diff
changeset
|
620 | { |
|
fb7ac52ed7df
Let's get response contents
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33432
diff
changeset
|
621 | GList *values; |
|
33434
ec4f343af107
Chunked file transfers support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33433
diff
changeset
|
622 | gchar *key_low; |
|
33433
fb7ac52ed7df
Let's get response contents
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33432
diff
changeset
|
623 | |
|
fb7ac52ed7df
Let's get response contents
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33432
diff
changeset
|
624 | g_return_val_if_fail(hdrs != NULL, NULL); |
|
fb7ac52ed7df
Let's get response contents
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33432
diff
changeset
|
625 | g_return_val_if_fail(key != NULL, NULL); |
|
fb7ac52ed7df
Let's get response contents
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33432
diff
changeset
|
626 | |
|
33434
ec4f343af107
Chunked file transfers support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33433
diff
changeset
|
627 | key_low = g_ascii_strdown(key, -1); |
|
ec4f343af107
Chunked file transfers support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33433
diff
changeset
|
628 | values = g_hash_table_lookup(hdrs->by_name, key_low); |
|
ec4f343af107
Chunked file transfers support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33433
diff
changeset
|
629 | g_free(key_low); |
|
33451
27d0e5dbc2a1
Implement missing getters/setters and corresponding features
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33450
diff
changeset
|
630 | |
|
27d0e5dbc2a1
Implement missing getters/setters and corresponding features
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33450
diff
changeset
|
631 | return values; |
|
27d0e5dbc2a1
Implement missing getters/setters and corresponding features
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33450
diff
changeset
|
632 | } |
|
27d0e5dbc2a1
Implement missing getters/setters and corresponding features
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33450
diff
changeset
|
633 | |
|
27d0e5dbc2a1
Implement missing getters/setters and corresponding features
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33450
diff
changeset
|
634 | static const gchar * purple_http_headers_get(PurpleHttpHeaders *hdrs, |
|
27d0e5dbc2a1
Implement missing getters/setters and corresponding features
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33450
diff
changeset
|
635 | const gchar *key) |
|
27d0e5dbc2a1
Implement missing getters/setters and corresponding features
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33450
diff
changeset
|
636 | { |
|
27d0e5dbc2a1
Implement missing getters/setters and corresponding features
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33450
diff
changeset
|
637 | const GList *values = purple_http_headers_get_all_by_name(hdrs, key); |
|
27d0e5dbc2a1
Implement missing getters/setters and corresponding features
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33450
diff
changeset
|
638 | |
|
33433
fb7ac52ed7df
Let's get response contents
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33432
diff
changeset
|
639 | if (!values) |
|
fb7ac52ed7df
Let's get response contents
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33432
diff
changeset
|
640 | return NULL; |
|
fb7ac52ed7df
Let's get response contents
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33432
diff
changeset
|
641 | |
|
fb7ac52ed7df
Let's get response contents
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33432
diff
changeset
|
642 | return values->data; |
|
fb7ac52ed7df
Let's get response contents
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33432
diff
changeset
|
643 | } |
|
fb7ac52ed7df
Let's get response contents
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33432
diff
changeset
|
644 | |
|
fb7ac52ed7df
Let's get response contents
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33432
diff
changeset
|
645 | static gboolean purple_http_headers_get_int(PurpleHttpHeaders *hdrs, |
|
fb7ac52ed7df
Let's get response contents
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33432
diff
changeset
|
646 | const gchar *key, int *dst) |
|
fb7ac52ed7df
Let's get response contents
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33432
diff
changeset
|
647 | { |
|
fb7ac52ed7df
Let's get response contents
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33432
diff
changeset
|
648 | int val; |
|
fb7ac52ed7df
Let's get response contents
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33432
diff
changeset
|
649 | const gchar *str; |
|
fb7ac52ed7df
Let's get response contents
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33432
diff
changeset
|
650 | |
|
fb7ac52ed7df
Let's get response contents
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33432
diff
changeset
|
651 | str = purple_http_headers_get(hdrs, key); |
|
fb7ac52ed7df
Let's get response contents
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33432
diff
changeset
|
652 | if (!str) |
|
fb7ac52ed7df
Let's get response contents
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33432
diff
changeset
|
653 | return FALSE; |
|
fb7ac52ed7df
Let's get response contents
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33432
diff
changeset
|
654 | |
|
fb7ac52ed7df
Let's get response contents
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33432
diff
changeset
|
655 | if (1 != sscanf(str, "%d", &val)) |
|
fb7ac52ed7df
Let's get response contents
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33432
diff
changeset
|
656 | return FALSE; |
|
fb7ac52ed7df
Let's get response contents
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33432
diff
changeset
|
657 | |
|
fb7ac52ed7df
Let's get response contents
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33432
diff
changeset
|
658 | *dst = val; |
|
fb7ac52ed7df
Let's get response contents
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33432
diff
changeset
|
659 | return TRUE; |
|
fb7ac52ed7df
Let's get response contents
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33432
diff
changeset
|
660 | } |
|
fb7ac52ed7df
Let's get response contents
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33432
diff
changeset
|
661 | |
|
33434
ec4f343af107
Chunked file transfers support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33433
diff
changeset
|
662 | static gboolean purple_http_headers_match(PurpleHttpHeaders *hdrs, |
|
ec4f343af107
Chunked file transfers support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33433
diff
changeset
|
663 | const gchar *key, const gchar *value) |
|
ec4f343af107
Chunked file transfers support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33433
diff
changeset
|
664 | { |
|
ec4f343af107
Chunked file transfers support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33433
diff
changeset
|
665 | const gchar *str; |
|
ec4f343af107
Chunked file transfers support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33433
diff
changeset
|
666 | |
|
ec4f343af107
Chunked file transfers support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33433
diff
changeset
|
667 | str = purple_http_headers_get(hdrs, key); |
|
ec4f343af107
Chunked file transfers support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33433
diff
changeset
|
668 | if (str == NULL || value == NULL) |
|
ec4f343af107
Chunked file transfers support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33433
diff
changeset
|
669 | return str == value; |
|
ec4f343af107
Chunked file transfers support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33433
diff
changeset
|
670 | |
|
ec4f343af107
Chunked file transfers support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33433
diff
changeset
|
671 | return (g_ascii_strcasecmp(str, value) == 0); |
|
ec4f343af107
Chunked file transfers support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33433
diff
changeset
|
672 | } |
|
ec4f343af107
Chunked file transfers support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33433
diff
changeset
|
673 | |
|
33432
9c4acb75b2e6
Let's parse response headers
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33431
diff
changeset
|
674 | static gchar * purple_http_headers_dump(PurpleHttpHeaders *hdrs) |
|
9c4acb75b2e6
Let's parse response headers
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33431
diff
changeset
|
675 | { |
|
9c4acb75b2e6
Let's parse response headers
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33431
diff
changeset
|
676 | const GList *hdr; |
|
9c4acb75b2e6
Let's parse response headers
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33431
diff
changeset
|
677 | |
|
9c4acb75b2e6
Let's parse response headers
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33431
diff
changeset
|
678 | GString *s = g_string_new(""); |
|
9c4acb75b2e6
Let's parse response headers
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33431
diff
changeset
|
679 | |
|
9c4acb75b2e6
Let's parse response headers
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33431
diff
changeset
|
680 | hdr = purple_http_headers_get_all(hdrs); |
|
9c4acb75b2e6
Let's parse response headers
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33431
diff
changeset
|
681 | while (hdr) { |
|
9c4acb75b2e6
Let's parse response headers
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33431
diff
changeset
|
682 | PurpleKeyValuePair *kvp = hdr->data; |
|
9c4acb75b2e6
Let's parse response headers
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33431
diff
changeset
|
683 | hdr = g_list_next(hdr); |
|
9c4acb75b2e6
Let's parse response headers
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33431
diff
changeset
|
684 | |
|
9c4acb75b2e6
Let's parse response headers
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33431
diff
changeset
|
685 | g_string_append_printf(s, "%s: %s%s", kvp->key, |
|
9c4acb75b2e6
Let's parse response headers
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33431
diff
changeset
|
686 | (gchar*)kvp->value, hdr ? "\n" : ""); |
|
9c4acb75b2e6
Let's parse response headers
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33431
diff
changeset
|
687 | } |
|
9c4acb75b2e6
Let's parse response headers
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33431
diff
changeset
|
688 | |
|
9c4acb75b2e6
Let's parse response headers
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33431
diff
changeset
|
689 | return g_string_free(s, FALSE); |
|
9c4acb75b2e6
Let's parse response headers
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33431
diff
changeset
|
690 | } |
|
33429
1ce1faf4e675
Extend URL parsing
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33427
diff
changeset
|
691 | |
|
33430
013c5aebb665
Let's connect
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33429
diff
changeset
|
692 | /*** HTTP protocol backend ****************************************************/ |
|
013c5aebb665
Let's connect
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33429
diff
changeset
|
693 | |
|
34260
7a55eaa31da6
HTTP: implement keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34257
diff
changeset
|
694 | static void _purple_http_disconnect(PurpleHttpConnection *hc, |
|
7a55eaa31da6
HTTP: implement keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34257
diff
changeset
|
695 | gboolean is_graceful); |
|
33430
013c5aebb665
Let's connect
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33429
diff
changeset
|
696 | |
|
33431
704de181d1d2
Let's request
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33430
diff
changeset
|
697 | static void _purple_http_gen_headers(PurpleHttpConnection *hc); |
|
33522
7a3d131c3086
HTTP: don't freeze download on files larger than buffer size
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33521
diff
changeset
|
698 | static gboolean _purple_http_recv_loopbody(PurpleHttpConnection *hc, gint fd); |
|
7a3d131c3086
HTTP: don't freeze download on files larger than buffer size
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33521
diff
changeset
|
699 | static void _purple_http_recv(gpointer _hc, gint fd, |
|
7a3d131c3086
HTTP: don't freeze download on files larger than buffer size
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33521
diff
changeset
|
700 | PurpleInputCondition cond); |
|
33430
013c5aebb665
Let's connect
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33429
diff
changeset
|
701 | static void _purple_http_send(gpointer _hc, gint fd, PurpleInputCondition cond); |
|
013c5aebb665
Let's connect
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33429
diff
changeset
|
702 | |
|
013c5aebb665
Let's connect
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33429
diff
changeset
|
703 | /* closes current connection (if exists), estabilishes one and proceeds with |
|
013c5aebb665
Let's connect
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33429
diff
changeset
|
704 | * request */ |
|
013c5aebb665
Let's connect
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33429
diff
changeset
|
705 | static gboolean _purple_http_reconnect(PurpleHttpConnection *hc); |
|
013c5aebb665
Let's connect
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33429
diff
changeset
|
706 | |
|
013c5aebb665
Let's connect
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33429
diff
changeset
|
707 | static void _purple_http_error(PurpleHttpConnection *hc, const char *format, |
|
013c5aebb665
Let's connect
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33429
diff
changeset
|
708 | ...) G_GNUC_PRINTF(2, 3); |
|
013c5aebb665
Let's connect
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33429
diff
changeset
|
709 | |
|
013c5aebb665
Let's connect
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33429
diff
changeset
|
710 | static void _purple_http_error(PurpleHttpConnection *hc, const char *format, |
|
013c5aebb665
Let's connect
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33429
diff
changeset
|
711 | ...) |
|
013c5aebb665
Let's connect
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33429
diff
changeset
|
712 | { |
|
013c5aebb665
Let's connect
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33429
diff
changeset
|
713 | va_list args; |
|
013c5aebb665
Let's connect
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33429
diff
changeset
|
714 | |
|
013c5aebb665
Let's connect
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33429
diff
changeset
|
715 | va_start(args, format); |
|
013c5aebb665
Let's connect
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33429
diff
changeset
|
716 | hc->response->error = g_strdup_vprintf(format, args); |
|
013c5aebb665
Let's connect
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33429
diff
changeset
|
717 | va_end(args); |
|
013c5aebb665
Let's connect
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33429
diff
changeset
|
718 | |
|
34265
e6de87604147
HTTP: get rid of the second msn's own HTTP implementation (for soap)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34263
diff
changeset
|
719 | if (purple_debug_is_verbose()) |
|
e6de87604147
HTTP: get rid of the second msn's own HTTP implementation (for soap)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34263
diff
changeset
|
720 | purple_debug_warning("http", "error: %s\n", hc->response->error); |
|
e6de87604147
HTTP: get rid of the second msn's own HTTP implementation (for soap)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34263
diff
changeset
|
721 | |
|
33430
013c5aebb665
Let's connect
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33429
diff
changeset
|
722 | purple_http_conn_cancel(hc); |
|
013c5aebb665
Let's connect
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33429
diff
changeset
|
723 | } |
|
013c5aebb665
Let's connect
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33429
diff
changeset
|
724 | |
|
33431
704de181d1d2
Let's request
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33430
diff
changeset
|
725 | static void _purple_http_gen_headers(PurpleHttpConnection *hc) |
|
704de181d1d2
Let's request
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33430
diff
changeset
|
726 | { |
|
704de181d1d2
Let's request
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33430
diff
changeset
|
727 | GString *h; |
|
704de181d1d2
Let's request
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33430
diff
changeset
|
728 | PurpleHttpURL *url; |
|
33447
b890f231e15f
Request headers support, wrapping new API with legacy purple_util_fetch_url
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33446
diff
changeset
|
729 | const GList *hdr; |
|
33451
27d0e5dbc2a1
Implement missing getters/setters and corresponding features
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33450
diff
changeset
|
730 | PurpleHttpRequest *req; |
|
27d0e5dbc2a1
Implement missing getters/setters and corresponding features
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33450
diff
changeset
|
731 | PurpleHttpHeaders *hdrs; |
|
33453
3cb58ea9667c
HTTP Proxy support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33452
diff
changeset
|
732 | gchar *request_url, *tmp_url = NULL; |
|
3cb58ea9667c
HTTP Proxy support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33452
diff
changeset
|
733 | |
|
3cb58ea9667c
HTTP Proxy support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33452
diff
changeset
|
734 | PurpleProxyInfo *proxy; |
|
3cb58ea9667c
HTTP Proxy support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33452
diff
changeset
|
735 | gboolean proxy_http = FALSE; |
|
3cb58ea9667c
HTTP Proxy support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33452
diff
changeset
|
736 | const gchar *proxy_username, *proxy_password; |
|
33431
704de181d1d2
Let's request
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33430
diff
changeset
|
737 | |
|
704de181d1d2
Let's request
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33430
diff
changeset
|
738 | g_return_if_fail(hc != NULL); |
|
704de181d1d2
Let's request
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33430
diff
changeset
|
739 | |
|
704de181d1d2
Let's request
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33430
diff
changeset
|
740 | if (hc->request_header != NULL) |
|
704de181d1d2
Let's request
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33430
diff
changeset
|
741 | return; |
|
704de181d1d2
Let's request
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33430
diff
changeset
|
742 | |
|
33451
27d0e5dbc2a1
Implement missing getters/setters and corresponding features
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33450
diff
changeset
|
743 | req = hc->request; |
|
33431
704de181d1d2
Let's request
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33430
diff
changeset
|
744 | url = hc->url; |
|
33451
27d0e5dbc2a1
Implement missing getters/setters and corresponding features
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33450
diff
changeset
|
745 | hdrs = req->headers; |
|
33431
704de181d1d2
Let's request
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33430
diff
changeset
|
746 | proxy = purple_proxy_get_setup(hc->gc ? |
|
704de181d1d2
Let's request
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33430
diff
changeset
|
747 | purple_connection_get_account(hc->gc) : NULL); |
|
704de181d1d2
Let's request
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33430
diff
changeset
|
748 | |
|
33453
3cb58ea9667c
HTTP Proxy support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33452
diff
changeset
|
749 | proxy_http = (purple_proxy_info_get_type(proxy) == PURPLE_PROXY_HTTP || |
|
3cb58ea9667c
HTTP Proxy support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33452
diff
changeset
|
750 | purple_proxy_info_get_type(proxy) == PURPLE_PROXY_USE_ENVVAR); |
|
33454
c5c9135ffafa
Tunelled http proxy is not a http proxy
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33453
diff
changeset
|
751 | /* this is HTTP proxy, but used with tunelling with CONNECT */ |
|
c5c9135ffafa
Tunelled http proxy is not a http proxy
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33453
diff
changeset
|
752 | if (proxy_http && url->port != 80) |
|
c5c9135ffafa
Tunelled http proxy is not a http proxy
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33453
diff
changeset
|
753 | proxy_http = FALSE; |
|
33453
3cb58ea9667c
HTTP Proxy support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33452
diff
changeset
|
754 | |
|
33431
704de181d1d2
Let's request
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33430
diff
changeset
|
755 | hc->request_header = h = g_string_new(""); |
|
704de181d1d2
Let's request
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33430
diff
changeset
|
756 | hc->request_header_written = 0; |
|
33457
81f92a310aff
Writing request contents
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33456
diff
changeset
|
757 | hc->request_contents_written = 0; |
|
33431
704de181d1d2
Let's request
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33430
diff
changeset
|
758 | |
|
33453
3cb58ea9667c
HTTP Proxy support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33452
diff
changeset
|
759 | if (proxy_http) |
|
3cb58ea9667c
HTTP Proxy support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33452
diff
changeset
|
760 | request_url = tmp_url = purple_http_url_print(url); |
|
3cb58ea9667c
HTTP Proxy support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33452
diff
changeset
|
761 | else |
|
3cb58ea9667c
HTTP Proxy support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33452
diff
changeset
|
762 | request_url = url->path; |
|
3cb58ea9667c
HTTP Proxy support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33452
diff
changeset
|
763 | |
|
33451
27d0e5dbc2a1
Implement missing getters/setters and corresponding features
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33450
diff
changeset
|
764 | g_string_append_printf(h, "%s %s HTTP/%s\r\n", |
|
27d0e5dbc2a1
Implement missing getters/setters and corresponding features
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33450
diff
changeset
|
765 | req->method ? req->method : "GET", |
|
33453
3cb58ea9667c
HTTP Proxy support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33452
diff
changeset
|
766 | request_url, |
|
33451
27d0e5dbc2a1
Implement missing getters/setters and corresponding features
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33450
diff
changeset
|
767 | req->http11 ? "1.1" : "1.0"); |
|
33447
b890f231e15f
Request headers support, wrapping new API with legacy purple_util_fetch_url
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33446
diff
changeset
|
768 | |
|
33453
3cb58ea9667c
HTTP Proxy support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33452
diff
changeset
|
769 | if (tmp_url) |
|
3cb58ea9667c
HTTP Proxy support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33452
diff
changeset
|
770 | g_free(tmp_url); |
|
3cb58ea9667c
HTTP Proxy support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33452
diff
changeset
|
771 | |
|
33451
27d0e5dbc2a1
Implement missing getters/setters and corresponding features
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33450
diff
changeset
|
772 | if (!purple_http_headers_get(hdrs, "host")) |
|
33447
b890f231e15f
Request headers support, wrapping new API with legacy purple_util_fetch_url
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33446
diff
changeset
|
773 | g_string_append_printf(h, "Host: %s\r\n", url->host); |
|
34257
935120490eb2
HTTP: isolate socket-related code in http module; initial implementation for keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34234
diff
changeset
|
774 | if (!purple_http_headers_get(hdrs, "connection")) { |
|
935120490eb2
HTTP: isolate socket-related code in http module; initial implementation for keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34234
diff
changeset
|
775 | g_string_append(h, "Connection: "); |
|
935120490eb2
HTTP: isolate socket-related code in http module; initial implementation for keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34234
diff
changeset
|
776 | g_string_append(h, hc->is_keepalive ? |
|
935120490eb2
HTTP: isolate socket-related code in http module; initial implementation for keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34234
diff
changeset
|
777 | "Keep-Alive\r\n" : "close\r\n"); |
|
935120490eb2
HTTP: isolate socket-related code in http module; initial implementation for keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34234
diff
changeset
|
778 | } |
|
33451
27d0e5dbc2a1
Implement missing getters/setters and corresponding features
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33450
diff
changeset
|
779 | if (!purple_http_headers_get(hdrs, "accept")) |
|
33453
3cb58ea9667c
HTTP Proxy support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33452
diff
changeset
|
780 | g_string_append(h, "Accept: */*\r\n"); |
|
3cb58ea9667c
HTTP Proxy support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33452
diff
changeset
|
781 | |
|
34232
a5517f235e0f
HTTP: migrate purple_util_fetch_url_request to new API for GG prpl
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34225
diff
changeset
|
782 | if (!purple_http_headers_get(hdrs, "content-length") && ( |
|
a5517f235e0f
HTTP: migrate purple_util_fetch_url_request to new API for GG prpl
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34225
diff
changeset
|
783 | req->contents_length > 0 || |
|
a5517f235e0f
HTTP: migrate purple_util_fetch_url_request to new API for GG prpl
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34225
diff
changeset
|
784 | purple_http_request_is_method(req, "post"))) |
|
a5517f235e0f
HTTP: migrate purple_util_fetch_url_request to new API for GG prpl
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34225
diff
changeset
|
785 | { |
|
33457
81f92a310aff
Writing request contents
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33456
diff
changeset
|
786 | g_string_append_printf(h, "Content-Length: %u\r\n", |
|
81f92a310aff
Writing request contents
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33456
diff
changeset
|
787 | req->contents_length); |
|
34232
a5517f235e0f
HTTP: migrate purple_util_fetch_url_request to new API for GG prpl
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34225
diff
changeset
|
788 | } |
|
33457
81f92a310aff
Writing request contents
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33456
diff
changeset
|
789 | |
|
33453
3cb58ea9667c
HTTP Proxy support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33452
diff
changeset
|
790 | if (proxy_http) |
|
34257
935120490eb2
HTTP: isolate socket-related code in http module; initial implementation for keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34234
diff
changeset
|
791 | g_string_append(h, "Proxy-Connection: close\r\n"); /* TEST: proxy+KeepAlive */ |
|
33453
3cb58ea9667c
HTTP Proxy support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33452
diff
changeset
|
792 | |
|
3cb58ea9667c
HTTP Proxy support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33452
diff
changeset
|
793 | proxy_username = purple_proxy_info_get_username(proxy); |
|
3cb58ea9667c
HTTP Proxy support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33452
diff
changeset
|
794 | if (proxy_http && proxy_username != NULL && proxy_username[0] != '\0') { |
|
3cb58ea9667c
HTTP Proxy support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33452
diff
changeset
|
795 | gchar *proxy_auth, *ntlm_type1, *tmp; |
|
3cb58ea9667c
HTTP Proxy support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33452
diff
changeset
|
796 | int len; |
|
3cb58ea9667c
HTTP Proxy support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33452
diff
changeset
|
797 | |
|
3cb58ea9667c
HTTP Proxy support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33452
diff
changeset
|
798 | proxy_password = purple_proxy_info_get_password(proxy); |
|
3cb58ea9667c
HTTP Proxy support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33452
diff
changeset
|
799 | if (proxy_password == NULL) |
|
3cb58ea9667c
HTTP Proxy support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33452
diff
changeset
|
800 | proxy_password = ""; |
|
3cb58ea9667c
HTTP Proxy support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33452
diff
changeset
|
801 | |
|
3cb58ea9667c
HTTP Proxy support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33452
diff
changeset
|
802 | tmp = g_strdup_printf("%s:%s", proxy_username, proxy_password); |
|
3cb58ea9667c
HTTP Proxy support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33452
diff
changeset
|
803 | len = strlen(tmp); |
|
3cb58ea9667c
HTTP Proxy support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33452
diff
changeset
|
804 | proxy_auth = purple_base64_encode((const guchar *)tmp, len); |
|
3cb58ea9667c
HTTP Proxy support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33452
diff
changeset
|
805 | memset(tmp, 0, len); |
|
3cb58ea9667c
HTTP Proxy support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33452
diff
changeset
|
806 | g_free(tmp); |
|
3cb58ea9667c
HTTP Proxy support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33452
diff
changeset
|
807 | |
|
33469
6c2fa6d8037d
HTTP: simplify hostname getting
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33468
diff
changeset
|
808 | ntlm_type1 = purple_ntlm_gen_type1(purple_get_host_name(), ""); |
|
33453
3cb58ea9667c
HTTP Proxy support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33452
diff
changeset
|
809 | |
|
3cb58ea9667c
HTTP Proxy support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33452
diff
changeset
|
810 | g_string_append_printf(h, "Proxy-Authorization: Basic %s\r\n", |
|
3cb58ea9667c
HTTP Proxy support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33452
diff
changeset
|
811 | proxy_auth); |
|
3cb58ea9667c
HTTP Proxy support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33452
diff
changeset
|
812 | g_string_append_printf(h, "Proxy-Authorization: NTLM %s\r\n", |
|
3cb58ea9667c
HTTP Proxy support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33452
diff
changeset
|
813 | ntlm_type1); |
|
34257
935120490eb2
HTTP: isolate socket-related code in http module; initial implementation for keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34234
diff
changeset
|
814 | g_string_append(h, "Proxy-Connection: close\r\n"); /* TEST: proxy+KeepAlive */ |
|
33453
3cb58ea9667c
HTTP Proxy support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33452
diff
changeset
|
815 | |
|
3cb58ea9667c
HTTP Proxy support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33452
diff
changeset
|
816 | memset(proxy_auth, 0, strlen(proxy_auth)); |
|
3cb58ea9667c
HTTP Proxy support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33452
diff
changeset
|
817 | g_free(proxy_auth); |
|
3cb58ea9667c
HTTP Proxy support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33452
diff
changeset
|
818 | g_free(ntlm_type1); |
|
3cb58ea9667c
HTTP Proxy support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33452
diff
changeset
|
819 | } |
|
33431
704de181d1d2
Let's request
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33430
diff
changeset
|
820 | |
|
33451
27d0e5dbc2a1
Implement missing getters/setters and corresponding features
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33450
diff
changeset
|
821 | hdr = purple_http_headers_get_all(hdrs); |
|
33447
b890f231e15f
Request headers support, wrapping new API with legacy purple_util_fetch_url
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33446
diff
changeset
|
822 | while (hdr) { |
|
b890f231e15f
Request headers support, wrapping new API with legacy purple_util_fetch_url
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33446
diff
changeset
|
823 | PurpleKeyValuePair *kvp = hdr->data; |
|
b890f231e15f
Request headers support, wrapping new API with legacy purple_util_fetch_url
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33446
diff
changeset
|
824 | hdr = g_list_next(hdr); |
|
33431
704de181d1d2
Let's request
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33430
diff
changeset
|
825 | |
|
33447
b890f231e15f
Request headers support, wrapping new API with legacy purple_util_fetch_url
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33446
diff
changeset
|
826 | g_string_append_printf(h, "%s: %s\r\n", |
|
b890f231e15f
Request headers support, wrapping new API with legacy purple_util_fetch_url
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33446
diff
changeset
|
827 | kvp->key, (gchar*)kvp->value); |
|
b890f231e15f
Request headers support, wrapping new API with legacy purple_util_fetch_url
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33446
diff
changeset
|
828 | } |
|
33431
704de181d1d2
Let's request
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33430
diff
changeset
|
829 | |
|
33458
59b3364f690e
Sending cookies
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33457
diff
changeset
|
830 | if (!purple_http_cookie_jar_is_empty(req->cookie_jar)) { |
|
59b3364f690e
Sending cookies
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33457
diff
changeset
|
831 | gchar * cookies = purple_http_cookie_jar_gen(req->cookie_jar); |
|
59b3364f690e
Sending cookies
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33457
diff
changeset
|
832 | g_string_append_printf(h, "Cookie: %s\r\n", cookies); |
|
59b3364f690e
Sending cookies
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33457
diff
changeset
|
833 | g_free(cookies); |
|
59b3364f690e
Sending cookies
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33457
diff
changeset
|
834 | } |
|
33456
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
835 | |
|
33431
704de181d1d2
Let's request
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33430
diff
changeset
|
836 | g_string_append_printf(h, "\r\n"); |
|
704de181d1d2
Let's request
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33430
diff
changeset
|
837 | |
|
704de181d1d2
Let's request
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33430
diff
changeset
|
838 | if (purple_debug_is_unsafe() && purple_debug_is_verbose()) { |
|
704de181d1d2
Let's request
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33430
diff
changeset
|
839 | purple_debug_misc("http", "Generated request headers:\n%s", |
|
704de181d1d2
Let's request
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33430
diff
changeset
|
840 | h->str); |
|
704de181d1d2
Let's request
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33430
diff
changeset
|
841 | } |
|
704de181d1d2
Let's request
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33430
diff
changeset
|
842 | } |
|
704de181d1d2
Let's request
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33430
diff
changeset
|
843 | |
|
33433
fb7ac52ed7df
Let's get response contents
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33432
diff
changeset
|
844 | static gboolean _purple_http_recv_headers(PurpleHttpConnection *hc, |
|
33432
9c4acb75b2e6
Let's parse response headers
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33431
diff
changeset
|
845 | const gchar *buf, int len) |
|
9c4acb75b2e6
Let's parse response headers
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33431
diff
changeset
|
846 | { |
|
9c4acb75b2e6
Let's parse response headers
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33431
diff
changeset
|
847 | gchar *eol, *delim; |
|
9c4acb75b2e6
Let's parse response headers
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33431
diff
changeset
|
848 | |
|
33435
ab0560aa8ca4
Segfault shotgun debugging
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33434
diff
changeset
|
849 | if (hc->headers_got) { |
|
ab0560aa8ca4
Segfault shotgun debugging
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33434
diff
changeset
|
850 | purple_debug_error("http", "Headers already got\n"); |
|
ab0560aa8ca4
Segfault shotgun debugging
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33434
diff
changeset
|
851 | _purple_http_error(hc, _("Error parsing HTTP")); |
|
ab0560aa8ca4
Segfault shotgun debugging
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33434
diff
changeset
|
852 | return FALSE; |
|
ab0560aa8ca4
Segfault shotgun debugging
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33434
diff
changeset
|
853 | } |
|
ab0560aa8ca4
Segfault shotgun debugging
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33434
diff
changeset
|
854 | |
|
33443
ab563d4c927a
Don't eat resources with malicious http server
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33439
diff
changeset
|
855 | g_string_append_len(hc->response_buffer, buf, len); |
|
ab563d4c927a
Don't eat resources with malicious http server
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33439
diff
changeset
|
856 | if (hc->response_buffer->len > PURPLE_HTTP_MAX_RECV_BUFFER_LEN) { |
|
ab563d4c927a
Don't eat resources with malicious http server
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33439
diff
changeset
|
857 | purple_debug_error("http", |
|
ab563d4c927a
Don't eat resources with malicious http server
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33439
diff
changeset
|
858 | "Buffer too big when parsing headers\n"); |
|
ab563d4c927a
Don't eat resources with malicious http server
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33439
diff
changeset
|
859 | _purple_http_error(hc, _("Error parsing HTTP")); |
|
ab563d4c927a
Don't eat resources with malicious http server
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33439
diff
changeset
|
860 | return FALSE; |
|
ab563d4c927a
Don't eat resources with malicious http server
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33439
diff
changeset
|
861 | } |
|
ab563d4c927a
Don't eat resources with malicious http server
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33439
diff
changeset
|
862 | |
|
33432
9c4acb75b2e6
Let's parse response headers
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33431
diff
changeset
|
863 | while ((eol = strstr(hc->response_buffer->str, "\r\n")) |
|
9c4acb75b2e6
Let's parse response headers
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33431
diff
changeset
|
864 | != NULL) { |
|
9c4acb75b2e6
Let's parse response headers
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33431
diff
changeset
|
865 | gchar *hdrline = hc->response_buffer->str; |
|
9c4acb75b2e6
Let's parse response headers
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33431
diff
changeset
|
866 | int hdrline_len = eol - hdrline; |
|
9c4acb75b2e6
Let's parse response headers
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33431
diff
changeset
|
867 | |
|
9c4acb75b2e6
Let's parse response headers
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33431
diff
changeset
|
868 | hdrline[hdrline_len] = '\0'; |
|
9c4acb75b2e6
Let's parse response headers
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33431
diff
changeset
|
869 | |
|
9c4acb75b2e6
Let's parse response headers
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33431
diff
changeset
|
870 | if (hdrline[0] == '\0') { |
|
34286
8d0979967d05
HTTP: removing extra yahoo HTTP implementations - file transfer (and small improvements to libpurple http and ft code)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34272
diff
changeset
|
871 | if (!hc->main_header_got) { |
|
8d0979967d05
HTTP: removing extra yahoo HTTP implementations - file transfer (and small improvements to libpurple http and ft code)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34272
diff
changeset
|
872 | if (purple_debug_is_verbose() && |
|
8d0979967d05
HTTP: removing extra yahoo HTTP implementations - file transfer (and small improvements to libpurple http and ft code)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34272
diff
changeset
|
873 | hc->is_keepalive) |
|
8d0979967d05
HTTP: removing extra yahoo HTTP implementations - file transfer (and small improvements to libpurple http and ft code)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34272
diff
changeset
|
874 | { |
|
34260
7a55eaa31da6
HTTP: implement keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34257
diff
changeset
|
875 | purple_debug_misc("http", "Got keep-" |
|
7a55eaa31da6
HTTP: implement keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34257
diff
changeset
|
876 | "alive terminator from previous" |
|
7a55eaa31da6
HTTP: implement keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34257
diff
changeset
|
877 | " request\n"); |
|
34286
8d0979967d05
HTTP: removing extra yahoo HTTP implementations - file transfer (and small improvements to libpurple http and ft code)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34272
diff
changeset
|
878 | } else { |
|
8d0979967d05
HTTP: removing extra yahoo HTTP implementations - file transfer (and small improvements to libpurple http and ft code)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34272
diff
changeset
|
879 | purple_debug_warning("http", "Got empty" |
|
8d0979967d05
HTTP: removing extra yahoo HTTP implementations - file transfer (and small improvements to libpurple http and ft code)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34272
diff
changeset
|
880 | " line at the beginning - this " |
|
8d0979967d05
HTTP: removing extra yahoo HTTP implementations - file transfer (and small improvements to libpurple http and ft code)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34272
diff
changeset
|
881 | "may be a HTTP server quirk\n"); |
|
34260
7a55eaa31da6
HTTP: implement keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34257
diff
changeset
|
882 | } |
|
7a55eaa31da6
HTTP: implement keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34257
diff
changeset
|
883 | } else /* hc->main_header_got */ { |
|
7a55eaa31da6
HTTP: implement keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34257
diff
changeset
|
884 | hc->headers_got = TRUE; |
|
7a55eaa31da6
HTTP: implement keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34257
diff
changeset
|
885 | if (purple_debug_is_verbose()) { |
|
7a55eaa31da6
HTTP: implement keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34257
diff
changeset
|
886 | purple_debug_misc("http", "Got headers " |
|
7a55eaa31da6
HTTP: implement keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34257
diff
changeset
|
887 | "end\n"); |
|
7a55eaa31da6
HTTP: implement keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34257
diff
changeset
|
888 | } |
|
33432
9c4acb75b2e6
Let's parse response headers
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33431
diff
changeset
|
889 | } |
|
9c4acb75b2e6
Let's parse response headers
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33431
diff
changeset
|
890 | } else if (!hc->main_header_got) { |
|
9c4acb75b2e6
Let's parse response headers
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33431
diff
changeset
|
891 | hc->main_header_got = TRUE; |
|
9c4acb75b2e6
Let's parse response headers
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33431
diff
changeset
|
892 | delim = strchr(hdrline, ' '); |
|
9c4acb75b2e6
Let's parse response headers
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33431
diff
changeset
|
893 | if (delim == NULL || 1 != sscanf(delim + 1, "%d", |
|
9c4acb75b2e6
Let's parse response headers
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33431
diff
changeset
|
894 | &hc->response->code)) { |
|
33433
fb7ac52ed7df
Let's get response contents
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33432
diff
changeset
|
895 | purple_debug_warning("http", |
|
fb7ac52ed7df
Let's get response contents
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33432
diff
changeset
|
896 | "Invalid response code\n"); |
|
33432
9c4acb75b2e6
Let's parse response headers
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33431
diff
changeset
|
897 | _purple_http_error(hc, _("Error parsing HTTP")); |
|
33433
fb7ac52ed7df
Let's get response contents
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33432
diff
changeset
|
898 | return FALSE; |
|
33432
9c4acb75b2e6
Let's parse response headers
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33431
diff
changeset
|
899 | } |
|
33433
fb7ac52ed7df
Let's get response contents
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33432
diff
changeset
|
900 | if (purple_debug_is_verbose()) |
|
33453
3cb58ea9667c
HTTP Proxy support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33452
diff
changeset
|
901 | purple_debug_misc("http", |
|
3cb58ea9667c
HTTP Proxy support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33452
diff
changeset
|
902 | "Got main header with code %d\n", |
|
3cb58ea9667c
HTTP Proxy support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33452
diff
changeset
|
903 | hc->response->code); |
|
33432
9c4acb75b2e6
Let's parse response headers
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33431
diff
changeset
|
904 | } else { |
|
33433
fb7ac52ed7df
Let's get response contents
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33432
diff
changeset
|
905 | if (purple_debug_is_verbose() && |
|
fb7ac52ed7df
Let's get response contents
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33432
diff
changeset
|
906 | purple_debug_is_unsafe()) |
|
fb7ac52ed7df
Let's get response contents
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33432
diff
changeset
|
907 | purple_debug_misc("http", "Got header: %s\n", |
|
fb7ac52ed7df
Let's get response contents
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33432
diff
changeset
|
908 | hdrline); |
|
33432
9c4acb75b2e6
Let's parse response headers
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33431
diff
changeset
|
909 | delim = strchr(hdrline, ':'); |
|
9c4acb75b2e6
Let's parse response headers
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33431
diff
changeset
|
910 | if (delim == NULL || delim == hdrline) { |
|
33433
fb7ac52ed7df
Let's get response contents
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33432
diff
changeset
|
911 | purple_debug_warning("http", |
|
fb7ac52ed7df
Let's get response contents
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33432
diff
changeset
|
912 | "Bad header delimiter\n"); |
|
33432
9c4acb75b2e6
Let's parse response headers
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33431
diff
changeset
|
913 | _purple_http_error(hc, _("Error parsing HTTP")); |
|
33433
fb7ac52ed7df
Let's get response contents
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33432
diff
changeset
|
914 | return FALSE; |
|
33432
9c4acb75b2e6
Let's parse response headers
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33431
diff
changeset
|
915 | } |
|
9c4acb75b2e6
Let's parse response headers
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33431
diff
changeset
|
916 | *delim++ = '\0'; |
|
9c4acb75b2e6
Let's parse response headers
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33431
diff
changeset
|
917 | while (*delim == ' ') |
|
9c4acb75b2e6
Let's parse response headers
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33431
diff
changeset
|
918 | delim++; |
|
9c4acb75b2e6
Let's parse response headers
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33431
diff
changeset
|
919 | |
|
9c4acb75b2e6
Let's parse response headers
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33431
diff
changeset
|
920 | purple_http_headers_add(hc->response->headers, hdrline, delim); |
|
9c4acb75b2e6
Let's parse response headers
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33431
diff
changeset
|
921 | } |
|
9c4acb75b2e6
Let's parse response headers
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33431
diff
changeset
|
922 | |
|
9c4acb75b2e6
Let's parse response headers
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33431
diff
changeset
|
923 | g_string_erase(hc->response_buffer, 0, hdrline_len + 2); |
|
33433
fb7ac52ed7df
Let's get response contents
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33432
diff
changeset
|
924 | if (hc->headers_got) |
|
fb7ac52ed7df
Let's get response contents
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33432
diff
changeset
|
925 | break; |
|
33432
9c4acb75b2e6
Let's parse response headers
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33431
diff
changeset
|
926 | } |
|
33433
fb7ac52ed7df
Let's get response contents
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33432
diff
changeset
|
927 | return TRUE; |
|
fb7ac52ed7df
Let's get response contents
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33432
diff
changeset
|
928 | } |
|
fb7ac52ed7df
Let's get response contents
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33432
diff
changeset
|
929 | |
|
33517
ddd9e37c4b07
HTTP: PurpleHttpContentWriter support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33469
diff
changeset
|
930 | static gboolean _purple_http_recv_body_data(PurpleHttpConnection *hc, |
|
33434
ec4f343af107
Chunked file transfers support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33433
diff
changeset
|
931 | const gchar *buf, int len) |
|
ec4f343af107
Chunked file transfers support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33433
diff
changeset
|
932 | { |
|
34266
0cb189ba00f2
HTTP: refine content length calculation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34265
diff
changeset
|
933 | int current_offset = hc->length_got; |
|
0cb189ba00f2
HTTP: refine content length calculation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34265
diff
changeset
|
934 | |
|
0cb189ba00f2
HTTP: refine content length calculation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34265
diff
changeset
|
935 | if (hc->length_expected >= 0 && |
|
0cb189ba00f2
HTTP: refine content length calculation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34265
diff
changeset
|
936 | len + hc->length_got > hc->length_expected) |
|
0cb189ba00f2
HTTP: refine content length calculation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34265
diff
changeset
|
937 | { |
|
0cb189ba00f2
HTTP: refine content length calculation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34265
diff
changeset
|
938 | len = hc->length_expected - hc->length_got; |
|
0cb189ba00f2
HTTP: refine content length calculation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34265
diff
changeset
|
939 | } |
|
33446
95fda782966c
New feature: setting maximum length of response
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33445
diff
changeset
|
940 | if (hc->request->max_length >= 0) { |
|
34266
0cb189ba00f2
HTTP: refine content length calculation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34265
diff
changeset
|
941 | if (hc->length_got + len > hc->request->max_length) { |
|
34286
8d0979967d05
HTTP: removing extra yahoo HTTP implementations - file transfer (and small improvements to libpurple http and ft code)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34272
diff
changeset
|
942 | purple_debug_warning("http", |
|
8d0979967d05
HTTP: removing extra yahoo HTTP implementations - file transfer (and small improvements to libpurple http and ft code)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34272
diff
changeset
|
943 | "Maximum length exceeded, truncating\n"); |
|
34266
0cb189ba00f2
HTTP: refine content length calculation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34265
diff
changeset
|
944 | len = hc->request->max_length - hc->length_got; |
|
0cb189ba00f2
HTTP: refine content length calculation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34265
diff
changeset
|
945 | hc->length_expected = hc->request->max_length; |
|
33446
95fda782966c
New feature: setting maximum length of response
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33445
diff
changeset
|
946 | } |
|
33517
ddd9e37c4b07
HTTP: PurpleHttpContentWriter support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33469
diff
changeset
|
947 | } |
|
34266
0cb189ba00f2
HTTP: refine content length calculation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34265
diff
changeset
|
948 | hc->length_got += len; |
|
33517
ddd9e37c4b07
HTTP: PurpleHttpContentWriter support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33469
diff
changeset
|
949 | |
|
ddd9e37c4b07
HTTP: PurpleHttpContentWriter support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33469
diff
changeset
|
950 | if (len == 0) |
|
ddd9e37c4b07
HTTP: PurpleHttpContentWriter support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33469
diff
changeset
|
951 | return TRUE; |
|
ddd9e37c4b07
HTTP: PurpleHttpContentWriter support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33469
diff
changeset
|
952 | |
|
ddd9e37c4b07
HTTP: PurpleHttpContentWriter support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33469
diff
changeset
|
953 | if (hc->request->response_writer != NULL) { |
|
ddd9e37c4b07
HTTP: PurpleHttpContentWriter support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33469
diff
changeset
|
954 | gboolean succ; |
|
ddd9e37c4b07
HTTP: PurpleHttpContentWriter support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33469
diff
changeset
|
955 | succ = hc->request->response_writer(hc, hc->response, buf, |
|
ddd9e37c4b07
HTTP: PurpleHttpContentWriter support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33469
diff
changeset
|
956 | current_offset, len, hc->request->response_writer_data); |
|
ddd9e37c4b07
HTTP: PurpleHttpContentWriter support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33469
diff
changeset
|
957 | if (!succ) { |
|
ddd9e37c4b07
HTTP: PurpleHttpContentWriter support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33469
diff
changeset
|
958 | purple_debug_error("http", |
|
ddd9e37c4b07
HTTP: PurpleHttpContentWriter support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33469
diff
changeset
|
959 | "Cannot write using callback\n"); |
|
ddd9e37c4b07
HTTP: PurpleHttpContentWriter support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33469
diff
changeset
|
960 | _purple_http_error(hc, |
|
ddd9e37c4b07
HTTP: PurpleHttpContentWriter support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33469
diff
changeset
|
961 | _("Error handling retrieved data")); |
|
ddd9e37c4b07
HTTP: PurpleHttpContentWriter support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33469
diff
changeset
|
962 | return FALSE; |
|
ddd9e37c4b07
HTTP: PurpleHttpContentWriter support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33469
diff
changeset
|
963 | } |
|
ddd9e37c4b07
HTTP: PurpleHttpContentWriter support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33469
diff
changeset
|
964 | } else { |
|
ddd9e37c4b07
HTTP: PurpleHttpContentWriter support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33469
diff
changeset
|
965 | if (hc->response->contents == NULL) |
|
ddd9e37c4b07
HTTP: PurpleHttpContentWriter support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33469
diff
changeset
|
966 | hc->response->contents = g_string_new(""); |
|
ddd9e37c4b07
HTTP: PurpleHttpContentWriter support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33469
diff
changeset
|
967 | g_string_append_len(hc->response->contents, buf, len); |
|
33446
95fda782966c
New feature: setting maximum length of response
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33445
diff
changeset
|
968 | } |
|
95fda782966c
New feature: setting maximum length of response
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33445
diff
changeset
|
969 | |
|
33468
b057fee9d11a
HTTP progress watcher support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33466
diff
changeset
|
970 | purple_http_conn_notify_progress_watcher(hc); |
|
33517
ddd9e37c4b07
HTTP: PurpleHttpContentWriter support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33469
diff
changeset
|
971 | return TRUE; |
|
33434
ec4f343af107
Chunked file transfers support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33433
diff
changeset
|
972 | } |
|
ec4f343af107
Chunked file transfers support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33433
diff
changeset
|
973 | |
|
ec4f343af107
Chunked file transfers support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33433
diff
changeset
|
974 | static gboolean _purple_http_recv_body_chunked(PurpleHttpConnection *hc, |
|
ec4f343af107
Chunked file transfers support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33433
diff
changeset
|
975 | const gchar *buf, int len) |
|
ec4f343af107
Chunked file transfers support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33433
diff
changeset
|
976 | { |
|
ec4f343af107
Chunked file transfers support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33433
diff
changeset
|
977 | gchar *eol, *line; |
|
ec4f343af107
Chunked file transfers support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33433
diff
changeset
|
978 | int line_len; |
|
ec4f343af107
Chunked file transfers support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33433
diff
changeset
|
979 | |
|
ec4f343af107
Chunked file transfers support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33433
diff
changeset
|
980 | if (hc->chunks_done) |
|
ec4f343af107
Chunked file transfers support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33433
diff
changeset
|
981 | return FALSE; |
|
ec4f343af107
Chunked file transfers support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33433
diff
changeset
|
982 | if (!hc->response_buffer) |
|
ec4f343af107
Chunked file transfers support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33433
diff
changeset
|
983 | hc->response_buffer = g_string_new(""); |
|
33436
abec627c3a47
Segfault found, temporarily fixed
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33435
diff
changeset
|
984 | |
|
33443
ab563d4c927a
Don't eat resources with malicious http server
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33439
diff
changeset
|
985 | g_string_append_len(hc->response_buffer, buf, len); |
|
ab563d4c927a
Don't eat resources with malicious http server
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33439
diff
changeset
|
986 | if (hc->response_buffer->len > PURPLE_HTTP_MAX_RECV_BUFFER_LEN) { |
|
ab563d4c927a
Don't eat resources with malicious http server
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33439
diff
changeset
|
987 | purple_debug_error("http", |
|
ab563d4c927a
Don't eat resources with malicious http server
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33439
diff
changeset
|
988 | "Buffer too big when searching for chunk\n"); |
|
ab563d4c927a
Don't eat resources with malicious http server
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33439
diff
changeset
|
989 | _purple_http_error(hc, _("Error parsing HTTP")); |
|
ab563d4c927a
Don't eat resources with malicious http server
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33439
diff
changeset
|
990 | return FALSE; |
|
ab563d4c927a
Don't eat resources with malicious http server
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33439
diff
changeset
|
991 | } |
|
ab563d4c927a
Don't eat resources with malicious http server
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33439
diff
changeset
|
992 | |
|
33434
ec4f343af107
Chunked file transfers support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33433
diff
changeset
|
993 | while (hc->response_buffer->len > 0) { |
|
ec4f343af107
Chunked file transfers support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33433
diff
changeset
|
994 | if (hc->in_chunk) { |
|
ec4f343af107
Chunked file transfers support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33433
diff
changeset
|
995 | int got_now = hc->response_buffer->len; |
|
ec4f343af107
Chunked file transfers support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33433
diff
changeset
|
996 | if (hc->chunk_got + got_now > hc->chunk_length) |
|
ec4f343af107
Chunked file transfers support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33433
diff
changeset
|
997 | got_now = hc->chunk_length - hc->chunk_got; |
|
ec4f343af107
Chunked file transfers support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33433
diff
changeset
|
998 | hc->chunk_got += got_now; |
|
ec4f343af107
Chunked file transfers support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33433
diff
changeset
|
999 | |
|
33517
ddd9e37c4b07
HTTP: PurpleHttpContentWriter support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33469
diff
changeset
|
1000 | if (!_purple_http_recv_body_data(hc, |
|
ddd9e37c4b07
HTTP: PurpleHttpContentWriter support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33469
diff
changeset
|
1001 | hc->response_buffer->str, got_now)) |
|
ddd9e37c4b07
HTTP: PurpleHttpContentWriter support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33469
diff
changeset
|
1002 | return FALSE; |
|
33459
722a6d753cb2
Better cookies, better chunked transfer support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33458
diff
changeset
|
1003 | |
|
33434
ec4f343af107
Chunked file transfers support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33433
diff
changeset
|
1004 | g_string_erase(hc->response_buffer, 0, got_now); |
|
ec4f343af107
Chunked file transfers support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33433
diff
changeset
|
1005 | hc->in_chunk = (hc->chunk_got < hc->chunk_length); |
|
ec4f343af107
Chunked file transfers support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33433
diff
changeset
|
1006 | |
|
ec4f343af107
Chunked file transfers support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33433
diff
changeset
|
1007 | if (purple_debug_is_verbose()) |
|
ec4f343af107
Chunked file transfers support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33433
diff
changeset
|
1008 | purple_debug_misc("http", "Chunk (%d/%d)\n", |
|
ec4f343af107
Chunked file transfers support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33433
diff
changeset
|
1009 | hc->chunk_got, hc->chunk_length); |
|
ec4f343af107
Chunked file transfers support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33433
diff
changeset
|
1010 | |
|
ec4f343af107
Chunked file transfers support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33433
diff
changeset
|
1011 | continue; |
|
ec4f343af107
Chunked file transfers support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33433
diff
changeset
|
1012 | } |
|
ec4f343af107
Chunked file transfers support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33433
diff
changeset
|
1013 | |
|
ec4f343af107
Chunked file transfers support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33433
diff
changeset
|
1014 | line = hc->response_buffer->str; |
|
ec4f343af107
Chunked file transfers support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33433
diff
changeset
|
1015 | eol = strstr(line, "\r\n"); |
|
33459
722a6d753cb2
Better cookies, better chunked transfer support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33458
diff
changeset
|
1016 | if (eol == line) { |
|
722a6d753cb2
Better cookies, better chunked transfer support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33458
diff
changeset
|
1017 | g_string_erase(hc->response_buffer, 0, 2); |
|
722a6d753cb2
Better cookies, better chunked transfer support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33458
diff
changeset
|
1018 | line = hc->response_buffer->str; |
|
722a6d753cb2
Better cookies, better chunked transfer support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33458
diff
changeset
|
1019 | eol = strstr(line, "\r\n"); |
|
722a6d753cb2
Better cookies, better chunked transfer support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33458
diff
changeset
|
1020 | } |
|
33434
ec4f343af107
Chunked file transfers support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33433
diff
changeset
|
1021 | if (eol == NULL) { |
|
ec4f343af107
Chunked file transfers support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33433
diff
changeset
|
1022 | /* waiting for more data (unlikely, but possible) */ |
|
ec4f343af107
Chunked file transfers support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33433
diff
changeset
|
1023 | if (hc->response_buffer->len > 20) { |
|
ec4f343af107
Chunked file transfers support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33433
diff
changeset
|
1024 | purple_debug_warning("http", "Chunk length not " |
|
ec4f343af107
Chunked file transfers support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33433
diff
changeset
|
1025 | "found (buffer too large)\n"); |
|
ec4f343af107
Chunked file transfers support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33433
diff
changeset
|
1026 | _purple_http_error(hc, _("Error parsing HTTP")); |
|
ec4f343af107
Chunked file transfers support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33433
diff
changeset
|
1027 | return FALSE; |
|
ec4f343af107
Chunked file transfers support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33433
diff
changeset
|
1028 | } |
|
ec4f343af107
Chunked file transfers support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33433
diff
changeset
|
1029 | return TRUE; |
|
ec4f343af107
Chunked file transfers support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33433
diff
changeset
|
1030 | } |
|
ec4f343af107
Chunked file transfers support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33433
diff
changeset
|
1031 | line_len = eol - line; |
|
ec4f343af107
Chunked file transfers support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33433
diff
changeset
|
1032 | |
|
ec4f343af107
Chunked file transfers support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33433
diff
changeset
|
1033 | if (1 != sscanf(line, "%x", &hc->chunk_length)) { |
|
33450
4042907bcdf1
Timeout support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33448
diff
changeset
|
1034 | if (purple_debug_is_unsafe()) |
|
4042907bcdf1
Timeout support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33448
diff
changeset
|
1035 | purple_debug_warning("http", |
|
4042907bcdf1
Timeout support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33448
diff
changeset
|
1036 | "Chunk length not found in [%s]\n", |
|
4042907bcdf1
Timeout support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33448
diff
changeset
|
1037 | line); |
|
4042907bcdf1
Timeout support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33448
diff
changeset
|
1038 | else |
|
4042907bcdf1
Timeout support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33448
diff
changeset
|
1039 | purple_debug_warning("http", |
|
4042907bcdf1
Timeout support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33448
diff
changeset
|
1040 | "Chunk length not found\n"); |
|
33434
ec4f343af107
Chunked file transfers support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33433
diff
changeset
|
1041 | _purple_http_error(hc, _("Error parsing HTTP")); |
|
ec4f343af107
Chunked file transfers support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33433
diff
changeset
|
1042 | return FALSE; |
|
ec4f343af107
Chunked file transfers support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33433
diff
changeset
|
1043 | } |
|
ec4f343af107
Chunked file transfers support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33433
diff
changeset
|
1044 | hc->chunk_got = 0; |
|
ec4f343af107
Chunked file transfers support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33433
diff
changeset
|
1045 | hc->in_chunk = TRUE; |
|
ec4f343af107
Chunked file transfers support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33433
diff
changeset
|
1046 | |
|
ec4f343af107
Chunked file transfers support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33433
diff
changeset
|
1047 | if (purple_debug_is_verbose()) |
|
ec4f343af107
Chunked file transfers support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33433
diff
changeset
|
1048 | purple_debug_misc("http", "Found chunk of length %d\n", hc->chunk_length); |
|
ec4f343af107
Chunked file transfers support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33433
diff
changeset
|
1049 | |
|
ec4f343af107
Chunked file transfers support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33433
diff
changeset
|
1050 | g_string_erase(hc->response_buffer, 0, line_len + 2); |
|
ec4f343af107
Chunked file transfers support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33433
diff
changeset
|
1051 | |
|
ec4f343af107
Chunked file transfers support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33433
diff
changeset
|
1052 | if (hc->chunk_length == 0) { |
|
ec4f343af107
Chunked file transfers support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33433
diff
changeset
|
1053 | hc->chunks_done = TRUE; |
|
ec4f343af107
Chunked file transfers support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33433
diff
changeset
|
1054 | hc->in_chunk = FALSE; |
|
ec4f343af107
Chunked file transfers support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33433
diff
changeset
|
1055 | return TRUE; |
|
ec4f343af107
Chunked file transfers support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33433
diff
changeset
|
1056 | } |
|
ec4f343af107
Chunked file transfers support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33433
diff
changeset
|
1057 | } |
|
ec4f343af107
Chunked file transfers support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33433
diff
changeset
|
1058 | |
|
ec4f343af107
Chunked file transfers support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33433
diff
changeset
|
1059 | return TRUE; |
|
ec4f343af107
Chunked file transfers support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33433
diff
changeset
|
1060 | } |
|
ec4f343af107
Chunked file transfers support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33433
diff
changeset
|
1061 | |
|
ec4f343af107
Chunked file transfers support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33433
diff
changeset
|
1062 | static gboolean _purple_http_recv_body(PurpleHttpConnection *hc, |
|
33433
fb7ac52ed7df
Let's get response contents
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33432
diff
changeset
|
1063 | const gchar *buf, int len) |
|
fb7ac52ed7df
Let's get response contents
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33432
diff
changeset
|
1064 | { |
|
33434
ec4f343af107
Chunked file transfers support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33433
diff
changeset
|
1065 | if (hc->is_chunked) |
|
ec4f343af107
Chunked file transfers support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33433
diff
changeset
|
1066 | return _purple_http_recv_body_chunked(hc, buf, len); |
|
33433
fb7ac52ed7df
Let's get response contents
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33432
diff
changeset
|
1067 | |
|
33517
ddd9e37c4b07
HTTP: PurpleHttpContentWriter support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33469
diff
changeset
|
1068 | return _purple_http_recv_body_data(hc, buf, len); |
|
33432
9c4acb75b2e6
Let's parse response headers
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33431
diff
changeset
|
1069 | } |
|
9c4acb75b2e6
Let's parse response headers
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33431
diff
changeset
|
1070 | |
|
33522
7a3d131c3086
HTTP: don't freeze download on files larger than buffer size
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33521
diff
changeset
|
1071 | static gboolean _purple_http_recv_loopbody(PurpleHttpConnection *hc, gint fd) |
|
33431
704de181d1d2
Let's request
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33430
diff
changeset
|
1072 | { |
|
704de181d1d2
Let's request
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33430
diff
changeset
|
1073 | int len; |
|
33432
9c4acb75b2e6
Let's parse response headers
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33431
diff
changeset
|
1074 | gchar buf[4096]; |
|
33522
7a3d131c3086
HTTP: don't freeze download on files larger than buffer size
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33521
diff
changeset
|
1075 | gboolean got_anything; |
|
33431
704de181d1d2
Let's request
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33430
diff
changeset
|
1076 | |
|
34257
935120490eb2
HTTP: isolate socket-related code in http module; initial implementation for keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34234
diff
changeset
|
1077 | len = purple_http_socket_read(hc->socket, buf, sizeof(buf)); |
|
33522
7a3d131c3086
HTTP: don't freeze download on files larger than buffer size
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33521
diff
changeset
|
1078 | got_anything = (len > 0); |
|
33431
704de181d1d2
Let's request
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33430
diff
changeset
|
1079 | |
|
704de181d1d2
Let's request
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33430
diff
changeset
|
1080 | if (len < 0 && errno == EAGAIN) |
|
33522
7a3d131c3086
HTTP: don't freeze download on files larger than buffer size
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33521
diff
changeset
|
1081 | return FALSE; |
|
33431
704de181d1d2
Let's request
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33430
diff
changeset
|
1082 | |
|
704de181d1d2
Let's request
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33430
diff
changeset
|
1083 | if (len < 0) { |
|
704de181d1d2
Let's request
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33430
diff
changeset
|
1084 | _purple_http_error(hc, _("Error reading from %s: %s"), |
|
704de181d1d2
Let's request
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33430
diff
changeset
|
1085 | hc->url->host, g_strerror(errno)); |
|
33522
7a3d131c3086
HTTP: don't freeze download on files larger than buffer size
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33521
diff
changeset
|
1086 | return FALSE; |
|
33431
704de181d1d2
Let's request
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33430
diff
changeset
|
1087 | } |
|
704de181d1d2
Let's request
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33430
diff
changeset
|
1088 | |
|
33439
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
1089 | /* EOF */ |
|
33435
ab0560aa8ca4
Segfault shotgun debugging
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33434
diff
changeset
|
1090 | if (len == 0) { |
|
34286
8d0979967d05
HTTP: removing extra yahoo HTTP implementations - file transfer (and small improvements to libpurple http and ft code)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34272
diff
changeset
|
1091 | if (hc->request->max_length == 0) { |
|
8d0979967d05
HTTP: removing extra yahoo HTTP implementations - file transfer (and small improvements to libpurple http and ft code)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34272
diff
changeset
|
1092 | /* It's definitely YHttpServer quirk. */ |
|
8d0979967d05
HTTP: removing extra yahoo HTTP implementations - file transfer (and small improvements to libpurple http and ft code)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34272
diff
changeset
|
1093 | purple_debug_warning("http", "Got EOF, but no data was " |
|
8d0979967d05
HTTP: removing extra yahoo HTTP implementations - file transfer (and small improvements to libpurple http and ft code)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34272
diff
changeset
|
1094 | "expected (this may be a server quirk)\n"); |
|
8d0979967d05
HTTP: removing extra yahoo HTTP implementations - file transfer (and small improvements to libpurple http and ft code)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34272
diff
changeset
|
1095 | hc->length_expected = hc->length_got; |
|
8d0979967d05
HTTP: removing extra yahoo HTTP implementations - file transfer (and small improvements to libpurple http and ft code)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34272
diff
changeset
|
1096 | } |
|
33435
ab0560aa8ca4
Segfault shotgun debugging
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33434
diff
changeset
|
1097 | if (hc->length_expected >= 0 && |
|
ab0560aa8ca4
Segfault shotgun debugging
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33434
diff
changeset
|
1098 | hc->length_got < hc->length_expected) { |
|
ab0560aa8ca4
Segfault shotgun debugging
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33434
diff
changeset
|
1099 | purple_debug_warning("http", "No more data while reading" |
|
ab0560aa8ca4
Segfault shotgun debugging
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33434
diff
changeset
|
1100 | " contents\n"); |
|
ab0560aa8ca4
Segfault shotgun debugging
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33434
diff
changeset
|
1101 | _purple_http_error(hc, _("Error parsing HTTP")); |
|
33522
7a3d131c3086
HTTP: don't freeze download on files larger than buffer size
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33521
diff
changeset
|
1102 | return FALSE; |
|
33435
ab0560aa8ca4
Segfault shotgun debugging
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33434
diff
changeset
|
1103 | } |
|
ab0560aa8ca4
Segfault shotgun debugging
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33434
diff
changeset
|
1104 | if (hc->headers_got) |
|
ab0560aa8ca4
Segfault shotgun debugging
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33434
diff
changeset
|
1105 | hc->length_expected = hc->length_got; |
|
34260
7a55eaa31da6
HTTP: implement keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34257
diff
changeset
|
1106 | else if (hc->length_got == 0 && hc->socket->use_count > 1) { |
|
7a55eaa31da6
HTTP: implement keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34257
diff
changeset
|
1107 | purple_debug_info("http", "Keep-alive connection " |
|
34265
e6de87604147
HTTP: get rid of the second msn's own HTTP implementation (for soap)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34263
diff
changeset
|
1108 | "expired (when reading), retrying...\n"); |
|
34260
7a55eaa31da6
HTTP: implement keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34257
diff
changeset
|
1109 | purple_http_conn_retry(hc); |
|
7a55eaa31da6
HTTP: implement keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34257
diff
changeset
|
1110 | return FALSE; |
|
7a55eaa31da6
HTTP: implement keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34257
diff
changeset
|
1111 | } else { |
|
34286
8d0979967d05
HTTP: removing extra yahoo HTTP implementations - file transfer (and small improvements to libpurple http and ft code)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34272
diff
changeset
|
1112 | if (g_ascii_strcasecmp(purple_http_headers_get( |
|
8d0979967d05
HTTP: removing extra yahoo HTTP implementations - file transfer (and small improvements to libpurple http and ft code)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34272
diff
changeset
|
1113 | hc->response->headers, "Server"), |
|
8d0979967d05
HTTP: removing extra yahoo HTTP implementations - file transfer (and small improvements to libpurple http and ft code)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34272
diff
changeset
|
1114 | "YHttpServer") == 0) |
|
8d0979967d05
HTTP: removing extra yahoo HTTP implementations - file transfer (and small improvements to libpurple http and ft code)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34272
diff
changeset
|
1115 | { |
|
8d0979967d05
HTTP: removing extra yahoo HTTP implementations - file transfer (and small improvements to libpurple http and ft code)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34272
diff
changeset
|
1116 | purple_debug_warning("http", "No more data " |
|
8d0979967d05
HTTP: removing extra yahoo HTTP implementations - file transfer (and small improvements to libpurple http and ft code)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34272
diff
changeset
|
1117 | "while parsing headers (YHttpServer " |
|
8d0979967d05
HTTP: removing extra yahoo HTTP implementations - file transfer (and small improvements to libpurple http and ft code)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34272
diff
changeset
|
1118 | "quirk)\n"); |
|
8d0979967d05
HTTP: removing extra yahoo HTTP implementations - file transfer (and small improvements to libpurple http and ft code)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34272
diff
changeset
|
1119 | hc->headers_got = TRUE; |
|
8d0979967d05
HTTP: removing extra yahoo HTTP implementations - file transfer (and small improvements to libpurple http and ft code)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34272
diff
changeset
|
1120 | hc->length_expected = hc->length_got = 0; |
|
8d0979967d05
HTTP: removing extra yahoo HTTP implementations - file transfer (and small improvements to libpurple http and ft code)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34272
diff
changeset
|
1121 | } else { |
|
8d0979967d05
HTTP: removing extra yahoo HTTP implementations - file transfer (and small improvements to libpurple http and ft code)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34272
diff
changeset
|
1122 | purple_debug_warning("http", "No more data " |
|
8d0979967d05
HTTP: removing extra yahoo HTTP implementations - file transfer (and small improvements to libpurple http and ft code)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34272
diff
changeset
|
1123 | "while parsing headers\n"); |
|
8d0979967d05
HTTP: removing extra yahoo HTTP implementations - file transfer (and small improvements to libpurple http and ft code)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34272
diff
changeset
|
1124 | _purple_http_error(hc, _("Error parsing HTTP")); |
|
8d0979967d05
HTTP: removing extra yahoo HTTP implementations - file transfer (and small improvements to libpurple http and ft code)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34272
diff
changeset
|
1125 | return FALSE; |
|
8d0979967d05
HTTP: removing extra yahoo HTTP implementations - file transfer (and small improvements to libpurple http and ft code)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34272
diff
changeset
|
1126 | } |
|
33435
ab0560aa8ca4
Segfault shotgun debugging
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33434
diff
changeset
|
1127 | } |
|
ab0560aa8ca4
Segfault shotgun debugging
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33434
diff
changeset
|
1128 | } |
|
33433
fb7ac52ed7df
Let's get response contents
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33432
diff
changeset
|
1129 | |
|
fb7ac52ed7df
Let's get response contents
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33432
diff
changeset
|
1130 | if (!hc->headers_got && len > 0) { |
|
fb7ac52ed7df
Let's get response contents
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33432
diff
changeset
|
1131 | if (!_purple_http_recv_headers(hc, buf, len)) |
|
33522
7a3d131c3086
HTTP: don't freeze download on files larger than buffer size
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33521
diff
changeset
|
1132 | return FALSE; |
|
33459
722a6d753cb2
Better cookies, better chunked transfer support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33458
diff
changeset
|
1133 | len = 0; |
|
33433
fb7ac52ed7df
Let's get response contents
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33432
diff
changeset
|
1134 | if (hc->headers_got) { |
|
fb7ac52ed7df
Let's get response contents
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33432
diff
changeset
|
1135 | if (!purple_http_headers_get_int(hc->response->headers, |
|
fb7ac52ed7df
Let's get response contents
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33432
diff
changeset
|
1136 | "Content-Length", &hc->length_expected)) |
|
fb7ac52ed7df
Let's get response contents
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33432
diff
changeset
|
1137 | hc->length_expected = -1; |
|
33434
ec4f343af107
Chunked file transfers support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33433
diff
changeset
|
1138 | hc->is_chunked = (purple_http_headers_match( |
|
ec4f343af107
Chunked file transfers support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33433
diff
changeset
|
1139 | hc->response->headers, |
|
ec4f343af107
Chunked file transfers support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33433
diff
changeset
|
1140 | "Transfer-Encoding", "chunked")); |
|
ec4f343af107
Chunked file transfers support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33433
diff
changeset
|
1141 | } |
|
ec4f343af107
Chunked file transfers support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33433
diff
changeset
|
1142 | if (hc->headers_got && hc->response_buffer && |
|
ec4f343af107
Chunked file transfers support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33433
diff
changeset
|
1143 | hc->response_buffer->len > 0) { |
|
ec4f343af107
Chunked file transfers support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33433
diff
changeset
|
1144 | int buffer_len = hc->response_buffer->len; |
|
ec4f343af107
Chunked file transfers support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33433
diff
changeset
|
1145 | gchar *buffer = g_string_free(hc->response_buffer, FALSE); |
|
ec4f343af107
Chunked file transfers support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33433
diff
changeset
|
1146 | hc->response_buffer = NULL; |
|
ec4f343af107
Chunked file transfers support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33433
diff
changeset
|
1147 | _purple_http_recv_body(hc, buffer, buffer_len); |
|
33433
fb7ac52ed7df
Let's get response contents
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33432
diff
changeset
|
1148 | } |
|
33455
2de654702970
Print-like setting headers, vestigal keepalive support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33454
diff
changeset
|
1149 | if (!hc->headers_got) |
|
33522
7a3d131c3086
HTTP: don't freeze download on files larger than buffer size
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33521
diff
changeset
|
1150 | return got_anything; |
|
33433
fb7ac52ed7df
Let's get response contents
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33432
diff
changeset
|
1151 | } |
|
fb7ac52ed7df
Let's get response contents
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33432
diff
changeset
|
1152 | |
|
33434
ec4f343af107
Chunked file transfers support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33433
diff
changeset
|
1153 | if (len > 0) { |
|
ec4f343af107
Chunked file transfers support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33433
diff
changeset
|
1154 | if (!_purple_http_recv_body(hc, buf, len)) |
|
33522
7a3d131c3086
HTTP: don't freeze download on files larger than buffer size
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33521
diff
changeset
|
1155 | return FALSE; |
|
33434
ec4f343af107
Chunked file transfers support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33433
diff
changeset
|
1156 | } |
|
33433
fb7ac52ed7df
Let's get response contents
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33432
diff
changeset
|
1157 | |
|
34266
0cb189ba00f2
HTTP: refine content length calculation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34265
diff
changeset
|
1158 | if (hc->is_chunked && hc->chunks_done && hc->length_expected < 0) |
|
33434
ec4f343af107
Chunked file transfers support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33433
diff
changeset
|
1159 | hc->length_expected = hc->length_got; |
|
ec4f343af107
Chunked file transfers support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33433
diff
changeset
|
1160 | |
|
ec4f343af107
Chunked file transfers support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33433
diff
changeset
|
1161 | if (hc->length_expected >= 0 && hc->length_got >= hc->length_expected) { |
|
33439
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
1162 | const gchar *redirect; |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
1163 | |
|
34266
0cb189ba00f2
HTTP: refine content length calculation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34265
diff
changeset
|
1164 | if (hc->is_chunked && !hc->chunks_done) { |
|
0cb189ba00f2
HTTP: refine content length calculation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34265
diff
changeset
|
1165 | if (purple_debug_is_verbose()) { |
|
0cb189ba00f2
HTTP: refine content length calculation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34265
diff
changeset
|
1166 | purple_debug_misc("http", |
|
0cb189ba00f2
HTTP: refine content length calculation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34265
diff
changeset
|
1167 | "I need the terminating empty chunk\n"); |
|
0cb189ba00f2
HTTP: refine content length calculation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34265
diff
changeset
|
1168 | } |
|
0cb189ba00f2
HTTP: refine content length calculation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34265
diff
changeset
|
1169 | return TRUE; |
|
0cb189ba00f2
HTTP: refine content length calculation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34265
diff
changeset
|
1170 | } |
|
0cb189ba00f2
HTTP: refine content length calculation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34265
diff
changeset
|
1171 | |
|
33432
9c4acb75b2e6
Let's parse response headers
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33431
diff
changeset
|
1172 | if (!hc->headers_got) { |
|
9c4acb75b2e6
Let's parse response headers
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33431
diff
changeset
|
1173 | hc->response->code = 0; |
|
33433
fb7ac52ed7df
Let's get response contents
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33432
diff
changeset
|
1174 | purple_debug_warning("http", "No headers got\n"); |
|
33432
9c4acb75b2e6
Let's parse response headers
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33431
diff
changeset
|
1175 | _purple_http_error(hc, _("Error parsing HTTP")); |
|
33522
7a3d131c3086
HTTP: don't freeze download on files larger than buffer size
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33521
diff
changeset
|
1176 | return FALSE; |
|
33432
9c4acb75b2e6
Let's parse response headers
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33431
diff
changeset
|
1177 | } |
|
9c4acb75b2e6
Let's parse response headers
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33431
diff
changeset
|
1178 | |
|
9c4acb75b2e6
Let's parse response headers
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33431
diff
changeset
|
1179 | if (purple_debug_is_unsafe() && purple_debug_is_verbose()) { |
|
9c4acb75b2e6
Let's parse response headers
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33431
diff
changeset
|
1180 | gchar *hdrs = purple_http_headers_dump( |
|
9c4acb75b2e6
Let's parse response headers
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33431
diff
changeset
|
1181 | hc->response->headers); |
|
9c4acb75b2e6
Let's parse response headers
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33431
diff
changeset
|
1182 | purple_debug_misc("http", "Got response headers: %s\n", |
|
9c4acb75b2e6
Let's parse response headers
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33431
diff
changeset
|
1183 | hdrs); |
|
9c4acb75b2e6
Let's parse response headers
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33431
diff
changeset
|
1184 | g_free(hdrs); |
|
9c4acb75b2e6
Let's parse response headers
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33431
diff
changeset
|
1185 | } |
|
9c4acb75b2e6
Let's parse response headers
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33431
diff
changeset
|
1186 | |
|
33456
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
1187 | purple_http_cookie_jar_parse(hc->request->cookie_jar, |
|
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
1188 | purple_http_headers_get_all_by_name( |
|
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
1189 | hc->response->headers, "Set-Cookie")); |
|
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
1190 | |
|
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
1191 | if (purple_debug_is_unsafe() && purple_debug_is_verbose() && |
|
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
1192 | !purple_http_cookie_jar_is_empty( |
|
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
1193 | hc->request->cookie_jar)) { |
|
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
1194 | gchar *cookies = purple_http_cookie_jar_dump( |
|
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
1195 | hc->request->cookie_jar); |
|
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
1196 | purple_debug_misc("http", "Cookies: %s\n", cookies); |
|
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
1197 | g_free(cookies); |
|
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
1198 | } |
|
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
1199 | |
|
33453
3cb58ea9667c
HTTP Proxy support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33452
diff
changeset
|
1200 | if (hc->response->code == 407) { |
|
3cb58ea9667c
HTTP Proxy support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33452
diff
changeset
|
1201 | _purple_http_error(hc, _("Invalid proxy credentials")); |
|
33522
7a3d131c3086
HTTP: don't freeze download on files larger than buffer size
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33521
diff
changeset
|
1202 | return FALSE; |
|
33453
3cb58ea9667c
HTTP Proxy support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33452
diff
changeset
|
1203 | } |
|
3cb58ea9667c
HTTP Proxy support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33452
diff
changeset
|
1204 | |
|
33439
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
1205 | redirect = purple_http_headers_get(hc->response->headers, |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
1206 | "location"); |
|
33445
1bcbdca07787
Allow infinite amount of redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33444
diff
changeset
|
1207 | if (redirect && (hc->request->max_redirects == -1 || |
|
1bcbdca07787
Allow infinite amount of redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33444
diff
changeset
|
1208 | hc->request->max_redirects > hc->redirects_count)) { |
|
33439
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
1209 | PurpleHttpURL *url = purple_http_url_parse(redirect); |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
1210 | |
|
33444
b3afec292014
New features: http version switching and limits for redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33443
diff
changeset
|
1211 | hc->redirects_count++; |
|
b3afec292014
New features: http version switching and limits for redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33443
diff
changeset
|
1212 | |
|
33439
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
1213 | if (!url) { |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
1214 | if (purple_debug_is_unsafe()) |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
1215 | purple_debug_warning("http", |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
1216 | "Invalid redirect to %s\n", |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
1217 | redirect); |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
1218 | else |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
1219 | purple_debug_warning("http", |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
1220 | "Invalid redirect\n"); |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
1221 | _purple_http_error(hc, _("Error parsing HTTP")); |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
1222 | } |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
1223 | |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
1224 | purple_http_url_relative(hc->url, url); |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
1225 | purple_http_url_free(url); |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
1226 | |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
1227 | _purple_http_reconnect(hc); |
|
33522
7a3d131c3086
HTTP: don't freeze download on files larger than buffer size
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33521
diff
changeset
|
1228 | return FALSE; |
|
33439
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
1229 | } |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
1230 | |
|
34260
7a55eaa31da6
HTTP: implement keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34257
diff
changeset
|
1231 | _purple_http_disconnect(hc, TRUE); |
|
33432
9c4acb75b2e6
Let's parse response headers
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33431
diff
changeset
|
1232 | purple_http_connection_terminate(hc); |
|
33522
7a3d131c3086
HTTP: don't freeze download on files larger than buffer size
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33521
diff
changeset
|
1233 | return FALSE; |
|
33432
9c4acb75b2e6
Let's parse response headers
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33431
diff
changeset
|
1234 | } |
|
33522
7a3d131c3086
HTTP: don't freeze download on files larger than buffer size
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33521
diff
changeset
|
1235 | |
|
7a3d131c3086
HTTP: don't freeze download on files larger than buffer size
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33521
diff
changeset
|
1236 | return got_anything; |
|
7a3d131c3086
HTTP: don't freeze download on files larger than buffer size
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33521
diff
changeset
|
1237 | } |
|
7a3d131c3086
HTTP: don't freeze download on files larger than buffer size
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33521
diff
changeset
|
1238 | |
|
7a3d131c3086
HTTP: don't freeze download on files larger than buffer size
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33521
diff
changeset
|
1239 | static void _purple_http_recv(gpointer _hc, gint fd, PurpleInputCondition cond) |
|
7a3d131c3086
HTTP: don't freeze download on files larger than buffer size
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33521
diff
changeset
|
1240 | { |
|
7a3d131c3086
HTTP: don't freeze download on files larger than buffer size
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33521
diff
changeset
|
1241 | PurpleHttpConnection *hc = _hc; |
|
7a3d131c3086
HTTP: don't freeze download on files larger than buffer size
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33521
diff
changeset
|
1242 | |
|
7a3d131c3086
HTTP: don't freeze download on files larger than buffer size
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33521
diff
changeset
|
1243 | while (_purple_http_recv_loopbody(hc, fd)); |
|
33431
704de181d1d2
Let's request
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33430
diff
changeset
|
1244 | } |
|
704de181d1d2
Let's request
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33430
diff
changeset
|
1245 | |
|
33466
918507303f45
HTTP API: PurpleHttpContentReader support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33464
diff
changeset
|
1246 | static void _purple_http_send_got_data(PurpleHttpConnection *hc, |
|
918507303f45
HTTP API: PurpleHttpContentReader support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33464
diff
changeset
|
1247 | gboolean success, gboolean eof, size_t stored) |
|
918507303f45
HTTP API: PurpleHttpContentReader support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33464
diff
changeset
|
1248 | { |
|
918507303f45
HTTP API: PurpleHttpContentReader support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33464
diff
changeset
|
1249 | int estimated_length; |
|
918507303f45
HTTP API: PurpleHttpContentReader support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33464
diff
changeset
|
1250 | |
|
918507303f45
HTTP API: PurpleHttpContentReader support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33464
diff
changeset
|
1251 | g_return_if_fail(hc != NULL); |
|
918507303f45
HTTP API: PurpleHttpContentReader support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33464
diff
changeset
|
1252 | |
|
918507303f45
HTTP API: PurpleHttpContentReader support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33464
diff
changeset
|
1253 | if (!success) { |
|
918507303f45
HTTP API: PurpleHttpContentReader support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33464
diff
changeset
|
1254 | _purple_http_error(hc, _("Error requesting data to write")); |
|
918507303f45
HTTP API: PurpleHttpContentReader support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33464
diff
changeset
|
1255 | return; |
|
918507303f45
HTTP API: PurpleHttpContentReader support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33464
diff
changeset
|
1256 | } |
|
918507303f45
HTTP API: PurpleHttpContentReader support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33464
diff
changeset
|
1257 | |
|
918507303f45
HTTP API: PurpleHttpContentReader support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33464
diff
changeset
|
1258 | hc->contents_reader_requested = FALSE; |
|
918507303f45
HTTP API: PurpleHttpContentReader support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33464
diff
changeset
|
1259 | g_string_set_size(hc->contents_reader_buffer, stored); |
|
918507303f45
HTTP API: PurpleHttpContentReader support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33464
diff
changeset
|
1260 | if (!eof) |
|
918507303f45
HTTP API: PurpleHttpContentReader support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33464
diff
changeset
|
1261 | return; |
|
918507303f45
HTTP API: PurpleHttpContentReader support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33464
diff
changeset
|
1262 | |
|
918507303f45
HTTP API: PurpleHttpContentReader support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33464
diff
changeset
|
1263 | estimated_length = hc->request_contents_written + stored; |
|
918507303f45
HTTP API: PurpleHttpContentReader support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33464
diff
changeset
|
1264 | |
|
918507303f45
HTTP API: PurpleHttpContentReader support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33464
diff
changeset
|
1265 | if (hc->request->contents_length != -1 && |
|
918507303f45
HTTP API: PurpleHttpContentReader support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33464
diff
changeset
|
1266 | hc->request->contents_length != estimated_length) { |
|
918507303f45
HTTP API: PurpleHttpContentReader support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33464
diff
changeset
|
1267 | purple_debug_warning("http", |
|
918507303f45
HTTP API: PurpleHttpContentReader support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33464
diff
changeset
|
1268 | "Invalid amount of data has been written\n"); |
|
918507303f45
HTTP API: PurpleHttpContentReader support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33464
diff
changeset
|
1269 | } |
|
918507303f45
HTTP API: PurpleHttpContentReader support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33464
diff
changeset
|
1270 | hc->request->contents_length = estimated_length; |
|
918507303f45
HTTP API: PurpleHttpContentReader support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33464
diff
changeset
|
1271 | } |
|
918507303f45
HTTP API: PurpleHttpContentReader support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33464
diff
changeset
|
1272 | |
|
33430
013c5aebb665
Let's connect
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33429
diff
changeset
|
1273 | static void _purple_http_send(gpointer _hc, gint fd, PurpleInputCondition cond) |
|
33431
704de181d1d2
Let's request
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33430
diff
changeset
|
1274 | { |
|
33430
013c5aebb665
Let's connect
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33429
diff
changeset
|
1275 | PurpleHttpConnection *hc = _hc; |
|
33431
704de181d1d2
Let's request
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33430
diff
changeset
|
1276 | int written, write_len; |
|
704de181d1d2
Let's request
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33430
diff
changeset
|
1277 | const gchar *write_from; |
|
33457
81f92a310aff
Writing request contents
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33456
diff
changeset
|
1278 | gboolean writing_headers; |
|
33431
704de181d1d2
Let's request
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33430
diff
changeset
|
1279 | |
|
33466
918507303f45
HTTP API: PurpleHttpContentReader support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33464
diff
changeset
|
1280 | /* Waiting for data. This could be written more efficiently, by removing |
|
918507303f45
HTTP API: PurpleHttpContentReader support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33464
diff
changeset
|
1281 | * (and later, adding) hs->inpa. */ |
|
918507303f45
HTTP API: PurpleHttpContentReader support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33464
diff
changeset
|
1282 | if (hc->contents_reader_requested) |
|
918507303f45
HTTP API: PurpleHttpContentReader support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33464
diff
changeset
|
1283 | return; |
|
918507303f45
HTTP API: PurpleHttpContentReader support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33464
diff
changeset
|
1284 | |
|
33431
704de181d1d2
Let's request
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33430
diff
changeset
|
1285 | _purple_http_gen_headers(hc); |
|
33430
013c5aebb665
Let's connect
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33429
diff
changeset
|
1286 | |
|
33457
81f92a310aff
Writing request contents
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33456
diff
changeset
|
1287 | writing_headers = |
|
81f92a310aff
Writing request contents
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33456
diff
changeset
|
1288 | (hc->request_header_written < hc->request_header->len); |
|
81f92a310aff
Writing request contents
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33456
diff
changeset
|
1289 | if (writing_headers) { |
|
81f92a310aff
Writing request contents
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33456
diff
changeset
|
1290 | write_from = hc->request_header->str + |
|
81f92a310aff
Writing request contents
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33456
diff
changeset
|
1291 | hc->request_header_written; |
|
81f92a310aff
Writing request contents
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33456
diff
changeset
|
1292 | write_len = hc->request_header->len - |
|
81f92a310aff
Writing request contents
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33456
diff
changeset
|
1293 | hc->request_header_written; |
|
33466
918507303f45
HTTP API: PurpleHttpContentReader support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33464
diff
changeset
|
1294 | } else if (hc->request->contents_reader) { |
|
918507303f45
HTTP API: PurpleHttpContentReader support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33464
diff
changeset
|
1295 | if (hc->contents_reader_requested) |
|
918507303f45
HTTP API: PurpleHttpContentReader support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33464
diff
changeset
|
1296 | return; /* waiting for data */ |
|
918507303f45
HTTP API: PurpleHttpContentReader support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33464
diff
changeset
|
1297 | if (!hc->contents_reader_buffer) |
|
918507303f45
HTTP API: PurpleHttpContentReader support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33464
diff
changeset
|
1298 | hc->contents_reader_buffer = g_string_new(""); |
|
918507303f45
HTTP API: PurpleHttpContentReader support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33464
diff
changeset
|
1299 | if (hc->contents_reader_buffer->len == 0) { |
|
918507303f45
HTTP API: PurpleHttpContentReader support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33464
diff
changeset
|
1300 | hc->contents_reader_requested = TRUE; |
|
918507303f45
HTTP API: PurpleHttpContentReader support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33464
diff
changeset
|
1301 | g_string_set_size(hc->contents_reader_buffer, |
|
918507303f45
HTTP API: PurpleHttpContentReader support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33464
diff
changeset
|
1302 | PURPLE_HTTP_MAX_READ_BUFFER_LEN); |
|
918507303f45
HTTP API: PurpleHttpContentReader support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33464
diff
changeset
|
1303 | hc->request->contents_reader(hc, |
|
918507303f45
HTTP API: PurpleHttpContentReader support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33464
diff
changeset
|
1304 | hc->contents_reader_buffer->str, |
|
918507303f45
HTTP API: PurpleHttpContentReader support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33464
diff
changeset
|
1305 | hc->request_contents_written, |
|
918507303f45
HTTP API: PurpleHttpContentReader support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33464
diff
changeset
|
1306 | PURPLE_HTTP_MAX_READ_BUFFER_LEN, |
|
918507303f45
HTTP API: PurpleHttpContentReader support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33464
diff
changeset
|
1307 | hc->request->contents_reader_data, |
|
918507303f45
HTTP API: PurpleHttpContentReader support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33464
diff
changeset
|
1308 | _purple_http_send_got_data); |
|
918507303f45
HTTP API: PurpleHttpContentReader support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33464
diff
changeset
|
1309 | return; |
|
918507303f45
HTTP API: PurpleHttpContentReader support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33464
diff
changeset
|
1310 | } |
|
918507303f45
HTTP API: PurpleHttpContentReader support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33464
diff
changeset
|
1311 | write_from = hc->contents_reader_buffer->str; |
|
918507303f45
HTTP API: PurpleHttpContentReader support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33464
diff
changeset
|
1312 | write_len = hc->contents_reader_buffer->len; |
|
33457
81f92a310aff
Writing request contents
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33456
diff
changeset
|
1313 | } else { |
|
81f92a310aff
Writing request contents
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33456
diff
changeset
|
1314 | write_from = hc->request->contents + |
|
81f92a310aff
Writing request contents
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33456
diff
changeset
|
1315 | hc->request_contents_written; |
|
81f92a310aff
Writing request contents
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33456
diff
changeset
|
1316 | write_len = hc->request->contents_length - |
|
81f92a310aff
Writing request contents
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33456
diff
changeset
|
1317 | hc->request_contents_written; |
|
81f92a310aff
Writing request contents
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33456
diff
changeset
|
1318 | } |
|
33431
704de181d1d2
Let's request
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33430
diff
changeset
|
1319 | |
|
33457
81f92a310aff
Writing request contents
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33456
diff
changeset
|
1320 | if (write_len == 0) { |
|
81f92a310aff
Writing request contents
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33456
diff
changeset
|
1321 | purple_debug_warning("http", "Nothing to write\n"); |
|
81f92a310aff
Writing request contents
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33456
diff
changeset
|
1322 | written = 0; |
|
34257
935120490eb2
HTTP: isolate socket-related code in http module; initial implementation for keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34234
diff
changeset
|
1323 | } else { |
|
935120490eb2
HTTP: isolate socket-related code in http module; initial implementation for keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34234
diff
changeset
|
1324 | written = purple_http_socket_write(hc->socket, write_from, |
|
935120490eb2
HTTP: isolate socket-related code in http module; initial implementation for keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34234
diff
changeset
|
1325 | write_len); |
|
935120490eb2
HTTP: isolate socket-related code in http module; initial implementation for keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34234
diff
changeset
|
1326 | } |
|
33431
704de181d1d2
Let's request
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33430
diff
changeset
|
1327 | |
|
704de181d1d2
Let's request
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33430
diff
changeset
|
1328 | if (written < 0 && errno == EAGAIN) |
|
704de181d1d2
Let's request
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33430
diff
changeset
|
1329 | return; |
|
704de181d1d2
Let's request
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33430
diff
changeset
|
1330 | |
|
704de181d1d2
Let's request
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33430
diff
changeset
|
1331 | if (written < 0) { |
|
34265
e6de87604147
HTTP: get rid of the second msn's own HTTP implementation (for soap)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34263
diff
changeset
|
1332 | if (hc->request_header_written == 0 && |
|
e6de87604147
HTTP: get rid of the second msn's own HTTP implementation (for soap)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34263
diff
changeset
|
1333 | hc->socket->use_count > 1) |
|
e6de87604147
HTTP: get rid of the second msn's own HTTP implementation (for soap)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34263
diff
changeset
|
1334 | { |
|
e6de87604147
HTTP: get rid of the second msn's own HTTP implementation (for soap)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34263
diff
changeset
|
1335 | purple_debug_info("http", "Keep-alive connection " |
|
e6de87604147
HTTP: get rid of the second msn's own HTTP implementation (for soap)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34263
diff
changeset
|
1336 | "expired (when writing), retrying...\n"); |
|
e6de87604147
HTTP: get rid of the second msn's own HTTP implementation (for soap)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34263
diff
changeset
|
1337 | purple_http_conn_retry(hc); |
|
e6de87604147
HTTP: get rid of the second msn's own HTTP implementation (for soap)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34263
diff
changeset
|
1338 | return; |
|
e6de87604147
HTTP: get rid of the second msn's own HTTP implementation (for soap)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34263
diff
changeset
|
1339 | } |
|
e6de87604147
HTTP: get rid of the second msn's own HTTP implementation (for soap)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34263
diff
changeset
|
1340 | |
|
33431
704de181d1d2
Let's request
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33430
diff
changeset
|
1341 | _purple_http_error(hc, _("Error writing to %s: %s"), |
|
704de181d1d2
Let's request
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33430
diff
changeset
|
1342 | hc->url->host, g_strerror(errno)); |
|
704de181d1d2
Let's request
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33430
diff
changeset
|
1343 | return; |
|
704de181d1d2
Let's request
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33430
diff
changeset
|
1344 | } |
|
704de181d1d2
Let's request
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33430
diff
changeset
|
1345 | |
|
33457
81f92a310aff
Writing request contents
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33456
diff
changeset
|
1346 | if (writing_headers) { |
|
81f92a310aff
Writing request contents
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33456
diff
changeset
|
1347 | hc->request_header_written += written; |
|
33468
b057fee9d11a
HTTP progress watcher support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33466
diff
changeset
|
1348 | purple_http_conn_notify_progress_watcher(hc); |
|
33457
81f92a310aff
Writing request contents
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33456
diff
changeset
|
1349 | if (hc->request_header_written < hc->request_header->len) |
|
81f92a310aff
Writing request contents
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33456
diff
changeset
|
1350 | return; |
|
81f92a310aff
Writing request contents
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33456
diff
changeset
|
1351 | if (hc->request->contents_length > 0) |
|
81f92a310aff
Writing request contents
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33456
diff
changeset
|
1352 | return; |
|
81f92a310aff
Writing request contents
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33456
diff
changeset
|
1353 | } else { |
|
81f92a310aff
Writing request contents
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33456
diff
changeset
|
1354 | hc->request_contents_written += written; |
|
33468
b057fee9d11a
HTTP progress watcher support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33466
diff
changeset
|
1355 | purple_http_conn_notify_progress_watcher(hc); |
|
33466
918507303f45
HTTP API: PurpleHttpContentReader support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33464
diff
changeset
|
1356 | if (hc->contents_reader_buffer) |
|
918507303f45
HTTP API: PurpleHttpContentReader support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33464
diff
changeset
|
1357 | g_string_erase(hc->contents_reader_buffer, 0, written); |
|
33457
81f92a310aff
Writing request contents
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33456
diff
changeset
|
1358 | if (hc->request_contents_written < hc->request->contents_length) |
|
81f92a310aff
Writing request contents
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33456
diff
changeset
|
1359 | return; |
|
81f92a310aff
Writing request contents
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33456
diff
changeset
|
1360 | } |
|
33431
704de181d1d2
Let's request
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33430
diff
changeset
|
1361 | |
|
704de181d1d2
Let's request
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33430
diff
changeset
|
1362 | /* request is completely written, let's read the response */ |
|
33468
b057fee9d11a
HTTP progress watcher support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33466
diff
changeset
|
1363 | hc->is_reading = TRUE; |
|
34257
935120490eb2
HTTP: isolate socket-related code in http module; initial implementation for keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34234
diff
changeset
|
1364 | purple_http_socket_watch(hc->socket, PURPLE_INPUT_READ, |
|
935120490eb2
HTTP: isolate socket-related code in http module; initial implementation for keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34234
diff
changeset
|
1365 | _purple_http_recv, hc); |
|
33430
013c5aebb665
Let's connect
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33429
diff
changeset
|
1366 | } |
|
013c5aebb665
Let's connect
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33429
diff
changeset
|
1367 | |
|
34260
7a55eaa31da6
HTTP: implement keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34257
diff
changeset
|
1368 | static void _purple_http_disconnect(PurpleHttpConnection *hc, |
|
7a55eaa31da6
HTTP: implement keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34257
diff
changeset
|
1369 | gboolean is_graceful) |
|
33430
013c5aebb665
Let's connect
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33429
diff
changeset
|
1370 | { |
|
013c5aebb665
Let's connect
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33429
diff
changeset
|
1371 | g_return_if_fail(hc != NULL); |
|
013c5aebb665
Let's connect
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33429
diff
changeset
|
1372 | |
|
33431
704de181d1d2
Let's request
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33430
diff
changeset
|
1373 | if (hc->request_header) |
|
704de181d1d2
Let's request
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33430
diff
changeset
|
1374 | g_string_free(hc->request_header, TRUE); |
|
704de181d1d2
Let's request
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33430
diff
changeset
|
1375 | hc->request_header = NULL; |
|
34260
7a55eaa31da6
HTTP: implement keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34257
diff
changeset
|
1376 | |
|
33432
9c4acb75b2e6
Let's parse response headers
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33431
diff
changeset
|
1377 | if (hc->response_buffer) |
|
9c4acb75b2e6
Let's parse response headers
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33431
diff
changeset
|
1378 | g_string_free(hc->response_buffer, TRUE); |
|
9c4acb75b2e6
Let's parse response headers
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33431
diff
changeset
|
1379 | hc->response_buffer = NULL; |
|
33430
013c5aebb665
Let's connect
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33429
diff
changeset
|
1380 | |
|
34263
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
1381 | if (hc->socket_request) |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
1382 | purple_http_keepalive_pool_request_cancel(hc->socket_request); |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
1383 | else { |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
1384 | purple_http_keepalive_pool_release(hc->socket, !is_graceful); |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
1385 | hc->socket = NULL; |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
1386 | } |
|
34257
935120490eb2
HTTP: isolate socket-related code in http module; initial implementation for keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34234
diff
changeset
|
1387 | } |
|
935120490eb2
HTTP: isolate socket-related code in http module; initial implementation for keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34234
diff
changeset
|
1388 | |
|
935120490eb2
HTTP: isolate socket-related code in http module; initial implementation for keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34234
diff
changeset
|
1389 | static void _purple_http_connected(PurpleHttpSocket *hs, const gchar *error, gpointer _hc) |
|
935120490eb2
HTTP: isolate socket-related code in http module; initial implementation for keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34234
diff
changeset
|
1390 | { |
|
935120490eb2
HTTP: isolate socket-related code in http module; initial implementation for keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34234
diff
changeset
|
1391 | PurpleHttpConnection *hc = _hc; |
|
935120490eb2
HTTP: isolate socket-related code in http module; initial implementation for keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34234
diff
changeset
|
1392 | |
|
34263
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
1393 | hc->socket_request = NULL; |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
1394 | hc->socket = hs; |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
1395 | |
|
34257
935120490eb2
HTTP: isolate socket-related code in http module; initial implementation for keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34234
diff
changeset
|
1396 | if (error != NULL) { |
|
935120490eb2
HTTP: isolate socket-related code in http module; initial implementation for keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34234
diff
changeset
|
1397 | _purple_http_error(hc, _("Unable to connect to %s: %s"), |
|
935120490eb2
HTTP: isolate socket-related code in http module; initial implementation for keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34234
diff
changeset
|
1398 | hc->url->host, error); |
|
935120490eb2
HTTP: isolate socket-related code in http module; initial implementation for keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34234
diff
changeset
|
1399 | return; |
|
33430
013c5aebb665
Let's connect
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33429
diff
changeset
|
1400 | } |
|
34263
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
1401 | |
|
34257
935120490eb2
HTTP: isolate socket-related code in http module; initial implementation for keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34234
diff
changeset
|
1402 | purple_http_socket_watch(hs, PURPLE_INPUT_WRITE, _purple_http_send, hc); |
|
33430
013c5aebb665
Let's connect
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33429
diff
changeset
|
1403 | } |
|
013c5aebb665
Let's connect
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33429
diff
changeset
|
1404 | |
|
013c5aebb665
Let's connect
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33429
diff
changeset
|
1405 | static gboolean _purple_http_reconnect(PurpleHttpConnection *hc) |
|
013c5aebb665
Let's connect
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33429
diff
changeset
|
1406 | { |
|
013c5aebb665
Let's connect
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33429
diff
changeset
|
1407 | PurpleHttpURL *url; |
|
013c5aebb665
Let's connect
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33429
diff
changeset
|
1408 | gboolean is_ssl = FALSE; |
|
013c5aebb665
Let's connect
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33429
diff
changeset
|
1409 | |
|
013c5aebb665
Let's connect
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33429
diff
changeset
|
1410 | g_return_val_if_fail(hc != NULL, FALSE); |
|
013c5aebb665
Let's connect
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33429
diff
changeset
|
1411 | g_return_val_if_fail(hc->url != NULL, FALSE); |
|
013c5aebb665
Let's connect
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33429
diff
changeset
|
1412 | |
|
34260
7a55eaa31da6
HTTP: implement keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34257
diff
changeset
|
1413 | _purple_http_disconnect(hc, TRUE); |
|
33430
013c5aebb665
Let's connect
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33429
diff
changeset
|
1414 | |
|
33438
66c4b90ff08a
More debug prints
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33437
diff
changeset
|
1415 | if (purple_debug_is_verbose()) { |
|
66c4b90ff08a
More debug prints
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33437
diff
changeset
|
1416 | if (purple_debug_is_unsafe()) { |
|
66c4b90ff08a
More debug prints
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33437
diff
changeset
|
1417 | gchar *url = purple_http_url_print(hc->url); |
|
66c4b90ff08a
More debug prints
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33437
diff
changeset
|
1418 | purple_debug_misc("http", "Connecting to %s...\n", url); |
|
66c4b90ff08a
More debug prints
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33437
diff
changeset
|
1419 | g_free(url); |
|
66c4b90ff08a
More debug prints
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33437
diff
changeset
|
1420 | } else |
|
66c4b90ff08a
More debug prints
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33437
diff
changeset
|
1421 | purple_debug_misc("http", "Connecting to %s...\n", |
|
66c4b90ff08a
More debug prints
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33437
diff
changeset
|
1422 | hc->url->host); |
|
66c4b90ff08a
More debug prints
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33437
diff
changeset
|
1423 | } |
|
66c4b90ff08a
More debug prints
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33437
diff
changeset
|
1424 | |
|
33430
013c5aebb665
Let's connect
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33429
diff
changeset
|
1425 | url = hc->url; |
|
013c5aebb665
Let's connect
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33429
diff
changeset
|
1426 | if (url->protocol[0] == '\0' || |
|
013c5aebb665
Let's connect
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33429
diff
changeset
|
1427 | g_ascii_strcasecmp(url->protocol, "http") == 0) { |
|
013c5aebb665
Let's connect
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33429
diff
changeset
|
1428 | /* do nothing */ |
|
013c5aebb665
Let's connect
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33429
diff
changeset
|
1429 | } else if (g_ascii_strcasecmp(url->protocol, "https") == 0) { |
|
013c5aebb665
Let's connect
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33429
diff
changeset
|
1430 | is_ssl = TRUE; |
|
013c5aebb665
Let's connect
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33429
diff
changeset
|
1431 | } else { |
|
013c5aebb665
Let's connect
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33429
diff
changeset
|
1432 | _purple_http_error(hc, _("Unsupported protocol: %s"), |
|
013c5aebb665
Let's connect
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33429
diff
changeset
|
1433 | url->protocol); |
|
013c5aebb665
Let's connect
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33429
diff
changeset
|
1434 | return FALSE; |
|
013c5aebb665
Let's connect
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33429
diff
changeset
|
1435 | } |
|
013c5aebb665
Let's connect
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33429
diff
changeset
|
1436 | |
|
34257
935120490eb2
HTTP: isolate socket-related code in http module; initial implementation for keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34234
diff
changeset
|
1437 | if (is_ssl && !purple_ssl_is_supported()) { |
|
935120490eb2
HTTP: isolate socket-related code in http module; initial implementation for keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34234
diff
changeset
|
1438 | _purple_http_error(hc, _("Unable to connect to %s: %s"), |
|
935120490eb2
HTTP: isolate socket-related code in http module; initial implementation for keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34234
diff
changeset
|
1439 | url->host, _("Server requires TLS/SSL, " |
|
935120490eb2
HTTP: isolate socket-related code in http module; initial implementation for keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34234
diff
changeset
|
1440 | "but no TLS/SSL support was found.")); |
|
935120490eb2
HTTP: isolate socket-related code in http module; initial implementation for keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34234
diff
changeset
|
1441 | return FALSE; |
|
33430
013c5aebb665
Let's connect
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33429
diff
changeset
|
1442 | } |
|
013c5aebb665
Let's connect
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33429
diff
changeset
|
1443 | |
|
34263
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
1444 | if (hc->request->keepalive_pool != NULL) { |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
1445 | hc->socket_request = purple_http_keepalive_pool_request( |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
1446 | hc->request->keepalive_pool, hc->gc, url->host, |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
1447 | url->port, is_ssl, _purple_http_connected, hc); |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
1448 | } else { |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
1449 | hc->socket = purple_http_socket_connect_new(hc->gc, url->host, |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
1450 | url->port, is_ssl, _purple_http_connected, hc); |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
1451 | } |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
1452 | |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
1453 | if (hc->socket_request == NULL && hc->socket == NULL) { |
|
33430
013c5aebb665
Let's connect
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33429
diff
changeset
|
1454 | _purple_http_error(hc, _("Unable to connect to %s"), url->host); |
|
013c5aebb665
Let's connect
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33429
diff
changeset
|
1455 | return FALSE; |
|
013c5aebb665
Let's connect
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33429
diff
changeset
|
1456 | } |
|
33432
9c4acb75b2e6
Let's parse response headers
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33431
diff
changeset
|
1457 | |
|
9c4acb75b2e6
Let's parse response headers
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33431
diff
changeset
|
1458 | purple_http_headers_free(hc->response->headers); |
|
9c4acb75b2e6
Let's parse response headers
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33431
diff
changeset
|
1459 | hc->response->headers = purple_http_headers_new(); |
|
9c4acb75b2e6
Let's parse response headers
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33431
diff
changeset
|
1460 | hc->response_buffer = g_string_new(""); |
|
9c4acb75b2e6
Let's parse response headers
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33431
diff
changeset
|
1461 | hc->main_header_got = FALSE; |
|
9c4acb75b2e6
Let's parse response headers
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33431
diff
changeset
|
1462 | hc->headers_got = FALSE; |
|
33433
fb7ac52ed7df
Let's get response contents
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33432
diff
changeset
|
1463 | if (hc->response->contents != NULL) |
|
fb7ac52ed7df
Let's get response contents
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33432
diff
changeset
|
1464 | g_string_free(hc->response->contents, TRUE); |
|
fb7ac52ed7df
Let's get response contents
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33432
diff
changeset
|
1465 | hc->response->contents = NULL; |
|
fb7ac52ed7df
Let's get response contents
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33432
diff
changeset
|
1466 | hc->length_got = 0; |
|
fb7ac52ed7df
Let's get response contents
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33432
diff
changeset
|
1467 | hc->length_expected = -1; |
|
33434
ec4f343af107
Chunked file transfers support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33433
diff
changeset
|
1468 | hc->is_chunked = FALSE; |
|
ec4f343af107
Chunked file transfers support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33433
diff
changeset
|
1469 | hc->in_chunk = FALSE; |
|
ec4f343af107
Chunked file transfers support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33433
diff
changeset
|
1470 | hc->chunks_done = FALSE; |
|
33430
013c5aebb665
Let's connect
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33429
diff
changeset
|
1471 | |
|
33468
b057fee9d11a
HTTP progress watcher support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33466
diff
changeset
|
1472 | purple_http_conn_notify_progress_watcher(hc); |
|
b057fee9d11a
HTTP progress watcher support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33466
diff
changeset
|
1473 | |
|
33430
013c5aebb665
Let's connect
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33429
diff
changeset
|
1474 | return TRUE; |
|
013c5aebb665
Let's connect
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33429
diff
changeset
|
1475 | } |
|
013c5aebb665
Let's connect
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33429
diff
changeset
|
1476 | |
|
33427
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
1477 | /*** Performing HTTP requests *************************************************/ |
|
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
1478 | |
|
33450
4042907bcdf1
Timeout support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33448
diff
changeset
|
1479 | static gboolean purple_http_request_timeout(gpointer _hc) |
|
4042907bcdf1
Timeout support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33448
diff
changeset
|
1480 | { |
|
4042907bcdf1
Timeout support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33448
diff
changeset
|
1481 | PurpleHttpConnection *hc = _hc; |
|
4042907bcdf1
Timeout support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33448
diff
changeset
|
1482 | |
|
4042907bcdf1
Timeout support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33448
diff
changeset
|
1483 | purple_debug_warning("http", "Timeout reached for request %p\n", hc); |
|
4042907bcdf1
Timeout support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33448
diff
changeset
|
1484 | |
|
4042907bcdf1
Timeout support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33448
diff
changeset
|
1485 | purple_http_conn_cancel(hc); |
|
4042907bcdf1
Timeout support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33448
diff
changeset
|
1486 | |
|
4042907bcdf1
Timeout support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33448
diff
changeset
|
1487 | return FALSE; |
|
4042907bcdf1
Timeout support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33448
diff
changeset
|
1488 | } |
|
4042907bcdf1
Timeout support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33448
diff
changeset
|
1489 | |
|
34233
8bdcc4f84a5e
HTTP: introduce purple_http_get_printf, make purple_http_get consistent with it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34232
diff
changeset
|
1490 | PurpleHttpConnection * purple_http_get(PurpleConnection *gc, |
|
8bdcc4f84a5e
HTTP: introduce purple_http_get_printf, make purple_http_get consistent with it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34232
diff
changeset
|
1491 | PurpleHttpCallback callback, gpointer user_data, const gchar *url) |
|
33427
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
1492 | { |
|
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
1493 | PurpleHttpRequest *request; |
|
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
1494 | PurpleHttpConnection *hc; |
|
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
1495 | |
|
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
1496 | g_return_val_if_fail(url != NULL, NULL); |
|
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
1497 | |
|
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
1498 | request = purple_http_request_new(url); |
|
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
1499 | hc = purple_http_request(gc, request, callback, user_data); |
|
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
1500 | purple_http_request_unref(request); |
|
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
1501 | |
|
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
1502 | return hc; |
|
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
1503 | } |
|
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
1504 | |
|
34233
8bdcc4f84a5e
HTTP: introduce purple_http_get_printf, make purple_http_get consistent with it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34232
diff
changeset
|
1505 | PurpleHttpConnection * purple_http_get_printf(PurpleConnection *gc, |
|
8bdcc4f84a5e
HTTP: introduce purple_http_get_printf, make purple_http_get consistent with it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34232
diff
changeset
|
1506 | PurpleHttpCallback callback, gpointer user_data, |
|
8bdcc4f84a5e
HTTP: introduce purple_http_get_printf, make purple_http_get consistent with it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34232
diff
changeset
|
1507 | const gchar *format, ...) |
|
8bdcc4f84a5e
HTTP: introduce purple_http_get_printf, make purple_http_get consistent with it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34232
diff
changeset
|
1508 | { |
|
8bdcc4f84a5e
HTTP: introduce purple_http_get_printf, make purple_http_get consistent with it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34232
diff
changeset
|
1509 | va_list args; |
|
8bdcc4f84a5e
HTTP: introduce purple_http_get_printf, make purple_http_get consistent with it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34232
diff
changeset
|
1510 | gchar *value; |
|
8bdcc4f84a5e
HTTP: introduce purple_http_get_printf, make purple_http_get consistent with it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34232
diff
changeset
|
1511 | PurpleHttpConnection *ret; |
|
8bdcc4f84a5e
HTTP: introduce purple_http_get_printf, make purple_http_get consistent with it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34232
diff
changeset
|
1512 | |
|
8bdcc4f84a5e
HTTP: introduce purple_http_get_printf, make purple_http_get consistent with it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34232
diff
changeset
|
1513 | g_return_val_if_fail(format != NULL, NULL); |
|
8bdcc4f84a5e
HTTP: introduce purple_http_get_printf, make purple_http_get consistent with it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34232
diff
changeset
|
1514 | |
|
8bdcc4f84a5e
HTTP: introduce purple_http_get_printf, make purple_http_get consistent with it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34232
diff
changeset
|
1515 | va_start(args, format); |
|
8bdcc4f84a5e
HTTP: introduce purple_http_get_printf, make purple_http_get consistent with it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34232
diff
changeset
|
1516 | value = g_strdup_vprintf(format, args); |
|
8bdcc4f84a5e
HTTP: introduce purple_http_get_printf, make purple_http_get consistent with it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34232
diff
changeset
|
1517 | va_end(args); |
|
8bdcc4f84a5e
HTTP: introduce purple_http_get_printf, make purple_http_get consistent with it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34232
diff
changeset
|
1518 | |
|
8bdcc4f84a5e
HTTP: introduce purple_http_get_printf, make purple_http_get consistent with it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34232
diff
changeset
|
1519 | ret = purple_http_get(gc, callback, user_data, value); |
|
8bdcc4f84a5e
HTTP: introduce purple_http_get_printf, make purple_http_get consistent with it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34232
diff
changeset
|
1520 | g_free(value); |
|
8bdcc4f84a5e
HTTP: introduce purple_http_get_printf, make purple_http_get consistent with it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34232
diff
changeset
|
1521 | |
|
8bdcc4f84a5e
HTTP: introduce purple_http_get_printf, make purple_http_get consistent with it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34232
diff
changeset
|
1522 | return ret; |
|
8bdcc4f84a5e
HTTP: introduce purple_http_get_printf, make purple_http_get consistent with it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34232
diff
changeset
|
1523 | } |
|
8bdcc4f84a5e
HTTP: introduce purple_http_get_printf, make purple_http_get consistent with it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34232
diff
changeset
|
1524 | |
|
33427
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
1525 | PurpleHttpConnection * purple_http_request(PurpleConnection *gc, |
|
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
1526 | PurpleHttpRequest *request, PurpleHttpCallback callback, |
|
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
1527 | gpointer user_data) |
|
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
1528 | { |
|
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
1529 | PurpleHttpConnection *hc; |
|
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
1530 | |
|
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
1531 | g_return_val_if_fail(request != NULL, NULL); |
|
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
1532 | |
|
34232
a5517f235e0f
HTTP: migrate purple_util_fetch_url_request to new API for GG prpl
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34225
diff
changeset
|
1533 | if (request->url == NULL) { |
|
a5517f235e0f
HTTP: migrate purple_util_fetch_url_request to new API for GG prpl
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34225
diff
changeset
|
1534 | purple_debug_error("http", "Cannot perform new request - " |
|
a5517f235e0f
HTTP: migrate purple_util_fetch_url_request to new API for GG prpl
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34225
diff
changeset
|
1535 | "URL is not set\n"); |
|
a5517f235e0f
HTTP: migrate purple_util_fetch_url_request to new API for GG prpl
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34225
diff
changeset
|
1536 | return NULL; |
|
a5517f235e0f
HTTP: migrate purple_util_fetch_url_request to new API for GG prpl
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34225
diff
changeset
|
1537 | } |
|
a5517f235e0f
HTTP: migrate purple_util_fetch_url_request to new API for GG prpl
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34225
diff
changeset
|
1538 | |
|
34262
3b8ce83bac96
HTTP: get rid of one (of two) msn's own http implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34261
diff
changeset
|
1539 | if (g_hash_table_lookup(purple_http_cancelling_gc, gc)) { |
|
3b8ce83bac96
HTTP: get rid of one (of two) msn's own http implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34261
diff
changeset
|
1540 | purple_debug_warning("http", "Cannot perform another HTTP " |
|
3b8ce83bac96
HTTP: get rid of one (of two) msn's own http implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34261
diff
changeset
|
1541 | "request while cancelling all related with this " |
|
3b8ce83bac96
HTTP: get rid of one (of two) msn's own http implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34261
diff
changeset
|
1542 | "PurpleConnection\n"); |
|
3b8ce83bac96
HTTP: get rid of one (of two) msn's own http implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34261
diff
changeset
|
1543 | return NULL; |
|
3b8ce83bac96
HTTP: get rid of one (of two) msn's own http implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34261
diff
changeset
|
1544 | } |
|
3b8ce83bac96
HTTP: get rid of one (of two) msn's own http implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34261
diff
changeset
|
1545 | |
|
33448
4d41b1f7b95f
Cancelling all HTTP connections on account disconnect or app shutdown
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33447
diff
changeset
|
1546 | hc = purple_http_connection_new(request, gc); |
|
33427
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
1547 | hc->callback = callback; |
|
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
1548 | hc->user_data = user_data; |
|
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
1549 | |
|
34268
cf61366236ee
HTTP: connections set support added; BOSH for xmpp reimplemented, to use http API instead of its own HTTP implementation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34267
diff
changeset
|
1550 | hc->url = purple_http_url_parse(request->url); |
|
cf61366236ee
HTTP: connections set support added; BOSH for xmpp reimplemented, to use http API instead of its own HTTP implementation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34267
diff
changeset
|
1551 | |
|
33429
1ce1faf4e675
Extend URL parsing
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33427
diff
changeset
|
1552 | if (purple_debug_is_unsafe()) |
|
1ce1faf4e675
Extend URL parsing
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33427
diff
changeset
|
1553 | purple_debug_misc("http", "Performing new request %p for %s.\n", |
|
1ce1faf4e675
Extend URL parsing
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33427
diff
changeset
|
1554 | hc, request->url); |
|
1ce1faf4e675
Extend URL parsing
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33427
diff
changeset
|
1555 | else |
|
34268
cf61366236ee
HTTP: connections set support added; BOSH for xmpp reimplemented, to use http API instead of its own HTTP implementation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34267
diff
changeset
|
1556 | purple_debug_misc("http", "Performing new request %p to %s.\n", |
|
cf61366236ee
HTTP: connections set support added; BOSH for xmpp reimplemented, to use http API instead of its own HTTP implementation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34267
diff
changeset
|
1557 | hc, hc->url ? hc->url->host : NULL); |
|
cf61366236ee
HTTP: connections set support added; BOSH for xmpp reimplemented, to use http API instead of its own HTTP implementation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34267
diff
changeset
|
1558 | |
|
34218
de45cb0670a5
HTTP: make purple_url_parse deprecated in favor of purple_http_url_parse
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33868
diff
changeset
|
1559 | if (!hc->url || hc->url->host == NULL || hc->url->host[0] == '\0') { |
|
33429
1ce1faf4e675
Extend URL parsing
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33427
diff
changeset
|
1560 | purple_debug_error("http", "Invalid URL requested.\n"); |
|
1ce1faf4e675
Extend URL parsing
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33427
diff
changeset
|
1561 | purple_http_connection_terminate(hc); |
|
1ce1faf4e675
Extend URL parsing
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33427
diff
changeset
|
1562 | return NULL; |
|
1ce1faf4e675
Extend URL parsing
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33427
diff
changeset
|
1563 | } |
|
33427
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
1564 | |
|
33430
013c5aebb665
Let's connect
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33429
diff
changeset
|
1565 | _purple_http_reconnect(hc); |
|
013c5aebb665
Let's connect
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33429
diff
changeset
|
1566 | |
|
33450
4042907bcdf1
Timeout support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33448
diff
changeset
|
1567 | hc->timeout_handle = purple_timeout_add_seconds(request->timeout, |
|
4042907bcdf1
Timeout support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33448
diff
changeset
|
1568 | purple_http_request_timeout, hc); |
|
33427
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
1569 | |
|
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
1570 | return hc; |
|
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
1571 | } |
|
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
1572 | |
|
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
1573 | /*** HTTP connection API ******************************************************/ |
|
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
1574 | |
|
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
1575 | static void purple_http_connection_free(PurpleHttpConnection *hc); |
|
33521
43c34cda245d
HTTP: don't forget to notify about progress before connection freeze
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33517
diff
changeset
|
1576 | static gboolean purple_http_conn_notify_progress_watcher_timeout(gpointer _hc); |
|
33427
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
1577 | |
|
33448
4d41b1f7b95f
Cancelling all HTTP connections on account disconnect or app shutdown
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33447
diff
changeset
|
1578 | static PurpleHttpConnection * purple_http_connection_new( |
|
4d41b1f7b95f
Cancelling all HTTP connections on account disconnect or app shutdown
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33447
diff
changeset
|
1579 | PurpleHttpRequest *request, PurpleConnection *gc) |
|
33427
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
1580 | { |
|
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
1581 | PurpleHttpConnection *hc = g_new0(PurpleHttpConnection, 1); |
|
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
1582 | |
|
33429
1ce1faf4e675
Extend URL parsing
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33427
diff
changeset
|
1583 | hc->request = request; |
|
1ce1faf4e675
Extend URL parsing
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33427
diff
changeset
|
1584 | purple_http_request_ref(request); |
|
33427
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
1585 | hc->response = purple_http_response_new(); |
|
34257
935120490eb2
HTTP: isolate socket-related code in http module; initial implementation for keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34234
diff
changeset
|
1586 | hc->is_keepalive = (request->keepalive_pool != NULL); |
|
33427
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
1587 | |
|
33448
4d41b1f7b95f
Cancelling all HTTP connections on account disconnect or app shutdown
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33447
diff
changeset
|
1588 | hc->link_global = purple_http_hc_list = |
|
4d41b1f7b95f
Cancelling all HTTP connections on account disconnect or app shutdown
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33447
diff
changeset
|
1589 | g_list_prepend(purple_http_hc_list, hc); |
|
4d41b1f7b95f
Cancelling all HTTP connections on account disconnect or app shutdown
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33447
diff
changeset
|
1590 | g_hash_table_insert(purple_http_hc_by_ptr, hc, hc->link_global); |
|
4d41b1f7b95f
Cancelling all HTTP connections on account disconnect or app shutdown
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33447
diff
changeset
|
1591 | if (gc) { |
|
4d41b1f7b95f
Cancelling all HTTP connections on account disconnect or app shutdown
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33447
diff
changeset
|
1592 | GList *gc_list = g_hash_table_lookup(purple_http_hc_by_gc, gc); |
|
4d41b1f7b95f
Cancelling all HTTP connections on account disconnect or app shutdown
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33447
diff
changeset
|
1593 | g_hash_table_steal(purple_http_hc_by_gc, gc); |
|
4d41b1f7b95f
Cancelling all HTTP connections on account disconnect or app shutdown
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33447
diff
changeset
|
1594 | hc->link_gc = gc_list = g_list_prepend(gc_list, hc); |
|
4d41b1f7b95f
Cancelling all HTTP connections on account disconnect or app shutdown
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33447
diff
changeset
|
1595 | g_hash_table_insert(purple_http_hc_by_gc, gc, gc_list); |
|
4d41b1f7b95f
Cancelling all HTTP connections on account disconnect or app shutdown
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33447
diff
changeset
|
1596 | hc->gc = gc; |
|
4d41b1f7b95f
Cancelling all HTTP connections on account disconnect or app shutdown
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33447
diff
changeset
|
1597 | } |
|
4d41b1f7b95f
Cancelling all HTTP connections on account disconnect or app shutdown
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33447
diff
changeset
|
1598 | |
|
33427
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
1599 | return hc; |
|
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
1600 | } |
|
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
1601 | |
|
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
1602 | static void purple_http_connection_free(PurpleHttpConnection *hc) |
|
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
1603 | { |
|
33450
4042907bcdf1
Timeout support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33448
diff
changeset
|
1604 | if (hc->timeout_handle) |
|
4042907bcdf1
Timeout support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33448
diff
changeset
|
1605 | purple_timeout_remove(hc->timeout_handle); |
|
33521
43c34cda245d
HTTP: don't forget to notify about progress before connection freeze
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33517
diff
changeset
|
1606 | if (hc->watcher_delayed_handle) |
|
43c34cda245d
HTTP: don't forget to notify about progress before connection freeze
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33517
diff
changeset
|
1607 | purple_timeout_remove(hc->watcher_delayed_handle); |
|
33450
4042907bcdf1
Timeout support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33448
diff
changeset
|
1608 | |
|
34268
cf61366236ee
HTTP: connections set support added; BOSH for xmpp reimplemented, to use http API instead of its own HTTP implementation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34267
diff
changeset
|
1609 | if (hc->connection_set != NULL) |
|
cf61366236ee
HTTP: connections set support added; BOSH for xmpp reimplemented, to use http API instead of its own HTTP implementation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34267
diff
changeset
|
1610 | purple_http_connection_set_remove(hc->connection_set, hc); |
|
cf61366236ee
HTTP: connections set support added; BOSH for xmpp reimplemented, to use http API instead of its own HTTP implementation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34267
diff
changeset
|
1611 | |
|
33429
1ce1faf4e675
Extend URL parsing
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33427
diff
changeset
|
1612 | purple_http_url_free(hc->url); |
|
1ce1faf4e675
Extend URL parsing
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33427
diff
changeset
|
1613 | purple_http_request_unref(hc->request); |
|
33427
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
1614 | purple_http_response_free(hc->response); |
|
33430
013c5aebb665
Let's connect
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33429
diff
changeset
|
1615 | |
|
33466
918507303f45
HTTP API: PurpleHttpContentReader support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33464
diff
changeset
|
1616 | if (hc->contents_reader_buffer) |
|
918507303f45
HTTP API: PurpleHttpContentReader support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33464
diff
changeset
|
1617 | g_string_free(hc->contents_reader_buffer, TRUE); |
|
918507303f45
HTTP API: PurpleHttpContentReader support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33464
diff
changeset
|
1618 | |
|
33431
704de181d1d2
Let's request
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33430
diff
changeset
|
1619 | if (hc->request_header) |
|
704de181d1d2
Let's request
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33430
diff
changeset
|
1620 | g_string_free(hc->request_header, TRUE); |
|
704de181d1d2
Let's request
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33430
diff
changeset
|
1621 | |
|
33448
4d41b1f7b95f
Cancelling all HTTP connections on account disconnect or app shutdown
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33447
diff
changeset
|
1622 | purple_http_hc_list = g_list_delete_link(purple_http_hc_list, |
|
4d41b1f7b95f
Cancelling all HTTP connections on account disconnect or app shutdown
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33447
diff
changeset
|
1623 | hc->link_global); |
|
4d41b1f7b95f
Cancelling all HTTP connections on account disconnect or app shutdown
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33447
diff
changeset
|
1624 | g_hash_table_remove(purple_http_hc_by_ptr, hc); |
|
4d41b1f7b95f
Cancelling all HTTP connections on account disconnect or app shutdown
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33447
diff
changeset
|
1625 | if (hc->gc) { |
|
4d41b1f7b95f
Cancelling all HTTP connections on account disconnect or app shutdown
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33447
diff
changeset
|
1626 | GList *gc_list, *gc_list_new; |
|
4d41b1f7b95f
Cancelling all HTTP connections on account disconnect or app shutdown
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33447
diff
changeset
|
1627 | gc_list = g_hash_table_lookup(purple_http_hc_by_gc, hc->gc); |
|
4d41b1f7b95f
Cancelling all HTTP connections on account disconnect or app shutdown
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33447
diff
changeset
|
1628 | g_assert(gc_list != NULL); |
|
4d41b1f7b95f
Cancelling all HTTP connections on account disconnect or app shutdown
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33447
diff
changeset
|
1629 | |
|
4d41b1f7b95f
Cancelling all HTTP connections on account disconnect or app shutdown
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33447
diff
changeset
|
1630 | gc_list_new = g_list_delete_link(gc_list, hc->link_gc); |
|
4d41b1f7b95f
Cancelling all HTTP connections on account disconnect or app shutdown
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33447
diff
changeset
|
1631 | if (gc_list != gc_list_new) { |
|
4d41b1f7b95f
Cancelling all HTTP connections on account disconnect or app shutdown
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33447
diff
changeset
|
1632 | g_hash_table_steal(purple_http_hc_by_gc, hc->gc); |
|
4d41b1f7b95f
Cancelling all HTTP connections on account disconnect or app shutdown
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33447
diff
changeset
|
1633 | if (gc_list_new) |
|
4d41b1f7b95f
Cancelling all HTTP connections on account disconnect or app shutdown
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33447
diff
changeset
|
1634 | g_hash_table_insert(purple_http_hc_by_gc, |
|
4d41b1f7b95f
Cancelling all HTTP connections on account disconnect or app shutdown
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33447
diff
changeset
|
1635 | hc->gc, gc_list_new); |
|
4d41b1f7b95f
Cancelling all HTTP connections on account disconnect or app shutdown
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33447
diff
changeset
|
1636 | } |
|
4d41b1f7b95f
Cancelling all HTTP connections on account disconnect or app shutdown
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33447
diff
changeset
|
1637 | } |
|
4d41b1f7b95f
Cancelling all HTTP connections on account disconnect or app shutdown
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33447
diff
changeset
|
1638 | |
|
33427
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
1639 | g_free(hc); |
|
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
1640 | } |
|
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
1641 | |
|
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
1642 | /* call callback and do the cleanup */ |
|
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
1643 | static void purple_http_connection_terminate(PurpleHttpConnection *hc) |
|
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
1644 | { |
|
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
1645 | g_return_if_fail(hc != NULL); |
|
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
1646 | |
|
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
1647 | purple_debug_misc("http", "Request %p performed %s.\n", hc, |
|
34287
6cd0c77b1f6a
HTTP: successful is spelled with one l
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34286
diff
changeset
|
1648 | purple_http_response_is_successful(hc->response) ? |
|
33427
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
1649 | "successfully" : "without success"); |
|
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
1650 | |
|
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
1651 | if (hc->callback) |
|
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
1652 | hc->callback(hc, hc->response, hc->user_data); |
|
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
1653 | |
|
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
1654 | purple_http_connection_free(hc); |
|
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
1655 | } |
|
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
1656 | |
|
33430
013c5aebb665
Let's connect
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33429
diff
changeset
|
1657 | void purple_http_conn_cancel(PurpleHttpConnection *http_conn) |
|
013c5aebb665
Let's connect
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33429
diff
changeset
|
1658 | { |
|
33464
9605c0a2839e
Don't crash when cancelling non-existent HTTP connection
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33462
diff
changeset
|
1659 | if (http_conn == NULL) |
|
9605c0a2839e
Don't crash when cancelling non-existent HTTP connection
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33462
diff
changeset
|
1660 | return; |
|
9605c0a2839e
Don't crash when cancelling non-existent HTTP connection
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33462
diff
changeset
|
1661 | |
|
34263
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
1662 | if (http_conn->is_cancelling) |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
1663 | return; |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
1664 | http_conn->is_cancelling = TRUE; |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
1665 | |
|
34260
7a55eaa31da6
HTTP: implement keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34257
diff
changeset
|
1666 | if (purple_debug_is_verbose()) { |
|
7a55eaa31da6
HTTP: implement keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34257
diff
changeset
|
1667 | purple_debug_misc("http", "Cancelling connection %p...\n", |
|
7a55eaa31da6
HTTP: implement keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34257
diff
changeset
|
1668 | http_conn); |
|
7a55eaa31da6
HTTP: implement keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34257
diff
changeset
|
1669 | } |
|
7a55eaa31da6
HTTP: implement keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34257
diff
changeset
|
1670 | |
|
33430
013c5aebb665
Let's connect
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33429
diff
changeset
|
1671 | http_conn->response->code = 0; |
|
34260
7a55eaa31da6
HTTP: implement keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34257
diff
changeset
|
1672 | _purple_http_disconnect(http_conn, FALSE); |
|
33430
013c5aebb665
Let's connect
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33429
diff
changeset
|
1673 | purple_http_connection_terminate(http_conn); |
|
013c5aebb665
Let's connect
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33429
diff
changeset
|
1674 | } |
|
013c5aebb665
Let's connect
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33429
diff
changeset
|
1675 | |
|
34260
7a55eaa31da6
HTTP: implement keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34257
diff
changeset
|
1676 | static void |
|
7a55eaa31da6
HTTP: implement keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34257
diff
changeset
|
1677 | purple_http_conn_retry(PurpleHttpConnection *http_conn) |
|
7a55eaa31da6
HTTP: implement keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34257
diff
changeset
|
1678 | { |
|
7a55eaa31da6
HTTP: implement keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34257
diff
changeset
|
1679 | if (http_conn == NULL) |
|
7a55eaa31da6
HTTP: implement keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34257
diff
changeset
|
1680 | return; |
|
7a55eaa31da6
HTTP: implement keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34257
diff
changeset
|
1681 | |
|
7a55eaa31da6
HTTP: implement keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34257
diff
changeset
|
1682 | purple_debug_info("http", "Retrying connection %p...\n", http_conn); |
|
7a55eaa31da6
HTTP: implement keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34257
diff
changeset
|
1683 | |
|
7a55eaa31da6
HTTP: implement keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34257
diff
changeset
|
1684 | http_conn->response->code = 0; |
|
7a55eaa31da6
HTTP: implement keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34257
diff
changeset
|
1685 | _purple_http_disconnect(http_conn, FALSE); |
|
7a55eaa31da6
HTTP: implement keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34257
diff
changeset
|
1686 | _purple_http_reconnect(http_conn); |
|
7a55eaa31da6
HTTP: implement keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34257
diff
changeset
|
1687 | } |
|
7a55eaa31da6
HTTP: implement keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34257
diff
changeset
|
1688 | |
|
33427
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
1689 | void purple_http_conn_cancel_all(PurpleConnection *gc) |
|
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
1690 | { |
|
34265
e6de87604147
HTTP: get rid of the second msn's own HTTP implementation (for soap)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34263
diff
changeset
|
1691 | GList *gc_list; |
|
e6de87604147
HTTP: get rid of the second msn's own HTTP implementation (for soap)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34263
diff
changeset
|
1692 | |
|
e6de87604147
HTTP: get rid of the second msn's own HTTP implementation (for soap)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34263
diff
changeset
|
1693 | if (purple_debug_is_verbose()) { |
|
e6de87604147
HTTP: get rid of the second msn's own HTTP implementation (for soap)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34263
diff
changeset
|
1694 | purple_debug_misc("http", "Cancelling all running HTTP " |
|
e6de87604147
HTTP: get rid of the second msn's own HTTP implementation (for soap)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34263
diff
changeset
|
1695 | "connections\n"); |
|
e6de87604147
HTTP: get rid of the second msn's own HTTP implementation (for soap)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34263
diff
changeset
|
1696 | } |
|
e6de87604147
HTTP: get rid of the second msn's own HTTP implementation (for soap)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34263
diff
changeset
|
1697 | |
|
e6de87604147
HTTP: get rid of the second msn's own HTTP implementation (for soap)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34263
diff
changeset
|
1698 | gc_list = g_hash_table_lookup(purple_http_hc_by_gc, gc); |
|
33448
4d41b1f7b95f
Cancelling all HTTP connections on account disconnect or app shutdown
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33447
diff
changeset
|
1699 | |
|
34262
3b8ce83bac96
HTTP: get rid of one (of two) msn's own http implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34261
diff
changeset
|
1700 | g_hash_table_insert(purple_http_cancelling_gc, gc, GINT_TO_POINTER(TRUE)); |
|
3b8ce83bac96
HTTP: get rid of one (of two) msn's own http implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34261
diff
changeset
|
1701 | |
|
33448
4d41b1f7b95f
Cancelling all HTTP connections on account disconnect or app shutdown
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33447
diff
changeset
|
1702 | while (gc_list) { |
|
4d41b1f7b95f
Cancelling all HTTP connections on account disconnect or app shutdown
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33447
diff
changeset
|
1703 | PurpleHttpConnection *hc = gc_list->data; |
|
4d41b1f7b95f
Cancelling all HTTP connections on account disconnect or app shutdown
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33447
diff
changeset
|
1704 | gc_list = g_list_next(gc_list); |
|
4d41b1f7b95f
Cancelling all HTTP connections on account disconnect or app shutdown
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33447
diff
changeset
|
1705 | purple_http_conn_cancel(hc); |
|
4d41b1f7b95f
Cancelling all HTTP connections on account disconnect or app shutdown
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33447
diff
changeset
|
1706 | } |
|
4d41b1f7b95f
Cancelling all HTTP connections on account disconnect or app shutdown
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33447
diff
changeset
|
1707 | |
|
34262
3b8ce83bac96
HTTP: get rid of one (of two) msn's own http implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34261
diff
changeset
|
1708 | g_hash_table_remove(purple_http_cancelling_gc, gc); |
|
3b8ce83bac96
HTTP: get rid of one (of two) msn's own http implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34261
diff
changeset
|
1709 | |
|
33448
4d41b1f7b95f
Cancelling all HTTP connections on account disconnect or app shutdown
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33447
diff
changeset
|
1710 | if (NULL != g_hash_table_lookup(purple_http_hc_by_gc, gc)) |
|
34262
3b8ce83bac96
HTTP: get rid of one (of two) msn's own http implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34261
diff
changeset
|
1711 | purple_debug_fatal("http", "Couldn't cancel all connections " |
|
3b8ce83bac96
HTTP: get rid of one (of two) msn's own http implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34261
diff
changeset
|
1712 | "related to gc=%p (it shouldn't happen)\n", gc); |
|
33448
4d41b1f7b95f
Cancelling all HTTP connections on account disconnect or app shutdown
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33447
diff
changeset
|
1713 | } |
|
4d41b1f7b95f
Cancelling all HTTP connections on account disconnect or app shutdown
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33447
diff
changeset
|
1714 | |
|
4d41b1f7b95f
Cancelling all HTTP connections on account disconnect or app shutdown
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33447
diff
changeset
|
1715 | gboolean purple_http_conn_is_running(PurpleHttpConnection *http_conn) |
|
4d41b1f7b95f
Cancelling all HTTP connections on account disconnect or app shutdown
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33447
diff
changeset
|
1716 | { |
|
4d41b1f7b95f
Cancelling all HTTP connections on account disconnect or app shutdown
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33447
diff
changeset
|
1717 | if (http_conn == NULL) |
|
4d41b1f7b95f
Cancelling all HTTP connections on account disconnect or app shutdown
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33447
diff
changeset
|
1718 | return FALSE; |
|
4d41b1f7b95f
Cancelling all HTTP connections on account disconnect or app shutdown
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33447
diff
changeset
|
1719 | return (NULL != g_hash_table_lookup(purple_http_hc_by_ptr, http_conn)); |
|
33427
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
1720 | } |
|
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
1721 | |
|
33451
27d0e5dbc2a1
Implement missing getters/setters and corresponding features
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33450
diff
changeset
|
1722 | PurpleHttpRequest * purple_http_conn_get_request(PurpleHttpConnection *http_conn) |
|
27d0e5dbc2a1
Implement missing getters/setters and corresponding features
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33450
diff
changeset
|
1723 | { |
|
27d0e5dbc2a1
Implement missing getters/setters and corresponding features
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33450
diff
changeset
|
1724 | g_return_val_if_fail(http_conn != NULL, NULL); |
|
27d0e5dbc2a1
Implement missing getters/setters and corresponding features
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33450
diff
changeset
|
1725 | |
|
27d0e5dbc2a1
Implement missing getters/setters and corresponding features
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33450
diff
changeset
|
1726 | return http_conn->request; |
|
27d0e5dbc2a1
Implement missing getters/setters and corresponding features
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33450
diff
changeset
|
1727 | } |
|
27d0e5dbc2a1
Implement missing getters/setters and corresponding features
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33450
diff
changeset
|
1728 | |
|
33456
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
1729 | PurpleHttpCookieJar * purple_http_conn_get_cookie_jar( |
|
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
1730 | PurpleHttpConnection *http_conn) |
|
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
1731 | { |
|
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
1732 | return purple_http_request_get_cookie_jar(purple_http_conn_get_request( |
|
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
1733 | http_conn)); |
|
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
1734 | } |
|
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
1735 | |
|
33451
27d0e5dbc2a1
Implement missing getters/setters and corresponding features
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33450
diff
changeset
|
1736 | PurpleConnection * purple_http_conn_get_purple_connection( |
|
27d0e5dbc2a1
Implement missing getters/setters and corresponding features
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33450
diff
changeset
|
1737 | PurpleHttpConnection *http_conn) |
|
27d0e5dbc2a1
Implement missing getters/setters and corresponding features
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33450
diff
changeset
|
1738 | { |
|
27d0e5dbc2a1
Implement missing getters/setters and corresponding features
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33450
diff
changeset
|
1739 | g_return_val_if_fail(http_conn != NULL, NULL); |
|
27d0e5dbc2a1
Implement missing getters/setters and corresponding features
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33450
diff
changeset
|
1740 | |
|
27d0e5dbc2a1
Implement missing getters/setters and corresponding features
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33450
diff
changeset
|
1741 | return http_conn->gc; |
|
27d0e5dbc2a1
Implement missing getters/setters and corresponding features
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33450
diff
changeset
|
1742 | } |
|
27d0e5dbc2a1
Implement missing getters/setters and corresponding features
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33450
diff
changeset
|
1743 | |
|
33468
b057fee9d11a
HTTP progress watcher support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33466
diff
changeset
|
1744 | void purple_http_conn_set_progress_watcher(PurpleHttpConnection *http_conn, |
|
b057fee9d11a
HTTP progress watcher support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33466
diff
changeset
|
1745 | PurpleHttpProgressWatcher watcher, gpointer user_data, |
|
34272
8df870b218ca
HTTP: chop off another HTTP implementation (for xmpp oob file transfers)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34268
diff
changeset
|
1746 | gint interval_threshold) |
|
33468
b057fee9d11a
HTTP progress watcher support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33466
diff
changeset
|
1747 | { |
|
b057fee9d11a
HTTP progress watcher support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33466
diff
changeset
|
1748 | g_return_if_fail(http_conn != NULL); |
|
b057fee9d11a
HTTP progress watcher support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33466
diff
changeset
|
1749 | |
|
34272
8df870b218ca
HTTP: chop off another HTTP implementation (for xmpp oob file transfers)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34268
diff
changeset
|
1750 | if (interval_threshold < 0) { |
|
8df870b218ca
HTTP: chop off another HTTP implementation (for xmpp oob file transfers)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34268
diff
changeset
|
1751 | interval_threshold = |
|
8df870b218ca
HTTP: chop off another HTTP implementation (for xmpp oob file transfers)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34268
diff
changeset
|
1752 | PURPLE_HTTP_PROGRESS_WATCHER_DEFAULT_INTERVAL; |
|
8df870b218ca
HTTP: chop off another HTTP implementation (for xmpp oob file transfers)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34268
diff
changeset
|
1753 | } |
|
8df870b218ca
HTTP: chop off another HTTP implementation (for xmpp oob file transfers)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34268
diff
changeset
|
1754 | |
|
33468
b057fee9d11a
HTTP progress watcher support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33466
diff
changeset
|
1755 | http_conn->watcher = watcher; |
|
b057fee9d11a
HTTP progress watcher support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33466
diff
changeset
|
1756 | http_conn->watcher_user_data = user_data; |
|
b057fee9d11a
HTTP progress watcher support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33466
diff
changeset
|
1757 | http_conn->watcher_interval_threshold = interval_threshold; |
|
b057fee9d11a
HTTP progress watcher support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33466
diff
changeset
|
1758 | } |
|
b057fee9d11a
HTTP progress watcher support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33466
diff
changeset
|
1759 | |
|
b057fee9d11a
HTTP progress watcher support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33466
diff
changeset
|
1760 | static void purple_http_conn_notify_progress_watcher( |
|
b057fee9d11a
HTTP progress watcher support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33466
diff
changeset
|
1761 | PurpleHttpConnection *hc) |
|
b057fee9d11a
HTTP progress watcher support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33466
diff
changeset
|
1762 | { |
|
b057fee9d11a
HTTP progress watcher support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33466
diff
changeset
|
1763 | gint64 now; |
|
b057fee9d11a
HTTP progress watcher support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33466
diff
changeset
|
1764 | gboolean reading_state; |
|
b057fee9d11a
HTTP progress watcher support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33466
diff
changeset
|
1765 | int processed, total; |
|
b057fee9d11a
HTTP progress watcher support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33466
diff
changeset
|
1766 | |
|
b057fee9d11a
HTTP progress watcher support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33466
diff
changeset
|
1767 | g_return_if_fail(hc != NULL); |
|
b057fee9d11a
HTTP progress watcher support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33466
diff
changeset
|
1768 | |
|
b057fee9d11a
HTTP progress watcher support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33466
diff
changeset
|
1769 | if (hc->watcher == NULL) |
|
b057fee9d11a
HTTP progress watcher support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33466
diff
changeset
|
1770 | return; |
|
b057fee9d11a
HTTP progress watcher support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33466
diff
changeset
|
1771 | |
|
b057fee9d11a
HTTP progress watcher support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33466
diff
changeset
|
1772 | reading_state = hc->is_reading; |
|
b057fee9d11a
HTTP progress watcher support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33466
diff
changeset
|
1773 | if (reading_state) { |
|
b057fee9d11a
HTTP progress watcher support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33466
diff
changeset
|
1774 | total = hc->length_expected; |
|
b057fee9d11a
HTTP progress watcher support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33466
diff
changeset
|
1775 | processed = hc->length_got; |
|
b057fee9d11a
HTTP progress watcher support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33466
diff
changeset
|
1776 | } else { |
|
b057fee9d11a
HTTP progress watcher support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33466
diff
changeset
|
1777 | total = hc->request->contents_length; |
|
b057fee9d11a
HTTP progress watcher support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33466
diff
changeset
|
1778 | processed = hc->request_contents_written; |
|
b057fee9d11a
HTTP progress watcher support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33466
diff
changeset
|
1779 | if (total == 0) |
|
b057fee9d11a
HTTP progress watcher support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33466
diff
changeset
|
1780 | total = -1; |
|
b057fee9d11a
HTTP progress watcher support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33466
diff
changeset
|
1781 | } |
|
b057fee9d11a
HTTP progress watcher support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33466
diff
changeset
|
1782 | if (total != -1 && total < processed) { |
|
b057fee9d11a
HTTP progress watcher support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33466
diff
changeset
|
1783 | purple_debug_warning("http", "Processed too much\n"); |
|
b057fee9d11a
HTTP progress watcher support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33466
diff
changeset
|
1784 | total = processed; |
|
b057fee9d11a
HTTP progress watcher support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33466
diff
changeset
|
1785 | } |
|
b057fee9d11a
HTTP progress watcher support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33466
diff
changeset
|
1786 | |
|
b057fee9d11a
HTTP progress watcher support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33466
diff
changeset
|
1787 | now = g_get_monotonic_time(); |
|
b057fee9d11a
HTTP progress watcher support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33466
diff
changeset
|
1788 | if (hc->watcher_last_call + hc->watcher_interval_threshold |
|
33521
43c34cda245d
HTTP: don't forget to notify about progress before connection freeze
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33517
diff
changeset
|
1789 | > now && processed != total) { |
|
43c34cda245d
HTTP: don't forget to notify about progress before connection freeze
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33517
diff
changeset
|
1790 | if (hc->watcher_delayed_handle) |
|
43c34cda245d
HTTP: don't forget to notify about progress before connection freeze
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33517
diff
changeset
|
1791 | return; |
|
43c34cda245d
HTTP: don't forget to notify about progress before connection freeze
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33517
diff
changeset
|
1792 | hc->watcher_delayed_handle = purple_timeout_add_seconds( |
|
43c34cda245d
HTTP: don't forget to notify about progress before connection freeze
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33517
diff
changeset
|
1793 | 1 + hc->watcher_interval_threshold / 1000000, |
|
43c34cda245d
HTTP: don't forget to notify about progress before connection freeze
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33517
diff
changeset
|
1794 | purple_http_conn_notify_progress_watcher_timeout, hc); |
|
33468
b057fee9d11a
HTTP progress watcher support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33466
diff
changeset
|
1795 | return; |
|
33521
43c34cda245d
HTTP: don't forget to notify about progress before connection freeze
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33517
diff
changeset
|
1796 | } |
|
43c34cda245d
HTTP: don't forget to notify about progress before connection freeze
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33517
diff
changeset
|
1797 | |
|
43c34cda245d
HTTP: don't forget to notify about progress before connection freeze
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33517
diff
changeset
|
1798 | if (hc->watcher_delayed_handle) |
|
43c34cda245d
HTTP: don't forget to notify about progress before connection freeze
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33517
diff
changeset
|
1799 | purple_timeout_remove(hc->watcher_delayed_handle); |
|
43c34cda245d
HTTP: don't forget to notify about progress before connection freeze
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33517
diff
changeset
|
1800 | hc->watcher_delayed_handle = 0; |
|
43c34cda245d
HTTP: don't forget to notify about progress before connection freeze
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33517
diff
changeset
|
1801 | |
|
33468
b057fee9d11a
HTTP progress watcher support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33466
diff
changeset
|
1802 | hc->watcher_last_call = now; |
|
b057fee9d11a
HTTP progress watcher support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33466
diff
changeset
|
1803 | hc->watcher(hc, reading_state, processed, total, hc->watcher_user_data); |
|
b057fee9d11a
HTTP progress watcher support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33466
diff
changeset
|
1804 | } |
|
b057fee9d11a
HTTP progress watcher support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33466
diff
changeset
|
1805 | |
|
33521
43c34cda245d
HTTP: don't forget to notify about progress before connection freeze
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33517
diff
changeset
|
1806 | static gboolean purple_http_conn_notify_progress_watcher_timeout(gpointer _hc) |
|
43c34cda245d
HTTP: don't forget to notify about progress before connection freeze
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33517
diff
changeset
|
1807 | { |
|
43c34cda245d
HTTP: don't forget to notify about progress before connection freeze
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33517
diff
changeset
|
1808 | PurpleHttpConnection *hc = _hc; |
|
43c34cda245d
HTTP: don't forget to notify about progress before connection freeze
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33517
diff
changeset
|
1809 | |
|
43c34cda245d
HTTP: don't forget to notify about progress before connection freeze
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33517
diff
changeset
|
1810 | purple_http_conn_notify_progress_watcher(hc); |
|
43c34cda245d
HTTP: don't forget to notify about progress before connection freeze
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33517
diff
changeset
|
1811 | |
|
43c34cda245d
HTTP: don't forget to notify about progress before connection freeze
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33517
diff
changeset
|
1812 | return FALSE; |
|
43c34cda245d
HTTP: don't forget to notify about progress before connection freeze
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33517
diff
changeset
|
1813 | } |
|
43c34cda245d
HTTP: don't forget to notify about progress before connection freeze
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33517
diff
changeset
|
1814 | |
|
33456
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
1815 | /*** Cookie jar API ***********************************************************/ |
|
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
1816 | |
|
33459
722a6d753cb2
Better cookies, better chunked transfer support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33458
diff
changeset
|
1817 | static PurpleHttpCookie * purple_http_cookie_new(const gchar *value); |
|
722a6d753cb2
Better cookies, better chunked transfer support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33458
diff
changeset
|
1818 | void purple_http_cookie_free(PurpleHttpCookie *cookie); |
|
722a6d753cb2
Better cookies, better chunked transfer support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33458
diff
changeset
|
1819 | |
|
722a6d753cb2
Better cookies, better chunked transfer support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33458
diff
changeset
|
1820 | static void purple_http_cookie_jar_set_ext(PurpleHttpCookieJar *cookie_jar, |
|
722a6d753cb2
Better cookies, better chunked transfer support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33458
diff
changeset
|
1821 | const gchar *name, const gchar *value, time_t expires); |
|
722a6d753cb2
Better cookies, better chunked transfer support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33458
diff
changeset
|
1822 | |
|
722a6d753cb2
Better cookies, better chunked transfer support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33458
diff
changeset
|
1823 | static PurpleHttpCookie * purple_http_cookie_new(const gchar *value) |
|
722a6d753cb2
Better cookies, better chunked transfer support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33458
diff
changeset
|
1824 | { |
|
722a6d753cb2
Better cookies, better chunked transfer support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33458
diff
changeset
|
1825 | PurpleHttpCookie *cookie = g_new0(PurpleHttpCookie, 1); |
|
722a6d753cb2
Better cookies, better chunked transfer support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33458
diff
changeset
|
1826 | |
|
722a6d753cb2
Better cookies, better chunked transfer support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33458
diff
changeset
|
1827 | cookie->value = g_strdup(value); |
|
722a6d753cb2
Better cookies, better chunked transfer support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33458
diff
changeset
|
1828 | cookie->expires = -1; |
|
722a6d753cb2
Better cookies, better chunked transfer support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33458
diff
changeset
|
1829 | |
|
722a6d753cb2
Better cookies, better chunked transfer support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33458
diff
changeset
|
1830 | return cookie; |
|
722a6d753cb2
Better cookies, better chunked transfer support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33458
diff
changeset
|
1831 | } |
|
722a6d753cb2
Better cookies, better chunked transfer support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33458
diff
changeset
|
1832 | |
|
722a6d753cb2
Better cookies, better chunked transfer support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33458
diff
changeset
|
1833 | void purple_http_cookie_free(PurpleHttpCookie *cookie) |
|
722a6d753cb2
Better cookies, better chunked transfer support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33458
diff
changeset
|
1834 | { |
|
722a6d753cb2
Better cookies, better chunked transfer support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33458
diff
changeset
|
1835 | g_free(cookie->value); |
|
722a6d753cb2
Better cookies, better chunked transfer support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33458
diff
changeset
|
1836 | g_free(cookie); |
|
722a6d753cb2
Better cookies, better chunked transfer support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33458
diff
changeset
|
1837 | } |
|
722a6d753cb2
Better cookies, better chunked transfer support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33458
diff
changeset
|
1838 | |
|
33456
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
1839 | void purple_http_cookie_jar_free(PurpleHttpCookieJar *cookie_jar); |
|
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
1840 | |
|
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
1841 | PurpleHttpCookieJar * purple_http_cookie_jar_new(void) |
|
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
1842 | { |
|
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
1843 | PurpleHttpCookieJar *cjar = g_new0(PurpleHttpCookieJar, 1); |
|
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
1844 | |
|
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
1845 | cjar->ref_count = 1; |
|
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
1846 | cjar->tab = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, |
|
33459
722a6d753cb2
Better cookies, better chunked transfer support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33458
diff
changeset
|
1847 | (GDestroyNotify)purple_http_cookie_free); |
|
33456
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
1848 | |
|
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
1849 | return cjar; |
|
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
1850 | } |
|
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
1851 | |
|
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
1852 | void purple_http_cookie_jar_free(PurpleHttpCookieJar *cookie_jar) |
|
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
1853 | { |
|
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
1854 | g_hash_table_destroy(cookie_jar->tab); |
|
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
1855 | g_free(cookie_jar); |
|
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
1856 | } |
|
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
1857 | |
|
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
1858 | void purple_http_cookie_jar_ref(PurpleHttpCookieJar *cookie_jar) |
|
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
1859 | { |
|
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
1860 | g_return_if_fail(cookie_jar != NULL); |
|
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
1861 | |
|
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
1862 | cookie_jar->ref_count++; |
|
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
1863 | } |
|
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
1864 | |
|
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
1865 | PurpleHttpCookieJar * purple_http_cookie_jar_unref( |
|
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
1866 | PurpleHttpCookieJar *cookie_jar) |
|
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
1867 | { |
|
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
1868 | if (cookie_jar == NULL) |
|
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
1869 | return NULL; |
|
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
1870 | |
|
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
1871 | g_return_val_if_fail(cookie_jar->ref_count > 0, NULL); |
|
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
1872 | |
|
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
1873 | cookie_jar->ref_count--; |
|
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
1874 | if (cookie_jar->ref_count > 0) |
|
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
1875 | return cookie_jar; |
|
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
1876 | |
|
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
1877 | purple_http_cookie_jar_free(cookie_jar); |
|
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
1878 | return NULL; |
|
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
1879 | } |
|
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
1880 | |
|
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
1881 | static void purple_http_cookie_jar_parse(PurpleHttpCookieJar *cookie_jar, |
|
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
1882 | GList *values) |
|
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
1883 | { |
|
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
1884 | values = g_list_first(values); |
|
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
1885 | while (values) { |
|
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
1886 | const gchar *cookie = values->data; |
|
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
1887 | const gchar *eqsign, *semicolon; |
|
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
1888 | gchar *name, *value; |
|
33460
c37dd51516aa
Deleting (or expiring) a cookie
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33459
diff
changeset
|
1889 | time_t expires = -1; |
|
33456
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
1890 | values = g_list_next(values); |
|
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
1891 | |
|
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
1892 | eqsign = strchr(cookie, '='); |
|
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
1893 | semicolon = strchr(cookie, ';'); |
|
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
1894 | |
|
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
1895 | if (eqsign == NULL || eqsign == cookie || |
|
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
1896 | (semicolon != NULL && semicolon < eqsign)) { |
|
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
1897 | if (purple_debug_is_unsafe()) |
|
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
1898 | purple_debug_warning("http", |
|
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
1899 | "Invalid cookie: [%s]\n", cookie); |
|
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
1900 | else |
|
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
1901 | purple_debug_warning("http", "Invalid cookie."); |
|
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
1902 | } |
|
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
1903 | |
|
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
1904 | name = g_strndup(cookie, eqsign - cookie); |
|
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
1905 | eqsign++; |
|
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
1906 | if (semicolon != NULL) |
|
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
1907 | value = g_strndup(eqsign, semicolon - eqsign); |
|
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
1908 | else |
|
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
1909 | value = g_strdup(eqsign); |
|
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
1910 | |
|
33459
722a6d753cb2
Better cookies, better chunked transfer support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33458
diff
changeset
|
1911 | if (semicolon != NULL) { |
|
33460
c37dd51516aa
Deleting (or expiring) a cookie
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33459
diff
changeset
|
1912 | GMatchInfo *match_info; |
|
c37dd51516aa
Deleting (or expiring) a cookie
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33459
diff
changeset
|
1913 | GRegex *re_expires = g_regex_new( |
|
c37dd51516aa
Deleting (or expiring) a cookie
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33459
diff
changeset
|
1914 | "expires=([a-z0-9, :]+)", |
|
c37dd51516aa
Deleting (or expiring) a cookie
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33459
diff
changeset
|
1915 | G_REGEX_OPTIMIZE | G_REGEX_CASELESS, |
|
c37dd51516aa
Deleting (or expiring) a cookie
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33459
diff
changeset
|
1916 | G_REGEX_MATCH_NOTEMPTY, NULL); |
|
c37dd51516aa
Deleting (or expiring) a cookie
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33459
diff
changeset
|
1917 | |
|
c37dd51516aa
Deleting (or expiring) a cookie
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33459
diff
changeset
|
1918 | g_regex_match(re_expires, semicolon, 0, &match_info); |
|
c37dd51516aa
Deleting (or expiring) a cookie
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33459
diff
changeset
|
1919 | if (g_match_info_matches(match_info)) { |
|
c37dd51516aa
Deleting (or expiring) a cookie
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33459
diff
changeset
|
1920 | gchar *expire_date = |
|
c37dd51516aa
Deleting (or expiring) a cookie
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33459
diff
changeset
|
1921 | g_match_info_fetch(match_info, 1); |
|
c37dd51516aa
Deleting (or expiring) a cookie
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33459
diff
changeset
|
1922 | expires = purple_http_rfc1123_to_time( |
|
c37dd51516aa
Deleting (or expiring) a cookie
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33459
diff
changeset
|
1923 | expire_date); |
|
c37dd51516aa
Deleting (or expiring) a cookie
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33459
diff
changeset
|
1924 | g_free(expire_date); |
|
c37dd51516aa
Deleting (or expiring) a cookie
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33459
diff
changeset
|
1925 | } |
|
c37dd51516aa
Deleting (or expiring) a cookie
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33459
diff
changeset
|
1926 | g_match_info_free(match_info); |
|
c37dd51516aa
Deleting (or expiring) a cookie
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33459
diff
changeset
|
1927 | |
|
c37dd51516aa
Deleting (or expiring) a cookie
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33459
diff
changeset
|
1928 | g_regex_unref(re_expires); |
|
33459
722a6d753cb2
Better cookies, better chunked transfer support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33458
diff
changeset
|
1929 | } |
|
722a6d753cb2
Better cookies, better chunked transfer support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33458
diff
changeset
|
1930 | |
|
33460
c37dd51516aa
Deleting (or expiring) a cookie
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33459
diff
changeset
|
1931 | purple_http_cookie_jar_set_ext(cookie_jar, name, value, expires); |
|
33456
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
1932 | |
|
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
1933 | g_free(name); |
|
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
1934 | g_free(value); |
|
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
1935 | } |
|
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
1936 | } |
|
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
1937 | |
|
33458
59b3364f690e
Sending cookies
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33457
diff
changeset
|
1938 | static gchar * purple_http_cookie_jar_gen(PurpleHttpCookieJar *cookie_jar) |
|
59b3364f690e
Sending cookies
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33457
diff
changeset
|
1939 | { |
|
59b3364f690e
Sending cookies
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33457
diff
changeset
|
1940 | GHashTableIter it; |
|
33459
722a6d753cb2
Better cookies, better chunked transfer support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33458
diff
changeset
|
1941 | gchar *key; |
|
722a6d753cb2
Better cookies, better chunked transfer support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33458
diff
changeset
|
1942 | PurpleHttpCookie *cookie; |
|
33458
59b3364f690e
Sending cookies
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33457
diff
changeset
|
1943 | GString *str; |
|
33460
c37dd51516aa
Deleting (or expiring) a cookie
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33459
diff
changeset
|
1944 | time_t now = time(NULL); |
|
33458
59b3364f690e
Sending cookies
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33457
diff
changeset
|
1945 | |
|
59b3364f690e
Sending cookies
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33457
diff
changeset
|
1946 | g_return_val_if_fail(cookie_jar != NULL, NULL); |
|
59b3364f690e
Sending cookies
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33457
diff
changeset
|
1947 | |
|
59b3364f690e
Sending cookies
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33457
diff
changeset
|
1948 | str = g_string_new(""); |
|
59b3364f690e
Sending cookies
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33457
diff
changeset
|
1949 | |
|
59b3364f690e
Sending cookies
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33457
diff
changeset
|
1950 | g_hash_table_iter_init(&it, cookie_jar->tab); |
|
33460
c37dd51516aa
Deleting (or expiring) a cookie
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33459
diff
changeset
|
1951 | while (g_hash_table_iter_next(&it, (gpointer*)&key, |
|
c37dd51516aa
Deleting (or expiring) a cookie
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33459
diff
changeset
|
1952 | (gpointer*)&cookie)) { |
|
c37dd51516aa
Deleting (or expiring) a cookie
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33459
diff
changeset
|
1953 | if (cookie->expires != -1 && cookie->expires <= now) |
|
c37dd51516aa
Deleting (or expiring) a cookie
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33459
diff
changeset
|
1954 | continue; |
|
33459
722a6d753cb2
Better cookies, better chunked transfer support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33458
diff
changeset
|
1955 | g_string_append_printf(str, "%s=%s; ", key, cookie->value); |
|
33460
c37dd51516aa
Deleting (or expiring) a cookie
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33459
diff
changeset
|
1956 | } |
|
33458
59b3364f690e
Sending cookies
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33457
diff
changeset
|
1957 | |
|
59b3364f690e
Sending cookies
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33457
diff
changeset
|
1958 | if (str->len > 0) |
|
59b3364f690e
Sending cookies
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33457
diff
changeset
|
1959 | g_string_truncate(str, str->len - 2); |
|
59b3364f690e
Sending cookies
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33457
diff
changeset
|
1960 | return g_string_free(str, FALSE); |
|
59b3364f690e
Sending cookies
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33457
diff
changeset
|
1961 | } |
|
59b3364f690e
Sending cookies
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33457
diff
changeset
|
1962 | |
|
33456
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
1963 | void purple_http_cookie_jar_set(PurpleHttpCookieJar *cookie_jar, |
|
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
1964 | const gchar *name, const gchar *value) |
|
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
1965 | { |
|
33459
722a6d753cb2
Better cookies, better chunked transfer support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33458
diff
changeset
|
1966 | purple_http_cookie_jar_set_ext(cookie_jar, name, value, -1); |
|
722a6d753cb2
Better cookies, better chunked transfer support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33458
diff
changeset
|
1967 | } |
|
722a6d753cb2
Better cookies, better chunked transfer support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33458
diff
changeset
|
1968 | |
|
722a6d753cb2
Better cookies, better chunked transfer support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33458
diff
changeset
|
1969 | static void purple_http_cookie_jar_set_ext(PurpleHttpCookieJar *cookie_jar, |
|
722a6d753cb2
Better cookies, better chunked transfer support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33458
diff
changeset
|
1970 | const gchar *name, const gchar *value, time_t expires) |
|
722a6d753cb2
Better cookies, better chunked transfer support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33458
diff
changeset
|
1971 | { |
|
33456
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
1972 | g_return_if_fail(cookie_jar != NULL); |
|
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
1973 | g_return_if_fail(name != NULL); |
|
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
1974 | |
|
33460
c37dd51516aa
Deleting (or expiring) a cookie
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33459
diff
changeset
|
1975 | if (expires != -1 && time(NULL) >= expires) |
|
33459
722a6d753cb2
Better cookies, better chunked transfer support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33458
diff
changeset
|
1976 | value = NULL; |
|
722a6d753cb2
Better cookies, better chunked transfer support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33458
diff
changeset
|
1977 | |
|
722a6d753cb2
Better cookies, better chunked transfer support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33458
diff
changeset
|
1978 | if (value != NULL) { |
|
722a6d753cb2
Better cookies, better chunked transfer support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33458
diff
changeset
|
1979 | PurpleHttpCookie *cookie = purple_http_cookie_new(value); |
|
722a6d753cb2
Better cookies, better chunked transfer support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33458
diff
changeset
|
1980 | cookie->expires = expires; |
|
722a6d753cb2
Better cookies, better chunked transfer support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33458
diff
changeset
|
1981 | g_hash_table_insert(cookie_jar->tab, g_strdup(name), cookie); |
|
722a6d753cb2
Better cookies, better chunked transfer support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33458
diff
changeset
|
1982 | } else |
|
33456
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
1983 | g_hash_table_remove(cookie_jar->tab, name); |
|
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
1984 | } |
|
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
1985 | |
|
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
1986 | const gchar * purple_http_cookie_jar_get(PurpleHttpCookieJar *cookie_jar, |
|
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
1987 | const gchar *name) |
|
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
1988 | { |
|
33459
722a6d753cb2
Better cookies, better chunked transfer support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33458
diff
changeset
|
1989 | PurpleHttpCookie *cookie; |
|
722a6d753cb2
Better cookies, better chunked transfer support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33458
diff
changeset
|
1990 | |
|
722a6d753cb2
Better cookies, better chunked transfer support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33458
diff
changeset
|
1991 | g_return_val_if_fail(cookie_jar != NULL, NULL); |
|
722a6d753cb2
Better cookies, better chunked transfer support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33458
diff
changeset
|
1992 | g_return_val_if_fail(name != NULL, NULL); |
|
722a6d753cb2
Better cookies, better chunked transfer support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33458
diff
changeset
|
1993 | |
|
722a6d753cb2
Better cookies, better chunked transfer support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33458
diff
changeset
|
1994 | cookie = g_hash_table_lookup(cookie_jar->tab, name); |
|
722a6d753cb2
Better cookies, better chunked transfer support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33458
diff
changeset
|
1995 | if (!cookie) |
|
722a6d753cb2
Better cookies, better chunked transfer support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33458
diff
changeset
|
1996 | return NULL; |
|
722a6d753cb2
Better cookies, better chunked transfer support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33458
diff
changeset
|
1997 | |
|
722a6d753cb2
Better cookies, better chunked transfer support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33458
diff
changeset
|
1998 | return cookie->value; |
|
33456
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
1999 | } |
|
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
2000 | |
|
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
2001 | gchar * purple_http_cookie_jar_dump(PurpleHttpCookieJar *cjar) |
|
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
2002 | { |
|
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
2003 | GHashTableIter it; |
|
33459
722a6d753cb2
Better cookies, better chunked transfer support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33458
diff
changeset
|
2004 | gchar *key; |
|
722a6d753cb2
Better cookies, better chunked transfer support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33458
diff
changeset
|
2005 | PurpleHttpCookie *cookie; |
|
33456
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
2006 | GString *str = g_string_new(""); |
|
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
2007 | |
|
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
2008 | g_hash_table_iter_init(&it, cjar->tab); |
|
33459
722a6d753cb2
Better cookies, better chunked transfer support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33458
diff
changeset
|
2009 | while (g_hash_table_iter_next(&it, (gpointer*)&key, (gpointer*)&cookie)) |
|
33868
0ab9ed685a54
win32: fix a warning in http module
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33854
diff
changeset
|
2010 | g_string_append_printf(str, "%s: %s (expires: %" G_GINT64_FORMAT |
|
0ab9ed685a54
win32: fix a warning in http module
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33854
diff
changeset
|
2011 | ")\n", key, cookie->value, (gint64)cookie->expires); |
|
33456
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
2012 | |
|
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
2013 | if (str->len > 0) |
|
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
2014 | g_string_truncate(str, str->len - 1); |
|
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
2015 | return g_string_free(str, FALSE); |
|
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
2016 | } |
|
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
2017 | |
|
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
2018 | gboolean purple_http_cookie_jar_is_empty(PurpleHttpCookieJar *cookie_jar) |
|
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
2019 | { |
|
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
2020 | g_return_val_if_fail(cookie_jar != NULL, TRUE); |
|
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
2021 | |
|
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
2022 | return g_hash_table_size(cookie_jar->tab) == 0; |
|
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
2023 | } |
|
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
2024 | |
|
34257
935120490eb2
HTTP: isolate socket-related code in http module; initial implementation for keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34234
diff
changeset
|
2025 | /*** HTTP Keep-Alive pool API *************************************************/ |
|
935120490eb2
HTTP: isolate socket-related code in http module; initial implementation for keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34234
diff
changeset
|
2026 | |
|
34260
7a55eaa31da6
HTTP: implement keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34257
diff
changeset
|
2027 | static void |
|
34263
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
2028 | purple_http_keepalive_host_process_queue(PurpleHttpKeepaliveHost *host); |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
2029 | |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
2030 | static void |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
2031 | purple_http_keepalive_host_free(gpointer _host) |
|
34260
7a55eaa31da6
HTTP: implement keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34257
diff
changeset
|
2032 | { |
|
34263
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
2033 | PurpleHttpKeepaliveHost *host = _host; |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
2034 | |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
2035 | if (host->process_queue_timeout > 0) { |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
2036 | purple_timeout_remove(host->process_queue_timeout); |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
2037 | host->process_queue_timeout = 0; |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
2038 | } |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
2039 | |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
2040 | g_free(host->host); |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
2041 | |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
2042 | g_slist_free_full(host->queue, |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
2043 | (GDestroyNotify)purple_http_keepalive_pool_request_cancel); |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
2044 | g_slist_free_full(host->sockets, |
|
34260
7a55eaa31da6
HTTP: implement keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34257
diff
changeset
|
2045 | (GDestroyNotify)purple_http_socket_close_free); |
|
34263
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
2046 | |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
2047 | g_free(host); |
|
34260
7a55eaa31da6
HTTP: implement keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34257
diff
changeset
|
2048 | } |
|
7a55eaa31da6
HTTP: implement keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34257
diff
changeset
|
2049 | |
|
34257
935120490eb2
HTTP: isolate socket-related code in http module; initial implementation for keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34234
diff
changeset
|
2050 | PurpleHttpKeepalivePool * |
|
935120490eb2
HTTP: isolate socket-related code in http module; initial implementation for keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34234
diff
changeset
|
2051 | purple_http_keepalive_pool_new(void) |
|
935120490eb2
HTTP: isolate socket-related code in http module; initial implementation for keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34234
diff
changeset
|
2052 | { |
|
935120490eb2
HTTP: isolate socket-related code in http module; initial implementation for keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34234
diff
changeset
|
2053 | PurpleHttpKeepalivePool *pool = g_new0(PurpleHttpKeepalivePool, 1); |
|
935120490eb2
HTTP: isolate socket-related code in http module; initial implementation for keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34234
diff
changeset
|
2054 | |
|
935120490eb2
HTTP: isolate socket-related code in http module; initial implementation for keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34234
diff
changeset
|
2055 | pool->ref_count = 1; |
|
34260
7a55eaa31da6
HTTP: implement keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34257
diff
changeset
|
2056 | pool->by_hash = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, |
|
34263
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
2057 | purple_http_keepalive_host_free); |
|
34257
935120490eb2
HTTP: isolate socket-related code in http module; initial implementation for keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34234
diff
changeset
|
2058 | |
|
935120490eb2
HTTP: isolate socket-related code in http module; initial implementation for keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34234
diff
changeset
|
2059 | return pool; |
|
935120490eb2
HTTP: isolate socket-related code in http module; initial implementation for keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34234
diff
changeset
|
2060 | } |
|
935120490eb2
HTTP: isolate socket-related code in http module; initial implementation for keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34234
diff
changeset
|
2061 | |
|
935120490eb2
HTTP: isolate socket-related code in http module; initial implementation for keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34234
diff
changeset
|
2062 | static void |
|
935120490eb2
HTTP: isolate socket-related code in http module; initial implementation for keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34234
diff
changeset
|
2063 | purple_http_keepalive_pool_free(PurpleHttpKeepalivePool *pool) |
|
935120490eb2
HTTP: isolate socket-related code in http module; initial implementation for keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34234
diff
changeset
|
2064 | { |
|
935120490eb2
HTTP: isolate socket-related code in http module; initial implementation for keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34234
diff
changeset
|
2065 | g_return_if_fail(pool != NULL); |
|
935120490eb2
HTTP: isolate socket-related code in http module; initial implementation for keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34234
diff
changeset
|
2066 | |
|
34263
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
2067 | if (pool->is_destroying) |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
2068 | return; |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
2069 | pool->is_destroying = TRUE; |
|
34260
7a55eaa31da6
HTTP: implement keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34257
diff
changeset
|
2070 | g_hash_table_destroy(pool->by_hash); |
|
34257
935120490eb2
HTTP: isolate socket-related code in http module; initial implementation for keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34234
diff
changeset
|
2071 | g_free(pool); |
|
935120490eb2
HTTP: isolate socket-related code in http module; initial implementation for keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34234
diff
changeset
|
2072 | } |
|
935120490eb2
HTTP: isolate socket-related code in http module; initial implementation for keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34234
diff
changeset
|
2073 | |
|
935120490eb2
HTTP: isolate socket-related code in http module; initial implementation for keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34234
diff
changeset
|
2074 | void |
|
935120490eb2
HTTP: isolate socket-related code in http module; initial implementation for keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34234
diff
changeset
|
2075 | purple_http_keepalive_pool_ref(PurpleHttpKeepalivePool *pool) |
|
935120490eb2
HTTP: isolate socket-related code in http module; initial implementation for keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34234
diff
changeset
|
2076 | { |
|
935120490eb2
HTTP: isolate socket-related code in http module; initial implementation for keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34234
diff
changeset
|
2077 | g_return_if_fail(pool != NULL); |
|
935120490eb2
HTTP: isolate socket-related code in http module; initial implementation for keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34234
diff
changeset
|
2078 | |
|
935120490eb2
HTTP: isolate socket-related code in http module; initial implementation for keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34234
diff
changeset
|
2079 | pool->ref_count++; |
|
935120490eb2
HTTP: isolate socket-related code in http module; initial implementation for keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34234
diff
changeset
|
2080 | } |
|
935120490eb2
HTTP: isolate socket-related code in http module; initial implementation for keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34234
diff
changeset
|
2081 | |
|
935120490eb2
HTTP: isolate socket-related code in http module; initial implementation for keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34234
diff
changeset
|
2082 | PurpleHttpKeepalivePool * |
|
935120490eb2
HTTP: isolate socket-related code in http module; initial implementation for keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34234
diff
changeset
|
2083 | purple_http_keepalive_pool_unref(PurpleHttpKeepalivePool *pool) |
|
935120490eb2
HTTP: isolate socket-related code in http module; initial implementation for keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34234
diff
changeset
|
2084 | { |
|
935120490eb2
HTTP: isolate socket-related code in http module; initial implementation for keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34234
diff
changeset
|
2085 | if (pool == NULL) |
|
935120490eb2
HTTP: isolate socket-related code in http module; initial implementation for keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34234
diff
changeset
|
2086 | return NULL; |
|
935120490eb2
HTTP: isolate socket-related code in http module; initial implementation for keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34234
diff
changeset
|
2087 | |
|
935120490eb2
HTTP: isolate socket-related code in http module; initial implementation for keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34234
diff
changeset
|
2088 | g_return_val_if_fail(pool->ref_count > 0, NULL); |
|
935120490eb2
HTTP: isolate socket-related code in http module; initial implementation for keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34234
diff
changeset
|
2089 | |
|
935120490eb2
HTTP: isolate socket-related code in http module; initial implementation for keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34234
diff
changeset
|
2090 | pool->ref_count--; |
|
935120490eb2
HTTP: isolate socket-related code in http module; initial implementation for keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34234
diff
changeset
|
2091 | if (pool->ref_count > 0) |
|
935120490eb2
HTTP: isolate socket-related code in http module; initial implementation for keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34234
diff
changeset
|
2092 | return pool; |
|
935120490eb2
HTTP: isolate socket-related code in http module; initial implementation for keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34234
diff
changeset
|
2093 | |
|
935120490eb2
HTTP: isolate socket-related code in http module; initial implementation for keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34234
diff
changeset
|
2094 | purple_http_keepalive_pool_free(pool); |
|
935120490eb2
HTTP: isolate socket-related code in http module; initial implementation for keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34234
diff
changeset
|
2095 | return NULL; |
|
935120490eb2
HTTP: isolate socket-related code in http module; initial implementation for keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34234
diff
changeset
|
2096 | } |
|
935120490eb2
HTTP: isolate socket-related code in http module; initial implementation for keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34234
diff
changeset
|
2097 | |
|
34263
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
2098 | static PurpleHttpKeepaliveRequest * |
|
34260
7a55eaa31da6
HTTP: implement keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34257
diff
changeset
|
2099 | purple_http_keepalive_pool_request(PurpleHttpKeepalivePool *pool, |
|
7a55eaa31da6
HTTP: implement keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34257
diff
changeset
|
2100 | PurpleConnection *gc, const gchar *host, int port, gboolean is_ssl, |
|
7a55eaa31da6
HTTP: implement keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34257
diff
changeset
|
2101 | PurpleHttpSocketConnectCb cb, gpointer user_data) |
|
7a55eaa31da6
HTTP: implement keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34257
diff
changeset
|
2102 | { |
|
34263
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
2103 | PurpleHttpKeepaliveRequest *req; |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
2104 | PurpleHttpKeepaliveHost *kahost; |
|
34260
7a55eaa31da6
HTTP: implement keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34257
diff
changeset
|
2105 | gchar *hash; |
|
34263
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
2106 | |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
2107 | g_return_val_if_fail(pool != NULL, NULL); |
|
34260
7a55eaa31da6
HTTP: implement keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34257
diff
changeset
|
2108 | g_return_val_if_fail(host != NULL, NULL); |
|
7a55eaa31da6
HTTP: implement keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34257
diff
changeset
|
2109 | |
|
34263
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
2110 | if (pool->is_destroying) { |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
2111 | purple_debug_error("http", "pool is destroying\n"); |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
2112 | return NULL; |
|
34260
7a55eaa31da6
HTTP: implement keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34257
diff
changeset
|
2113 | } |
|
7a55eaa31da6
HTTP: implement keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34257
diff
changeset
|
2114 | |
|
7a55eaa31da6
HTTP: implement keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34257
diff
changeset
|
2115 | hash = purple_http_socket_hash(host, port, is_ssl); |
|
34263
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
2116 | kahost = g_hash_table_lookup(pool->by_hash, hash); |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
2117 | |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
2118 | if (kahost == NULL) { |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
2119 | kahost = g_new0(PurpleHttpKeepaliveHost, 1); |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
2120 | kahost->pool = pool; |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
2121 | kahost->host = g_strdup(host); |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
2122 | kahost->port = port; |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
2123 | kahost->is_ssl = is_ssl; |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
2124 | |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
2125 | g_hash_table_insert(pool->by_hash, g_strdup(hash), kahost); |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
2126 | } |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
2127 | |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
2128 | g_free(hash); |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
2129 | |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
2130 | req = g_new0(PurpleHttpKeepaliveRequest, 1); |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
2131 | req->gc = gc; |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
2132 | req->cb = cb; |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
2133 | req->user_data = user_data; |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
2134 | req->host = kahost; |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
2135 | |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
2136 | kahost->queue = g_slist_append(kahost->queue, req); |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
2137 | |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
2138 | purple_http_keepalive_host_process_queue(kahost); |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
2139 | |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
2140 | return req; |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
2141 | } |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
2142 | |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
2143 | static void |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
2144 | _purple_http_keepalive_socket_connected(PurpleHttpSocket *hs, |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
2145 | const gchar *error, gpointer _req) |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
2146 | { |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
2147 | PurpleHttpKeepaliveRequest *req = _req; |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
2148 | |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
2149 | if (hs != NULL) |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
2150 | hs->use_count++; |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
2151 | |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
2152 | req->cb(hs, error, req->user_data); |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
2153 | g_free(req); |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
2154 | } |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
2155 | |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
2156 | static gboolean |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
2157 | _purple_http_keepalive_host_process_queue_cb(gpointer _host) |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
2158 | { |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
2159 | PurpleHttpKeepaliveRequest *req; |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
2160 | PurpleHttpKeepaliveHost *host = _host; |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
2161 | PurpleHttpSocket *hs = NULL; |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
2162 | GSList *it; |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
2163 | int sockets_count; |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
2164 | |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
2165 | g_return_val_if_fail(host != NULL, FALSE); |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
2166 | |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
2167 | host->process_queue_timeout = 0; |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
2168 | |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
2169 | if (host->queue == NULL) |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
2170 | return FALSE; |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
2171 | |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
2172 | sockets_count = 0; |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
2173 | it = host->sockets; |
|
34260
7a55eaa31da6
HTTP: implement keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34257
diff
changeset
|
2174 | while (it != NULL) { |
|
7a55eaa31da6
HTTP: implement keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34257
diff
changeset
|
2175 | PurpleHttpSocket *hs_current = it->data; |
|
7a55eaa31da6
HTTP: implement keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34257
diff
changeset
|
2176 | |
|
34263
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
2177 | sockets_count++; |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
2178 | |
|
34260
7a55eaa31da6
HTTP: implement keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34257
diff
changeset
|
2179 | if (!hs_current->is_busy) { |
|
7a55eaa31da6
HTTP: implement keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34257
diff
changeset
|
2180 | hs = hs_current; |
|
7a55eaa31da6
HTTP: implement keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34257
diff
changeset
|
2181 | break; |
|
7a55eaa31da6
HTTP: implement keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34257
diff
changeset
|
2182 | } |
|
7a55eaa31da6
HTTP: implement keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34257
diff
changeset
|
2183 | |
|
7a55eaa31da6
HTTP: implement keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34257
diff
changeset
|
2184 | it = g_slist_next(it); |
|
7a55eaa31da6
HTTP: implement keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34257
diff
changeset
|
2185 | } |
|
7a55eaa31da6
HTTP: implement keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34257
diff
changeset
|
2186 | |
|
34263
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
2187 | /* There are no free sockets and we cannot create another one. */ |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
2188 | if (hs == NULL && sockets_count >= host->pool->limit_per_host && |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
2189 | host->pool->limit_per_host > 0) |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
2190 | { |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
2191 | return FALSE; |
|
34260
7a55eaa31da6
HTTP: implement keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34257
diff
changeset
|
2192 | } |
|
7a55eaa31da6
HTTP: implement keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34257
diff
changeset
|
2193 | |
|
34263
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
2194 | req = host->queue->data; |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
2195 | host->queue = g_slist_remove(host->queue, req); |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
2196 | |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
2197 | if (hs != NULL) { |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
2198 | if (purple_debug_is_verbose()) { |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
2199 | purple_debug_misc("http", "locking a (previously used) " |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
2200 | "socket: %p\n", hs); |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
2201 | } |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
2202 | |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
2203 | hs->is_busy = TRUE; |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
2204 | hs->use_count++; |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
2205 | |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
2206 | req->cb(hs, NULL, req->user_data); |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
2207 | g_free(req); |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
2208 | |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
2209 | return TRUE; /* run again */ |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
2210 | } |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
2211 | |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
2212 | hs = purple_http_socket_connect_new(req->gc, req->host->host, |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
2213 | req->host->port, req->host->is_ssl, |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
2214 | _purple_http_keepalive_socket_connected, req); |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
2215 | req->hs = hs; |
|
34260
7a55eaa31da6
HTTP: implement keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34257
diff
changeset
|
2216 | hs->is_busy = TRUE; |
|
34263
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
2217 | hs->host = host; |
|
34260
7a55eaa31da6
HTTP: implement keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34257
diff
changeset
|
2218 | |
|
34262
3b8ce83bac96
HTTP: get rid of one (of two) msn's own http implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34261
diff
changeset
|
2219 | if (purple_debug_is_verbose()) |
|
34263
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
2220 | purple_debug_misc("http", "locking a (new) socket: %p\n", hs); |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
2221 | |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
2222 | host->sockets = g_slist_append(host->sockets, hs); |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
2223 | |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
2224 | return FALSE; |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
2225 | } |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
2226 | |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
2227 | static void |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
2228 | purple_http_keepalive_host_process_queue(PurpleHttpKeepaliveHost *host) |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
2229 | { |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
2230 | g_return_if_fail(host != NULL); |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
2231 | |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
2232 | if (host->process_queue_timeout > 0) |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
2233 | return; |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
2234 | |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
2235 | host->process_queue_timeout = purple_timeout_add(0, |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
2236 | _purple_http_keepalive_host_process_queue_cb, host); |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
2237 | } |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
2238 | |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
2239 | static void |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
2240 | purple_http_keepalive_pool_request_cancel(PurpleHttpKeepaliveRequest *req) |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
2241 | { |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
2242 | if (req == NULL) |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
2243 | return; |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
2244 | |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
2245 | if (req->host != NULL) |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
2246 | req->host->queue = g_slist_remove(req->host->queue, req); |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
2247 | |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
2248 | if (req->hs != NULL) { |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
2249 | req->host->sockets = g_slist_remove(req->host->sockets, |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
2250 | req->hs); |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
2251 | purple_http_socket_close_free(req->hs); |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
2252 | /* req should already be free'd here */ |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
2253 | } else { |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
2254 | req->cb(req->hs, _("Cancelled"), req->user_data); |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
2255 | g_free(req); |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
2256 | } |
|
34260
7a55eaa31da6
HTTP: implement keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34257
diff
changeset
|
2257 | } |
|
7a55eaa31da6
HTTP: implement keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34257
diff
changeset
|
2258 | |
|
7a55eaa31da6
HTTP: implement keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34257
diff
changeset
|
2259 | static void |
|
7a55eaa31da6
HTTP: implement keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34257
diff
changeset
|
2260 | purple_http_keepalive_pool_release(PurpleHttpSocket *hs, gboolean invalidate) |
|
7a55eaa31da6
HTTP: implement keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34257
diff
changeset
|
2261 | { |
|
34263
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
2262 | PurpleHttpKeepaliveHost *host; |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
2263 | |
|
34260
7a55eaa31da6
HTTP: implement keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34257
diff
changeset
|
2264 | if (hs == NULL) |
|
7a55eaa31da6
HTTP: implement keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34257
diff
changeset
|
2265 | return; |
|
7a55eaa31da6
HTTP: implement keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34257
diff
changeset
|
2266 | |
|
34262
3b8ce83bac96
HTTP: get rid of one (of two) msn's own http implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34261
diff
changeset
|
2267 | if (purple_debug_is_verbose()) |
|
3b8ce83bac96
HTTP: get rid of one (of two) msn's own http implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34261
diff
changeset
|
2268 | purple_debug_misc("http", "releasing a socket: %p\n", hs); |
|
3b8ce83bac96
HTTP: get rid of one (of two) msn's own http implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34261
diff
changeset
|
2269 | |
|
34260
7a55eaa31da6
HTTP: implement keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34257
diff
changeset
|
2270 | purple_http_socket_dontwatch(hs); |
|
7a55eaa31da6
HTTP: implement keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34257
diff
changeset
|
2271 | hs->is_busy = FALSE; |
|
34263
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
2272 | host = hs->host; |
|
34260
7a55eaa31da6
HTTP: implement keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34257
diff
changeset
|
2273 | |
|
34286
8d0979967d05
HTTP: removing extra yahoo HTTP implementations - file transfer (and small improvements to libpurple http and ft code)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34272
diff
changeset
|
2274 | if (host == NULL) { |
|
8d0979967d05
HTTP: removing extra yahoo HTTP implementations - file transfer (and small improvements to libpurple http and ft code)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34272
diff
changeset
|
2275 | purple_http_socket_close_free(hs); |
|
8d0979967d05
HTTP: removing extra yahoo HTTP implementations - file transfer (and small improvements to libpurple http and ft code)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34272
diff
changeset
|
2276 | return; |
|
8d0979967d05
HTTP: removing extra yahoo HTTP implementations - file transfer (and small improvements to libpurple http and ft code)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34272
diff
changeset
|
2277 | } |
|
8d0979967d05
HTTP: removing extra yahoo HTTP implementations - file transfer (and small improvements to libpurple http and ft code)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34272
diff
changeset
|
2278 | |
|
34260
7a55eaa31da6
HTTP: implement keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34257
diff
changeset
|
2279 | if (invalidate) { |
|
34263
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
2280 | host->sockets = g_slist_remove(host->sockets, hs); |
|
34260
7a55eaa31da6
HTTP: implement keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34257
diff
changeset
|
2281 | purple_http_socket_close_free(hs); |
|
7a55eaa31da6
HTTP: implement keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34257
diff
changeset
|
2282 | } |
|
34263
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
2283 | |
|
34286
8d0979967d05
HTTP: removing extra yahoo HTTP implementations - file transfer (and small improvements to libpurple http and ft code)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34272
diff
changeset
|
2284 | purple_http_keepalive_host_process_queue(host); |
|
34263
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
2285 | } |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
2286 | |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
2287 | void |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
2288 | purple_http_keepalive_pool_set_limit_per_host(PurpleHttpKeepalivePool *pool, |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
2289 | guint limit) |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
2290 | { |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
2291 | g_return_if_fail(pool != NULL); |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
2292 | |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
2293 | pool->limit_per_host = limit; |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
2294 | } |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
2295 | |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
2296 | guint |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
2297 | purple_http_keepalive_pool_get_limit_per_host(PurpleHttpKeepalivePool *pool) |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
2298 | { |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
2299 | g_return_val_if_fail(pool != NULL, 0); |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
2300 | |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
2301 | return pool->limit_per_host; |
|
34260
7a55eaa31da6
HTTP: implement keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34257
diff
changeset
|
2302 | } |
|
7a55eaa31da6
HTTP: implement keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34257
diff
changeset
|
2303 | |
|
34268
cf61366236ee
HTTP: connections set support added; BOSH for xmpp reimplemented, to use http API instead of its own HTTP implementation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34267
diff
changeset
|
2304 | /*** HTTP connection set API **************************************************/ |
|
cf61366236ee
HTTP: connections set support added; BOSH for xmpp reimplemented, to use http API instead of its own HTTP implementation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34267
diff
changeset
|
2305 | |
|
cf61366236ee
HTTP: connections set support added; BOSH for xmpp reimplemented, to use http API instead of its own HTTP implementation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34267
diff
changeset
|
2306 | PurpleHttpConnectionSet * |
|
cf61366236ee
HTTP: connections set support added; BOSH for xmpp reimplemented, to use http API instead of its own HTTP implementation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34267
diff
changeset
|
2307 | purple_http_connection_set_new(void) |
|
cf61366236ee
HTTP: connections set support added; BOSH for xmpp reimplemented, to use http API instead of its own HTTP implementation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34267
diff
changeset
|
2308 | { |
|
cf61366236ee
HTTP: connections set support added; BOSH for xmpp reimplemented, to use http API instead of its own HTTP implementation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34267
diff
changeset
|
2309 | PurpleHttpConnectionSet *set; |
|
cf61366236ee
HTTP: connections set support added; BOSH for xmpp reimplemented, to use http API instead of its own HTTP implementation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34267
diff
changeset
|
2310 | |
|
cf61366236ee
HTTP: connections set support added; BOSH for xmpp reimplemented, to use http API instead of its own HTTP implementation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34267
diff
changeset
|
2311 | set = g_new0(PurpleHttpConnectionSet, 1); |
|
cf61366236ee
HTTP: connections set support added; BOSH for xmpp reimplemented, to use http API instead of its own HTTP implementation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34267
diff
changeset
|
2312 | set->connections = g_hash_table_new(g_direct_hash, g_direct_equal); |
|
cf61366236ee
HTTP: connections set support added; BOSH for xmpp reimplemented, to use http API instead of its own HTTP implementation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34267
diff
changeset
|
2313 | |
|
cf61366236ee
HTTP: connections set support added; BOSH for xmpp reimplemented, to use http API instead of its own HTTP implementation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34267
diff
changeset
|
2314 | return set; |
|
cf61366236ee
HTTP: connections set support added; BOSH for xmpp reimplemented, to use http API instead of its own HTTP implementation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34267
diff
changeset
|
2315 | } |
|
cf61366236ee
HTTP: connections set support added; BOSH for xmpp reimplemented, to use http API instead of its own HTTP implementation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34267
diff
changeset
|
2316 | |
|
cf61366236ee
HTTP: connections set support added; BOSH for xmpp reimplemented, to use http API instead of its own HTTP implementation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34267
diff
changeset
|
2317 | void |
|
cf61366236ee
HTTP: connections set support added; BOSH for xmpp reimplemented, to use http API instead of its own HTTP implementation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34267
diff
changeset
|
2318 | purple_http_connection_set_destroy(PurpleHttpConnectionSet *set) |
|
cf61366236ee
HTTP: connections set support added; BOSH for xmpp reimplemented, to use http API instead of its own HTTP implementation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34267
diff
changeset
|
2319 | { |
|
cf61366236ee
HTTP: connections set support added; BOSH for xmpp reimplemented, to use http API instead of its own HTTP implementation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34267
diff
changeset
|
2320 | if (set == NULL) |
|
cf61366236ee
HTTP: connections set support added; BOSH for xmpp reimplemented, to use http API instead of its own HTTP implementation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34267
diff
changeset
|
2321 | return; |
|
cf61366236ee
HTTP: connections set support added; BOSH for xmpp reimplemented, to use http API instead of its own HTTP implementation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34267
diff
changeset
|
2322 | |
|
cf61366236ee
HTTP: connections set support added; BOSH for xmpp reimplemented, to use http API instead of its own HTTP implementation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34267
diff
changeset
|
2323 | set->is_destroying = TRUE; |
|
cf61366236ee
HTTP: connections set support added; BOSH for xmpp reimplemented, to use http API instead of its own HTTP implementation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34267
diff
changeset
|
2324 | |
|
cf61366236ee
HTTP: connections set support added; BOSH for xmpp reimplemented, to use http API instead of its own HTTP implementation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34267
diff
changeset
|
2325 | while (TRUE) { |
|
cf61366236ee
HTTP: connections set support added; BOSH for xmpp reimplemented, to use http API instead of its own HTTP implementation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34267
diff
changeset
|
2326 | GHashTableIter iter; |
|
cf61366236ee
HTTP: connections set support added; BOSH for xmpp reimplemented, to use http API instead of its own HTTP implementation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34267
diff
changeset
|
2327 | PurpleHttpConnection *http_conn; |
|
cf61366236ee
HTTP: connections set support added; BOSH for xmpp reimplemented, to use http API instead of its own HTTP implementation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34267
diff
changeset
|
2328 | |
|
cf61366236ee
HTTP: connections set support added; BOSH for xmpp reimplemented, to use http API instead of its own HTTP implementation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34267
diff
changeset
|
2329 | g_hash_table_iter_init(&iter, set->connections); |
|
cf61366236ee
HTTP: connections set support added; BOSH for xmpp reimplemented, to use http API instead of its own HTTP implementation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34267
diff
changeset
|
2330 | if (!g_hash_table_iter_next(&iter, (gpointer*)&http_conn, NULL)) |
|
cf61366236ee
HTTP: connections set support added; BOSH for xmpp reimplemented, to use http API instead of its own HTTP implementation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34267
diff
changeset
|
2331 | break; |
|
cf61366236ee
HTTP: connections set support added; BOSH for xmpp reimplemented, to use http API instead of its own HTTP implementation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34267
diff
changeset
|
2332 | |
|
cf61366236ee
HTTP: connections set support added; BOSH for xmpp reimplemented, to use http API instead of its own HTTP implementation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34267
diff
changeset
|
2333 | purple_http_conn_cancel(http_conn); |
|
cf61366236ee
HTTP: connections set support added; BOSH for xmpp reimplemented, to use http API instead of its own HTTP implementation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34267
diff
changeset
|
2334 | } |
|
cf61366236ee
HTTP: connections set support added; BOSH for xmpp reimplemented, to use http API instead of its own HTTP implementation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34267
diff
changeset
|
2335 | |
|
cf61366236ee
HTTP: connections set support added; BOSH for xmpp reimplemented, to use http API instead of its own HTTP implementation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34267
diff
changeset
|
2336 | g_hash_table_destroy(set->connections); |
|
cf61366236ee
HTTP: connections set support added; BOSH for xmpp reimplemented, to use http API instead of its own HTTP implementation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34267
diff
changeset
|
2337 | g_free(set); |
|
cf61366236ee
HTTP: connections set support added; BOSH for xmpp reimplemented, to use http API instead of its own HTTP implementation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34267
diff
changeset
|
2338 | } |
|
cf61366236ee
HTTP: connections set support added; BOSH for xmpp reimplemented, to use http API instead of its own HTTP implementation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34267
diff
changeset
|
2339 | |
|
cf61366236ee
HTTP: connections set support added; BOSH for xmpp reimplemented, to use http API instead of its own HTTP implementation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34267
diff
changeset
|
2340 | void |
|
cf61366236ee
HTTP: connections set support added; BOSH for xmpp reimplemented, to use http API instead of its own HTTP implementation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34267
diff
changeset
|
2341 | purple_http_connection_set_add(PurpleHttpConnectionSet *set, |
|
cf61366236ee
HTTP: connections set support added; BOSH for xmpp reimplemented, to use http API instead of its own HTTP implementation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34267
diff
changeset
|
2342 | PurpleHttpConnection *http_conn) |
|
cf61366236ee
HTTP: connections set support added; BOSH for xmpp reimplemented, to use http API instead of its own HTTP implementation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34267
diff
changeset
|
2343 | { |
|
cf61366236ee
HTTP: connections set support added; BOSH for xmpp reimplemented, to use http API instead of its own HTTP implementation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34267
diff
changeset
|
2344 | if (set->is_destroying) |
|
cf61366236ee
HTTP: connections set support added; BOSH for xmpp reimplemented, to use http API instead of its own HTTP implementation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34267
diff
changeset
|
2345 | return; |
|
cf61366236ee
HTTP: connections set support added; BOSH for xmpp reimplemented, to use http API instead of its own HTTP implementation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34267
diff
changeset
|
2346 | if (http_conn->connection_set == set) |
|
cf61366236ee
HTTP: connections set support added; BOSH for xmpp reimplemented, to use http API instead of its own HTTP implementation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34267
diff
changeset
|
2347 | return; |
|
cf61366236ee
HTTP: connections set support added; BOSH for xmpp reimplemented, to use http API instead of its own HTTP implementation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34267
diff
changeset
|
2348 | if (http_conn->connection_set != NULL) { |
|
cf61366236ee
HTTP: connections set support added; BOSH for xmpp reimplemented, to use http API instead of its own HTTP implementation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34267
diff
changeset
|
2349 | purple_http_connection_set_remove(http_conn->connection_set, |
|
cf61366236ee
HTTP: connections set support added; BOSH for xmpp reimplemented, to use http API instead of its own HTTP implementation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34267
diff
changeset
|
2350 | http_conn); |
|
cf61366236ee
HTTP: connections set support added; BOSH for xmpp reimplemented, to use http API instead of its own HTTP implementation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34267
diff
changeset
|
2351 | } |
|
cf61366236ee
HTTP: connections set support added; BOSH for xmpp reimplemented, to use http API instead of its own HTTP implementation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34267
diff
changeset
|
2352 | g_hash_table_insert(set->connections, http_conn, (gpointer)TRUE); |
|
cf61366236ee
HTTP: connections set support added; BOSH for xmpp reimplemented, to use http API instead of its own HTTP implementation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34267
diff
changeset
|
2353 | http_conn->connection_set = set; |
|
cf61366236ee
HTTP: connections set support added; BOSH for xmpp reimplemented, to use http API instead of its own HTTP implementation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34267
diff
changeset
|
2354 | } |
|
cf61366236ee
HTTP: connections set support added; BOSH for xmpp reimplemented, to use http API instead of its own HTTP implementation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34267
diff
changeset
|
2355 | |
|
cf61366236ee
HTTP: connections set support added; BOSH for xmpp reimplemented, to use http API instead of its own HTTP implementation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34267
diff
changeset
|
2356 | static void |
|
cf61366236ee
HTTP: connections set support added; BOSH for xmpp reimplemented, to use http API instead of its own HTTP implementation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34267
diff
changeset
|
2357 | purple_http_connection_set_remove(PurpleHttpConnectionSet *set, |
|
cf61366236ee
HTTP: connections set support added; BOSH for xmpp reimplemented, to use http API instead of its own HTTP implementation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34267
diff
changeset
|
2358 | PurpleHttpConnection *http_conn) |
|
cf61366236ee
HTTP: connections set support added; BOSH for xmpp reimplemented, to use http API instead of its own HTTP implementation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34267
diff
changeset
|
2359 | { |
|
cf61366236ee
HTTP: connections set support added; BOSH for xmpp reimplemented, to use http API instead of its own HTTP implementation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34267
diff
changeset
|
2360 | g_hash_table_remove(set->connections, http_conn); |
|
cf61366236ee
HTTP: connections set support added; BOSH for xmpp reimplemented, to use http API instead of its own HTTP implementation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34267
diff
changeset
|
2361 | if (http_conn->connection_set == set) |
|
cf61366236ee
HTTP: connections set support added; BOSH for xmpp reimplemented, to use http API instead of its own HTTP implementation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34267
diff
changeset
|
2362 | http_conn->connection_set = NULL; |
|
cf61366236ee
HTTP: connections set support added; BOSH for xmpp reimplemented, to use http API instead of its own HTTP implementation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34267
diff
changeset
|
2363 | } |
|
cf61366236ee
HTTP: connections set support added; BOSH for xmpp reimplemented, to use http API instead of its own HTTP implementation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34267
diff
changeset
|
2364 | |
|
33427
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
2365 | /*** Request API **************************************************************/ |
|
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
2366 | |
|
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
2367 | static void purple_http_request_free(PurpleHttpRequest *request); |
|
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
2368 | |
|
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
2369 | PurpleHttpRequest * purple_http_request_new(const gchar *url) |
|
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
2370 | { |
|
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
2371 | PurpleHttpRequest *request; |
|
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
2372 | |
|
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
2373 | request = g_new0(PurpleHttpRequest, 1); |
|
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
2374 | |
|
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
2375 | request->ref_count = 1; |
|
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
2376 | request->url = g_strdup(url); |
|
33447
b890f231e15f
Request headers support, wrapping new API with legacy purple_util_fetch_url
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33446
diff
changeset
|
2377 | request->headers = purple_http_headers_new(); |
|
33456
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
2378 | request->cookie_jar = purple_http_cookie_jar_new(); |
|
34261
38a55c0c4e7d
HTTP: enable keep-alive by default
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34260
diff
changeset
|
2379 | request->keepalive_pool = purple_http_keepalive_pool_new(); |
|
33427
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
2380 | |
|
33450
4042907bcdf1
Timeout support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33448
diff
changeset
|
2381 | request->timeout = PURPLE_HTTP_REQUEST_DEFAULT_TIMEOUT; |
|
33444
b3afec292014
New features: http version switching and limits for redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33443
diff
changeset
|
2382 | request->max_redirects = PURPLE_HTTP_REQUEST_DEFAULT_MAX_REDIRECTS; |
|
b3afec292014
New features: http version switching and limits for redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33443
diff
changeset
|
2383 | request->http11 = TRUE; |
|
34225
3bba206f27f6
HTTP: migrate purple_util_fetch_url to new API for Pidgin UI
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34219
diff
changeset
|
2384 | request->max_length = PURPLE_HTTP_REQUEST_DEFAULT_MAX_LENGTH; |
|
33444
b3afec292014
New features: http version switching and limits for redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33443
diff
changeset
|
2385 | |
|
33427
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
2386 | return request; |
|
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
2387 | } |
|
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
2388 | |
|
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
2389 | static void purple_http_request_free(PurpleHttpRequest *request) |
|
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
2390 | { |
|
33447
b890f231e15f
Request headers support, wrapping new API with legacy purple_util_fetch_url
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33446
diff
changeset
|
2391 | purple_http_headers_free(request->headers); |
|
33456
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
2392 | purple_http_cookie_jar_unref(request->cookie_jar); |
|
34260
7a55eaa31da6
HTTP: implement keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34257
diff
changeset
|
2393 | purple_http_keepalive_pool_unref(request->keepalive_pool); |
|
33427
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
2394 | g_free(request->url); |
|
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
2395 | g_free(request); |
|
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
2396 | } |
|
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
2397 | |
|
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
2398 | void purple_http_request_ref(PurpleHttpRequest *request) |
|
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
2399 | { |
|
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
2400 | g_return_if_fail(request != NULL); |
|
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
2401 | |
|
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
2402 | request->ref_count++; |
|
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
2403 | } |
|
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
2404 | |
|
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
2405 | PurpleHttpRequest * purple_http_request_unref(PurpleHttpRequest *request) |
|
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
2406 | { |
|
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
2407 | if (request == NULL) |
|
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
2408 | return NULL; |
|
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
2409 | |
|
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
2410 | g_return_val_if_fail(request->ref_count > 0, NULL); |
|
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
2411 | |
|
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
2412 | request->ref_count--; |
|
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
2413 | if (request->ref_count > 0) |
|
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
2414 | return request; |
|
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
2415 | |
|
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
2416 | purple_http_request_free(request); |
|
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
2417 | return NULL; |
|
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
2418 | } |
|
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
2419 | |
|
33451
27d0e5dbc2a1
Implement missing getters/setters and corresponding features
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33450
diff
changeset
|
2420 | void purple_http_request_set_url(PurpleHttpRequest *request, const gchar *url) |
|
27d0e5dbc2a1
Implement missing getters/setters and corresponding features
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33450
diff
changeset
|
2421 | { |
|
27d0e5dbc2a1
Implement missing getters/setters and corresponding features
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33450
diff
changeset
|
2422 | g_return_if_fail(request != NULL); |
|
27d0e5dbc2a1
Implement missing getters/setters and corresponding features
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33450
diff
changeset
|
2423 | g_return_if_fail(url != NULL); |
|
27d0e5dbc2a1
Implement missing getters/setters and corresponding features
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33450
diff
changeset
|
2424 | |
|
27d0e5dbc2a1
Implement missing getters/setters and corresponding features
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33450
diff
changeset
|
2425 | g_free(request->url); |
|
27d0e5dbc2a1
Implement missing getters/setters and corresponding features
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33450
diff
changeset
|
2426 | request->url = g_strdup(url); |
|
27d0e5dbc2a1
Implement missing getters/setters and corresponding features
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33450
diff
changeset
|
2427 | } |
|
27d0e5dbc2a1
Implement missing getters/setters and corresponding features
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33450
diff
changeset
|
2428 | |
|
34232
a5517f235e0f
HTTP: migrate purple_util_fetch_url_request to new API for GG prpl
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34225
diff
changeset
|
2429 | void purple_http_request_set_url_printf(PurpleHttpRequest *request, |
|
a5517f235e0f
HTTP: migrate purple_util_fetch_url_request to new API for GG prpl
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34225
diff
changeset
|
2430 | const gchar *format, ...) |
|
a5517f235e0f
HTTP: migrate purple_util_fetch_url_request to new API for GG prpl
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34225
diff
changeset
|
2431 | { |
|
a5517f235e0f
HTTP: migrate purple_util_fetch_url_request to new API for GG prpl
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34225
diff
changeset
|
2432 | va_list args; |
|
a5517f235e0f
HTTP: migrate purple_util_fetch_url_request to new API for GG prpl
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34225
diff
changeset
|
2433 | gchar *value; |
|
a5517f235e0f
HTTP: migrate purple_util_fetch_url_request to new API for GG prpl
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34225
diff
changeset
|
2434 | |
|
a5517f235e0f
HTTP: migrate purple_util_fetch_url_request to new API for GG prpl
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34225
diff
changeset
|
2435 | g_return_if_fail(request != NULL); |
|
a5517f235e0f
HTTP: migrate purple_util_fetch_url_request to new API for GG prpl
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34225
diff
changeset
|
2436 | g_return_if_fail(format != NULL); |
|
a5517f235e0f
HTTP: migrate purple_util_fetch_url_request to new API for GG prpl
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34225
diff
changeset
|
2437 | |
|
a5517f235e0f
HTTP: migrate purple_util_fetch_url_request to new API for GG prpl
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34225
diff
changeset
|
2438 | va_start(args, format); |
|
a5517f235e0f
HTTP: migrate purple_util_fetch_url_request to new API for GG prpl
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34225
diff
changeset
|
2439 | value = g_strdup_vprintf(format, args); |
|
a5517f235e0f
HTTP: migrate purple_util_fetch_url_request to new API for GG prpl
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34225
diff
changeset
|
2440 | va_end(args); |
|
a5517f235e0f
HTTP: migrate purple_util_fetch_url_request to new API for GG prpl
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34225
diff
changeset
|
2441 | |
|
a5517f235e0f
HTTP: migrate purple_util_fetch_url_request to new API for GG prpl
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34225
diff
changeset
|
2442 | purple_http_request_set_url(request, value); |
|
a5517f235e0f
HTTP: migrate purple_util_fetch_url_request to new API for GG prpl
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34225
diff
changeset
|
2443 | g_free(value); |
|
a5517f235e0f
HTTP: migrate purple_util_fetch_url_request to new API for GG prpl
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34225
diff
changeset
|
2444 | } |
|
a5517f235e0f
HTTP: migrate purple_util_fetch_url_request to new API for GG prpl
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34225
diff
changeset
|
2445 | |
|
33451
27d0e5dbc2a1
Implement missing getters/setters and corresponding features
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33450
diff
changeset
|
2446 | const gchar * purple_http_request_get_url(PurpleHttpRequest *request) |
|
27d0e5dbc2a1
Implement missing getters/setters and corresponding features
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33450
diff
changeset
|
2447 | { |
|
27d0e5dbc2a1
Implement missing getters/setters and corresponding features
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33450
diff
changeset
|
2448 | g_return_val_if_fail(request != NULL, NULL); |
|
27d0e5dbc2a1
Implement missing getters/setters and corresponding features
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33450
diff
changeset
|
2449 | |
|
27d0e5dbc2a1
Implement missing getters/setters and corresponding features
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33450
diff
changeset
|
2450 | return request->url; |
|
27d0e5dbc2a1
Implement missing getters/setters and corresponding features
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33450
diff
changeset
|
2451 | } |
|
27d0e5dbc2a1
Implement missing getters/setters and corresponding features
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33450
diff
changeset
|
2452 | |
|
27d0e5dbc2a1
Implement missing getters/setters and corresponding features
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33450
diff
changeset
|
2453 | void purple_http_request_set_method(PurpleHttpRequest *request, const gchar *method) |
|
27d0e5dbc2a1
Implement missing getters/setters and corresponding features
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33450
diff
changeset
|
2454 | { |
|
27d0e5dbc2a1
Implement missing getters/setters and corresponding features
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33450
diff
changeset
|
2455 | g_return_if_fail(request != NULL); |
|
27d0e5dbc2a1
Implement missing getters/setters and corresponding features
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33450
diff
changeset
|
2456 | |
|
27d0e5dbc2a1
Implement missing getters/setters and corresponding features
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33450
diff
changeset
|
2457 | g_free(request->method); |
|
27d0e5dbc2a1
Implement missing getters/setters and corresponding features
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33450
diff
changeset
|
2458 | request->method = g_strdup(method); |
|
27d0e5dbc2a1
Implement missing getters/setters and corresponding features
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33450
diff
changeset
|
2459 | } |
|
27d0e5dbc2a1
Implement missing getters/setters and corresponding features
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33450
diff
changeset
|
2460 | |
|
27d0e5dbc2a1
Implement missing getters/setters and corresponding features
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33450
diff
changeset
|
2461 | const gchar * purple_http_request_get_method(PurpleHttpRequest *request) |
|
27d0e5dbc2a1
Implement missing getters/setters and corresponding features
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33450
diff
changeset
|
2462 | { |
|
27d0e5dbc2a1
Implement missing getters/setters and corresponding features
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33450
diff
changeset
|
2463 | g_return_val_if_fail(request != NULL, NULL); |
|
27d0e5dbc2a1
Implement missing getters/setters and corresponding features
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33450
diff
changeset
|
2464 | |
|
27d0e5dbc2a1
Implement missing getters/setters and corresponding features
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33450
diff
changeset
|
2465 | return request->method; |
|
27d0e5dbc2a1
Implement missing getters/setters and corresponding features
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33450
diff
changeset
|
2466 | } |
|
27d0e5dbc2a1
Implement missing getters/setters and corresponding features
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33450
diff
changeset
|
2467 | |
|
34232
a5517f235e0f
HTTP: migrate purple_util_fetch_url_request to new API for GG prpl
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34225
diff
changeset
|
2468 | static gboolean purple_http_request_is_method(PurpleHttpRequest *request, |
|
a5517f235e0f
HTTP: migrate purple_util_fetch_url_request to new API for GG prpl
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34225
diff
changeset
|
2469 | const gchar *method) |
|
a5517f235e0f
HTTP: migrate purple_util_fetch_url_request to new API for GG prpl
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34225
diff
changeset
|
2470 | { |
|
a5517f235e0f
HTTP: migrate purple_util_fetch_url_request to new API for GG prpl
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34225
diff
changeset
|
2471 | const gchar *rmethod; |
|
a5517f235e0f
HTTP: migrate purple_util_fetch_url_request to new API for GG prpl
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34225
diff
changeset
|
2472 | |
|
a5517f235e0f
HTTP: migrate purple_util_fetch_url_request to new API for GG prpl
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34225
diff
changeset
|
2473 | g_return_val_if_fail(request != NULL, FALSE); |
|
a5517f235e0f
HTTP: migrate purple_util_fetch_url_request to new API for GG prpl
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34225
diff
changeset
|
2474 | g_return_val_if_fail(method != NULL, FALSE); |
|
a5517f235e0f
HTTP: migrate purple_util_fetch_url_request to new API for GG prpl
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34225
diff
changeset
|
2475 | |
|
a5517f235e0f
HTTP: migrate purple_util_fetch_url_request to new API for GG prpl
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34225
diff
changeset
|
2476 | rmethod = purple_http_request_get_method(request); |
|
a5517f235e0f
HTTP: migrate purple_util_fetch_url_request to new API for GG prpl
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34225
diff
changeset
|
2477 | if (rmethod == NULL) |
|
a5517f235e0f
HTTP: migrate purple_util_fetch_url_request to new API for GG prpl
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34225
diff
changeset
|
2478 | return (g_ascii_strcasecmp(method, "get") == 0); |
|
a5517f235e0f
HTTP: migrate purple_util_fetch_url_request to new API for GG prpl
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34225
diff
changeset
|
2479 | return (g_ascii_strcasecmp(method, rmethod) == 0); |
|
a5517f235e0f
HTTP: migrate purple_util_fetch_url_request to new API for GG prpl
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34225
diff
changeset
|
2480 | } |
|
a5517f235e0f
HTTP: migrate purple_util_fetch_url_request to new API for GG prpl
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34225
diff
changeset
|
2481 | |
|
34257
935120490eb2
HTTP: isolate socket-related code in http module; initial implementation for keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34234
diff
changeset
|
2482 | void |
|
935120490eb2
HTTP: isolate socket-related code in http module; initial implementation for keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34234
diff
changeset
|
2483 | purple_http_request_set_keepalive_pool(PurpleHttpRequest *request, |
|
935120490eb2
HTTP: isolate socket-related code in http module; initial implementation for keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34234
diff
changeset
|
2484 | PurpleHttpKeepalivePool *pool) |
|
935120490eb2
HTTP: isolate socket-related code in http module; initial implementation for keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34234
diff
changeset
|
2485 | { |
|
935120490eb2
HTTP: isolate socket-related code in http module; initial implementation for keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34234
diff
changeset
|
2486 | g_return_if_fail(request != NULL); |
|
935120490eb2
HTTP: isolate socket-related code in http module; initial implementation for keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34234
diff
changeset
|
2487 | |
|
34260
7a55eaa31da6
HTTP: implement keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34257
diff
changeset
|
2488 | if (pool != NULL) |
|
7a55eaa31da6
HTTP: implement keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34257
diff
changeset
|
2489 | purple_http_keepalive_pool_ref(pool); |
|
7a55eaa31da6
HTTP: implement keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34257
diff
changeset
|
2490 | |
|
34257
935120490eb2
HTTP: isolate socket-related code in http module; initial implementation for keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34234
diff
changeset
|
2491 | if (request->keepalive_pool != NULL) { |
|
935120490eb2
HTTP: isolate socket-related code in http module; initial implementation for keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34234
diff
changeset
|
2492 | purple_http_keepalive_pool_unref(request->keepalive_pool); |
|
935120490eb2
HTTP: isolate socket-related code in http module; initial implementation for keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34234
diff
changeset
|
2493 | request->keepalive_pool = NULL; |
|
935120490eb2
HTTP: isolate socket-related code in http module; initial implementation for keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34234
diff
changeset
|
2494 | } |
|
935120490eb2
HTTP: isolate socket-related code in http module; initial implementation for keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34234
diff
changeset
|
2495 | |
|
34260
7a55eaa31da6
HTTP: implement keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34257
diff
changeset
|
2496 | if (pool != NULL) |
|
34257
935120490eb2
HTTP: isolate socket-related code in http module; initial implementation for keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34234
diff
changeset
|
2497 | request->keepalive_pool = pool; |
|
935120490eb2
HTTP: isolate socket-related code in http module; initial implementation for keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34234
diff
changeset
|
2498 | } |
|
935120490eb2
HTTP: isolate socket-related code in http module; initial implementation for keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34234
diff
changeset
|
2499 | |
|
935120490eb2
HTTP: isolate socket-related code in http module; initial implementation for keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34234
diff
changeset
|
2500 | PurpleHttpKeepalivePool * |
|
935120490eb2
HTTP: isolate socket-related code in http module; initial implementation for keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34234
diff
changeset
|
2501 | purple_http_request_get_keepalive_pool(PurpleHttpRequest *request) |
|
935120490eb2
HTTP: isolate socket-related code in http module; initial implementation for keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34234
diff
changeset
|
2502 | { |
|
935120490eb2
HTTP: isolate socket-related code in http module; initial implementation for keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34234
diff
changeset
|
2503 | g_return_val_if_fail(request != NULL, FALSE); |
|
935120490eb2
HTTP: isolate socket-related code in http module; initial implementation for keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34234
diff
changeset
|
2504 | |
|
935120490eb2
HTTP: isolate socket-related code in http module; initial implementation for keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34234
diff
changeset
|
2505 | return request->keepalive_pool; |
|
935120490eb2
HTTP: isolate socket-related code in http module; initial implementation for keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34234
diff
changeset
|
2506 | } |
|
935120490eb2
HTTP: isolate socket-related code in http module; initial implementation for keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34234
diff
changeset
|
2507 | |
|
33457
81f92a310aff
Writing request contents
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33456
diff
changeset
|
2508 | void purple_http_request_set_contents(PurpleHttpRequest *request, |
|
81f92a310aff
Writing request contents
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33456
diff
changeset
|
2509 | const gchar *contents, int length) |
|
81f92a310aff
Writing request contents
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33456
diff
changeset
|
2510 | { |
|
81f92a310aff
Writing request contents
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33456
diff
changeset
|
2511 | g_return_if_fail(request != NULL); |
|
81f92a310aff
Writing request contents
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33456
diff
changeset
|
2512 | g_return_if_fail(length >= -1); |
|
81f92a310aff
Writing request contents
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33456
diff
changeset
|
2513 | |
|
33466
918507303f45
HTTP API: PurpleHttpContentReader support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33464
diff
changeset
|
2514 | request->contents_reader = NULL; |
|
918507303f45
HTTP API: PurpleHttpContentReader support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33464
diff
changeset
|
2515 | request->contents_reader_data = NULL; |
|
918507303f45
HTTP API: PurpleHttpContentReader support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33464
diff
changeset
|
2516 | |
|
33457
81f92a310aff
Writing request contents
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33456
diff
changeset
|
2517 | g_free(request->contents); |
|
81f92a310aff
Writing request contents
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33456
diff
changeset
|
2518 | if (contents == NULL || length == 0) { |
|
81f92a310aff
Writing request contents
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33456
diff
changeset
|
2519 | request->contents = NULL; |
|
81f92a310aff
Writing request contents
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33456
diff
changeset
|
2520 | request->contents_length = 0; |
|
81f92a310aff
Writing request contents
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33456
diff
changeset
|
2521 | return; |
|
81f92a310aff
Writing request contents
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33456
diff
changeset
|
2522 | } |
|
81f92a310aff
Writing request contents
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33456
diff
changeset
|
2523 | |
|
81f92a310aff
Writing request contents
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33456
diff
changeset
|
2524 | if (length == -1) |
|
81f92a310aff
Writing request contents
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33456
diff
changeset
|
2525 | length = strlen(contents); |
|
81f92a310aff
Writing request contents
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33456
diff
changeset
|
2526 | request->contents = g_memdup(contents, length); |
|
81f92a310aff
Writing request contents
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33456
diff
changeset
|
2527 | request->contents_length = length; |
|
81f92a310aff
Writing request contents
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33456
diff
changeset
|
2528 | } |
|
81f92a310aff
Writing request contents
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33456
diff
changeset
|
2529 | |
|
33466
918507303f45
HTTP API: PurpleHttpContentReader support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33464
diff
changeset
|
2530 | void purple_http_request_set_contents_reader(PurpleHttpRequest *request, |
|
918507303f45
HTTP API: PurpleHttpContentReader support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33464
diff
changeset
|
2531 | PurpleHttpContentReader reader, int contents_length, gpointer user_data) |
|
918507303f45
HTTP API: PurpleHttpContentReader support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33464
diff
changeset
|
2532 | { |
|
918507303f45
HTTP API: PurpleHttpContentReader support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33464
diff
changeset
|
2533 | g_return_if_fail(request != NULL); |
|
918507303f45
HTTP API: PurpleHttpContentReader support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33464
diff
changeset
|
2534 | g_return_if_fail(reader != NULL); |
|
918507303f45
HTTP API: PurpleHttpContentReader support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33464
diff
changeset
|
2535 | g_return_if_fail(contents_length >= -1); |
|
918507303f45
HTTP API: PurpleHttpContentReader support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33464
diff
changeset
|
2536 | |
|
918507303f45
HTTP API: PurpleHttpContentReader support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33464
diff
changeset
|
2537 | g_free(request->contents); |
|
918507303f45
HTTP API: PurpleHttpContentReader support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33464
diff
changeset
|
2538 | request->contents = NULL; |
|
918507303f45
HTTP API: PurpleHttpContentReader support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33464
diff
changeset
|
2539 | request->contents_length = contents_length; |
|
918507303f45
HTTP API: PurpleHttpContentReader support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33464
diff
changeset
|
2540 | request->contents_reader = reader; |
|
918507303f45
HTTP API: PurpleHttpContentReader support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33464
diff
changeset
|
2541 | request->contents_reader_data = user_data; |
|
918507303f45
HTTP API: PurpleHttpContentReader support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33464
diff
changeset
|
2542 | } |
|
918507303f45
HTTP API: PurpleHttpContentReader support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33464
diff
changeset
|
2543 | |
|
33517
ddd9e37c4b07
HTTP: PurpleHttpContentWriter support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33469
diff
changeset
|
2544 | void purple_http_request_set_response_writer(PurpleHttpRequest *request, |
|
ddd9e37c4b07
HTTP: PurpleHttpContentWriter support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33469
diff
changeset
|
2545 | PurpleHttpContentWriter writer, gpointer user_data) |
|
ddd9e37c4b07
HTTP: PurpleHttpContentWriter support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33469
diff
changeset
|
2546 | { |
|
ddd9e37c4b07
HTTP: PurpleHttpContentWriter support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33469
diff
changeset
|
2547 | g_return_if_fail(request != NULL); |
|
ddd9e37c4b07
HTTP: PurpleHttpContentWriter support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33469
diff
changeset
|
2548 | |
|
ddd9e37c4b07
HTTP: PurpleHttpContentWriter support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33469
diff
changeset
|
2549 | if (writer == NULL) |
|
ddd9e37c4b07
HTTP: PurpleHttpContentWriter support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33469
diff
changeset
|
2550 | user_data = NULL; |
|
ddd9e37c4b07
HTTP: PurpleHttpContentWriter support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33469
diff
changeset
|
2551 | request->response_writer = writer; |
|
ddd9e37c4b07
HTTP: PurpleHttpContentWriter support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33469
diff
changeset
|
2552 | request->response_writer_data = user_data; |
|
ddd9e37c4b07
HTTP: PurpleHttpContentWriter support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33469
diff
changeset
|
2553 | } |
|
ddd9e37c4b07
HTTP: PurpleHttpContentWriter support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33469
diff
changeset
|
2554 | |
|
33450
4042907bcdf1
Timeout support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33448
diff
changeset
|
2555 | void purple_http_request_set_timeout(PurpleHttpRequest *request, int timeout) |
|
4042907bcdf1
Timeout support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33448
diff
changeset
|
2556 | { |
|
4042907bcdf1
Timeout support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33448
diff
changeset
|
2557 | g_return_if_fail(request != NULL); |
|
4042907bcdf1
Timeout support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33448
diff
changeset
|
2558 | |
|
4042907bcdf1
Timeout support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33448
diff
changeset
|
2559 | if (timeout < -1) |
|
4042907bcdf1
Timeout support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33448
diff
changeset
|
2560 | timeout = -1; |
|
4042907bcdf1
Timeout support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33448
diff
changeset
|
2561 | |
|
4042907bcdf1
Timeout support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33448
diff
changeset
|
2562 | request->timeout = timeout; |
|
4042907bcdf1
Timeout support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33448
diff
changeset
|
2563 | } |
|
4042907bcdf1
Timeout support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33448
diff
changeset
|
2564 | |
|
4042907bcdf1
Timeout support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33448
diff
changeset
|
2565 | int purple_http_request_get_timeout(PurpleHttpRequest *request) |
|
4042907bcdf1
Timeout support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33448
diff
changeset
|
2566 | { |
|
4042907bcdf1
Timeout support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33448
diff
changeset
|
2567 | g_return_val_if_fail(request != NULL, -1); |
|
4042907bcdf1
Timeout support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33448
diff
changeset
|
2568 | |
|
4042907bcdf1
Timeout support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33448
diff
changeset
|
2569 | return request->timeout; |
|
4042907bcdf1
Timeout support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33448
diff
changeset
|
2570 | } |
|
4042907bcdf1
Timeout support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33448
diff
changeset
|
2571 | |
|
33444
b3afec292014
New features: http version switching and limits for redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33443
diff
changeset
|
2572 | void purple_http_request_set_max_redirects(PurpleHttpRequest *request, |
|
b3afec292014
New features: http version switching and limits for redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33443
diff
changeset
|
2573 | int max_redirects) |
|
b3afec292014
New features: http version switching and limits for redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33443
diff
changeset
|
2574 | { |
|
b3afec292014
New features: http version switching and limits for redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33443
diff
changeset
|
2575 | g_return_if_fail(request != NULL); |
|
b3afec292014
New features: http version switching and limits for redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33443
diff
changeset
|
2576 | |
|
b3afec292014
New features: http version switching and limits for redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33443
diff
changeset
|
2577 | if (max_redirects < -1) |
|
b3afec292014
New features: http version switching and limits for redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33443
diff
changeset
|
2578 | max_redirects = -1; |
|
b3afec292014
New features: http version switching and limits for redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33443
diff
changeset
|
2579 | |
|
b3afec292014
New features: http version switching and limits for redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33443
diff
changeset
|
2580 | request->max_redirects = max_redirects; |
|
b3afec292014
New features: http version switching and limits for redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33443
diff
changeset
|
2581 | } |
|
b3afec292014
New features: http version switching and limits for redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33443
diff
changeset
|
2582 | |
|
b3afec292014
New features: http version switching and limits for redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33443
diff
changeset
|
2583 | int purple_http_request_get_max_redirects(PurpleHttpRequest *request) |
|
b3afec292014
New features: http version switching and limits for redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33443
diff
changeset
|
2584 | { |
|
b3afec292014
New features: http version switching and limits for redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33443
diff
changeset
|
2585 | g_return_val_if_fail(request != NULL, -1); |
|
b3afec292014
New features: http version switching and limits for redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33443
diff
changeset
|
2586 | |
|
b3afec292014
New features: http version switching and limits for redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33443
diff
changeset
|
2587 | return request->max_redirects; |
|
b3afec292014
New features: http version switching and limits for redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33443
diff
changeset
|
2588 | } |
|
b3afec292014
New features: http version switching and limits for redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33443
diff
changeset
|
2589 | |
|
33456
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
2590 | void purple_http_request_set_cookie_jar(PurpleHttpRequest *request, |
|
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
2591 | PurpleHttpCookieJar *cookie_jar) |
|
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
2592 | { |
|
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
2593 | g_return_if_fail(request != NULL); |
|
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
2594 | g_return_if_fail(cookie_jar != NULL); |
|
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
2595 | |
|
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
2596 | purple_http_cookie_jar_ref(cookie_jar); |
|
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
2597 | purple_http_cookie_jar_unref(request->cookie_jar); |
|
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
2598 | request->cookie_jar = cookie_jar; |
|
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
2599 | } |
|
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
2600 | |
|
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
2601 | PurpleHttpCookieJar * purple_http_request_get_cookie_jar( |
|
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
2602 | PurpleHttpRequest *request) |
|
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
2603 | { |
|
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
2604 | g_return_val_if_fail(request != NULL, NULL); |
|
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
2605 | |
|
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
2606 | return request->cookie_jar; |
|
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
2607 | } |
|
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
2608 | |
|
33444
b3afec292014
New features: http version switching and limits for redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33443
diff
changeset
|
2609 | void purple_http_request_set_http11(PurpleHttpRequest *request, gboolean http11) |
|
b3afec292014
New features: http version switching and limits for redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33443
diff
changeset
|
2610 | { |
|
b3afec292014
New features: http version switching and limits for redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33443
diff
changeset
|
2611 | g_return_if_fail(request != NULL); |
|
b3afec292014
New features: http version switching and limits for redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33443
diff
changeset
|
2612 | |
|
b3afec292014
New features: http version switching and limits for redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33443
diff
changeset
|
2613 | request->http11 = http11; |
|
b3afec292014
New features: http version switching and limits for redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33443
diff
changeset
|
2614 | } |
|
b3afec292014
New features: http version switching and limits for redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33443
diff
changeset
|
2615 | |
|
b3afec292014
New features: http version switching and limits for redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33443
diff
changeset
|
2616 | gboolean purple_http_request_is_http11(PurpleHttpRequest *request) |
|
b3afec292014
New features: http version switching and limits for redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33443
diff
changeset
|
2617 | { |
|
b3afec292014
New features: http version switching and limits for redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33443
diff
changeset
|
2618 | g_return_val_if_fail(request != NULL, FALSE); |
|
b3afec292014
New features: http version switching and limits for redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33443
diff
changeset
|
2619 | |
|
b3afec292014
New features: http version switching and limits for redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33443
diff
changeset
|
2620 | return request->http11; |
|
b3afec292014
New features: http version switching and limits for redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33443
diff
changeset
|
2621 | } |
|
b3afec292014
New features: http version switching and limits for redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33443
diff
changeset
|
2622 | |
|
33446
95fda782966c
New feature: setting maximum length of response
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33445
diff
changeset
|
2623 | void purple_http_request_set_max_len(PurpleHttpRequest *request, int max_len) |
|
95fda782966c
New feature: setting maximum length of response
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33445
diff
changeset
|
2624 | { |
|
95fda782966c
New feature: setting maximum length of response
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33445
diff
changeset
|
2625 | g_return_if_fail(request != NULL); |
|
95fda782966c
New feature: setting maximum length of response
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33445
diff
changeset
|
2626 | |
|
95fda782966c
New feature: setting maximum length of response
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33445
diff
changeset
|
2627 | if (max_len < -1) |
|
95fda782966c
New feature: setting maximum length of response
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33445
diff
changeset
|
2628 | max_len = -1; |
|
95fda782966c
New feature: setting maximum length of response
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33445
diff
changeset
|
2629 | |
|
95fda782966c
New feature: setting maximum length of response
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33445
diff
changeset
|
2630 | request->max_length = max_len; |
|
95fda782966c
New feature: setting maximum length of response
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33445
diff
changeset
|
2631 | } |
|
95fda782966c
New feature: setting maximum length of response
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33445
diff
changeset
|
2632 | |
|
95fda782966c
New feature: setting maximum length of response
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33445
diff
changeset
|
2633 | int purple_http_request_get_max_len(PurpleHttpRequest *request) |
|
95fda782966c
New feature: setting maximum length of response
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33445
diff
changeset
|
2634 | { |
|
95fda782966c
New feature: setting maximum length of response
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33445
diff
changeset
|
2635 | g_return_val_if_fail(request != NULL, -1); |
|
95fda782966c
New feature: setting maximum length of response
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33445
diff
changeset
|
2636 | |
|
95fda782966c
New feature: setting maximum length of response
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33445
diff
changeset
|
2637 | return request->max_length; |
|
95fda782966c
New feature: setting maximum length of response
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33445
diff
changeset
|
2638 | } |
|
95fda782966c
New feature: setting maximum length of response
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33445
diff
changeset
|
2639 | |
|
33447
b890f231e15f
Request headers support, wrapping new API with legacy purple_util_fetch_url
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33446
diff
changeset
|
2640 | void purple_http_request_header_set(PurpleHttpRequest *request, |
|
b890f231e15f
Request headers support, wrapping new API with legacy purple_util_fetch_url
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33446
diff
changeset
|
2641 | const gchar *key, const gchar *value) |
|
b890f231e15f
Request headers support, wrapping new API with legacy purple_util_fetch_url
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33446
diff
changeset
|
2642 | { |
|
b890f231e15f
Request headers support, wrapping new API with legacy purple_util_fetch_url
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33446
diff
changeset
|
2643 | g_return_if_fail(request != NULL); |
|
b890f231e15f
Request headers support, wrapping new API with legacy purple_util_fetch_url
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33446
diff
changeset
|
2644 | g_return_if_fail(key != NULL); |
|
b890f231e15f
Request headers support, wrapping new API with legacy purple_util_fetch_url
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33446
diff
changeset
|
2645 | |
|
b890f231e15f
Request headers support, wrapping new API with legacy purple_util_fetch_url
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33446
diff
changeset
|
2646 | purple_http_headers_remove(request->headers, key); |
|
b890f231e15f
Request headers support, wrapping new API with legacy purple_util_fetch_url
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33446
diff
changeset
|
2647 | if (value) |
|
b890f231e15f
Request headers support, wrapping new API with legacy purple_util_fetch_url
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33446
diff
changeset
|
2648 | purple_http_headers_add(request->headers, key, value); |
|
b890f231e15f
Request headers support, wrapping new API with legacy purple_util_fetch_url
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33446
diff
changeset
|
2649 | } |
|
b890f231e15f
Request headers support, wrapping new API with legacy purple_util_fetch_url
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33446
diff
changeset
|
2650 | |
|
33455
2de654702970
Print-like setting headers, vestigal keepalive support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33454
diff
changeset
|
2651 | void purple_http_request_header_set_printf(PurpleHttpRequest *request, |
|
2de654702970
Print-like setting headers, vestigal keepalive support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33454
diff
changeset
|
2652 | const gchar *key, const gchar *format, ...) |
|
2de654702970
Print-like setting headers, vestigal keepalive support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33454
diff
changeset
|
2653 | { |
|
2de654702970
Print-like setting headers, vestigal keepalive support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33454
diff
changeset
|
2654 | va_list args; |
|
2de654702970
Print-like setting headers, vestigal keepalive support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33454
diff
changeset
|
2655 | gchar *value; |
|
2de654702970
Print-like setting headers, vestigal keepalive support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33454
diff
changeset
|
2656 | |
|
2de654702970
Print-like setting headers, vestigal keepalive support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33454
diff
changeset
|
2657 | g_return_if_fail(request != NULL); |
|
2de654702970
Print-like setting headers, vestigal keepalive support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33454
diff
changeset
|
2658 | g_return_if_fail(key != NULL); |
|
2de654702970
Print-like setting headers, vestigal keepalive support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33454
diff
changeset
|
2659 | g_return_if_fail(format != NULL); |
|
2de654702970
Print-like setting headers, vestigal keepalive support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33454
diff
changeset
|
2660 | |
|
2de654702970
Print-like setting headers, vestigal keepalive support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33454
diff
changeset
|
2661 | va_start(args, format); |
|
2de654702970
Print-like setting headers, vestigal keepalive support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33454
diff
changeset
|
2662 | value = g_strdup_vprintf(format, args); |
|
2de654702970
Print-like setting headers, vestigal keepalive support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33454
diff
changeset
|
2663 | va_end(args); |
|
2de654702970
Print-like setting headers, vestigal keepalive support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33454
diff
changeset
|
2664 | |
|
2de654702970
Print-like setting headers, vestigal keepalive support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33454
diff
changeset
|
2665 | purple_http_request_header_set(request, key, value); |
|
2de654702970
Print-like setting headers, vestigal keepalive support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33454
diff
changeset
|
2666 | g_free(value); |
|
2de654702970
Print-like setting headers, vestigal keepalive support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33454
diff
changeset
|
2667 | } |
|
2de654702970
Print-like setting headers, vestigal keepalive support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33454
diff
changeset
|
2668 | |
|
33447
b890f231e15f
Request headers support, wrapping new API with legacy purple_util_fetch_url
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33446
diff
changeset
|
2669 | void purple_http_request_header_add(PurpleHttpRequest *request, |
|
b890f231e15f
Request headers support, wrapping new API with legacy purple_util_fetch_url
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33446
diff
changeset
|
2670 | const gchar *key, const gchar *value) |
|
b890f231e15f
Request headers support, wrapping new API with legacy purple_util_fetch_url
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33446
diff
changeset
|
2671 | { |
|
b890f231e15f
Request headers support, wrapping new API with legacy purple_util_fetch_url
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33446
diff
changeset
|
2672 | g_return_if_fail(request != NULL); |
|
b890f231e15f
Request headers support, wrapping new API with legacy purple_util_fetch_url
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33446
diff
changeset
|
2673 | g_return_if_fail(key != NULL); |
|
b890f231e15f
Request headers support, wrapping new API with legacy purple_util_fetch_url
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33446
diff
changeset
|
2674 | |
|
b890f231e15f
Request headers support, wrapping new API with legacy purple_util_fetch_url
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33446
diff
changeset
|
2675 | purple_http_headers_add(request->headers, key, value); |
|
b890f231e15f
Request headers support, wrapping new API with legacy purple_util_fetch_url
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33446
diff
changeset
|
2676 | } |
|
b890f231e15f
Request headers support, wrapping new API with legacy purple_util_fetch_url
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33446
diff
changeset
|
2677 | |
|
33427
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
2678 | /*** HTTP response API ********************************************************/ |
|
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
2679 | |
|
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
2680 | static PurpleHttpResponse * purple_http_response_new(void) |
|
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
2681 | { |
|
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
2682 | PurpleHttpResponse *response = g_new0(PurpleHttpResponse, 1); |
|
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
2683 | |
|
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
2684 | return response; |
|
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
2685 | } |
|
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
2686 | |
|
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
2687 | static void purple_http_response_free(PurpleHttpResponse *response) |
|
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
2688 | { |
|
33433
fb7ac52ed7df
Let's get response contents
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33432
diff
changeset
|
2689 | if (response->contents != NULL) |
|
fb7ac52ed7df
Let's get response contents
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33432
diff
changeset
|
2690 | g_string_free(response->contents, TRUE); |
|
33430
013c5aebb665
Let's connect
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33429
diff
changeset
|
2691 | g_free(response->error); |
|
33432
9c4acb75b2e6
Let's parse response headers
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33431
diff
changeset
|
2692 | purple_http_headers_free(response->headers); |
|
33427
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
2693 | g_free(response); |
|
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
2694 | } |
|
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
2695 | |
|
34287
6cd0c77b1f6a
HTTP: successful is spelled with one l
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34286
diff
changeset
|
2696 | gboolean purple_http_response_is_successful(PurpleHttpResponse *response) |
|
33427
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
2697 | { |
|
33432
9c4acb75b2e6
Let's parse response headers
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33431
diff
changeset
|
2698 | int code; |
|
9c4acb75b2e6
Let's parse response headers
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33431
diff
changeset
|
2699 | |
|
33427
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
2700 | g_return_val_if_fail(response != NULL, FALSE); |
|
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
2701 | |
|
33432
9c4acb75b2e6
Let's parse response headers
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33431
diff
changeset
|
2702 | code = response->code; |
|
9c4acb75b2e6
Let's parse response headers
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33431
diff
changeset
|
2703 | |
|
9c4acb75b2e6
Let's parse response headers
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33431
diff
changeset
|
2704 | if (code <= 0) |
|
9c4acb75b2e6
Let's parse response headers
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33431
diff
changeset
|
2705 | return FALSE; |
|
9c4acb75b2e6
Let's parse response headers
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33431
diff
changeset
|
2706 | |
|
34262
3b8ce83bac96
HTTP: get rid of one (of two) msn's own http implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34261
diff
changeset
|
2707 | /* TODO: HTTP/1.1 100 Continue */ |
|
3b8ce83bac96
HTTP: get rid of one (of two) msn's own http implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34261
diff
changeset
|
2708 | |
|
33458
59b3364f690e
Sending cookies
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33457
diff
changeset
|
2709 | if (code / 100 == 2) |
|
33432
9c4acb75b2e6
Let's parse response headers
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33431
diff
changeset
|
2710 | return TRUE; |
|
9c4acb75b2e6
Let's parse response headers
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33431
diff
changeset
|
2711 | |
|
9c4acb75b2e6
Let's parse response headers
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33431
diff
changeset
|
2712 | return FALSE; |
|
33427
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
2713 | } |
|
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
2714 | |
|
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
2715 | int purple_http_response_get_code(PurpleHttpResponse *response) |
|
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
2716 | { |
|
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
2717 | g_return_val_if_fail(response != NULL, 0); |
|
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
2718 | |
|
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
2719 | return response->code; |
|
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
2720 | } |
|
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
2721 | |
|
33430
013c5aebb665
Let's connect
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33429
diff
changeset
|
2722 | const gchar * purple_http_response_get_error(PurpleHttpResponse *response) |
|
013c5aebb665
Let's connect
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33429
diff
changeset
|
2723 | { |
|
013c5aebb665
Let's connect
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33429
diff
changeset
|
2724 | g_return_val_if_fail(response != NULL, NULL); |
|
013c5aebb665
Let's connect
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33429
diff
changeset
|
2725 | |
|
34234
bb56b6121733
HTTP: migrate purple_util_fetch_url_request to new API for yahoo prpl (login process)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34233
diff
changeset
|
2726 | if (response->error != NULL) |
|
bb56b6121733
HTTP: migrate purple_util_fetch_url_request to new API for yahoo prpl (login process)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34233
diff
changeset
|
2727 | return response->error; |
|
bb56b6121733
HTTP: migrate purple_util_fetch_url_request to new API for yahoo prpl (login process)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34233
diff
changeset
|
2728 | |
|
34287
6cd0c77b1f6a
HTTP: successful is spelled with one l
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34286
diff
changeset
|
2729 | if (!purple_http_response_is_successful(response)) { |
|
34234
bb56b6121733
HTTP: migrate purple_util_fetch_url_request to new API for yahoo prpl (login process)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34233
diff
changeset
|
2730 | static gchar errmsg[200]; |
|
bb56b6121733
HTTP: migrate purple_util_fetch_url_request to new API for yahoo prpl (login process)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34233
diff
changeset
|
2731 | if (response->code <= 0) { |
|
bb56b6121733
HTTP: migrate purple_util_fetch_url_request to new API for yahoo prpl (login process)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34233
diff
changeset
|
2732 | g_snprintf(errmsg, sizeof(errmsg), |
|
bb56b6121733
HTTP: migrate purple_util_fetch_url_request to new API for yahoo prpl (login process)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34233
diff
changeset
|
2733 | _("Unknown HTTP error")); |
|
bb56b6121733
HTTP: migrate purple_util_fetch_url_request to new API for yahoo prpl (login process)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34233
diff
changeset
|
2734 | } else { |
|
bb56b6121733
HTTP: migrate purple_util_fetch_url_request to new API for yahoo prpl (login process)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34233
diff
changeset
|
2735 | g_snprintf(errmsg, sizeof(errmsg), |
|
bb56b6121733
HTTP: migrate purple_util_fetch_url_request to new API for yahoo prpl (login process)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34233
diff
changeset
|
2736 | _("Invalid HTTP response code (%d)"), |
|
bb56b6121733
HTTP: migrate purple_util_fetch_url_request to new API for yahoo prpl (login process)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34233
diff
changeset
|
2737 | response->code); |
|
bb56b6121733
HTTP: migrate purple_util_fetch_url_request to new API for yahoo prpl (login process)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34233
diff
changeset
|
2738 | } |
|
bb56b6121733
HTTP: migrate purple_util_fetch_url_request to new API for yahoo prpl (login process)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34233
diff
changeset
|
2739 | return errmsg; |
|
bb56b6121733
HTTP: migrate purple_util_fetch_url_request to new API for yahoo prpl (login process)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34233
diff
changeset
|
2740 | } |
|
bb56b6121733
HTTP: migrate purple_util_fetch_url_request to new API for yahoo prpl (login process)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34233
diff
changeset
|
2741 | |
|
bb56b6121733
HTTP: migrate purple_util_fetch_url_request to new API for yahoo prpl (login process)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34233
diff
changeset
|
2742 | return NULL; |
|
33430
013c5aebb665
Let's connect
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33429
diff
changeset
|
2743 | } |
|
013c5aebb665
Let's connect
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33429
diff
changeset
|
2744 | |
|
33427
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
2745 | gsize purple_http_response_get_data_len(PurpleHttpResponse *response) |
|
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
2746 | { |
|
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
2747 | g_return_val_if_fail(response != NULL, 0); |
|
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
2748 | |
|
33433
fb7ac52ed7df
Let's get response contents
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33432
diff
changeset
|
2749 | if (response->contents == NULL) |
|
fb7ac52ed7df
Let's get response contents
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33432
diff
changeset
|
2750 | return 0; |
|
fb7ac52ed7df
Let's get response contents
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33432
diff
changeset
|
2751 | |
|
fb7ac52ed7df
Let's get response contents
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33432
diff
changeset
|
2752 | return response->contents->len; |
|
33427
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
2753 | } |
|
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
2754 | |
|
33626
2522d124d883
update purple_http_response_get_data to take a second parameter that is a return address for the size of the data
Gary Kramlich <grim@reaperworld.com>
parents:
33522
diff
changeset
|
2755 | const gchar * purple_http_response_get_data(PurpleHttpResponse *response, size_t *len) |
|
33427
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
2756 | { |
|
33626
2522d124d883
update purple_http_response_get_data to take a second parameter that is a return address for the size of the data
Gary Kramlich <grim@reaperworld.com>
parents:
33522
diff
changeset
|
2757 | const gchar *ret = ""; |
|
2522d124d883
update purple_http_response_get_data to take a second parameter that is a return address for the size of the data
Gary Kramlich <grim@reaperworld.com>
parents:
33522
diff
changeset
|
2758 | |
|
34232
a5517f235e0f
HTTP: migrate purple_util_fetch_url_request to new API for GG prpl
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34225
diff
changeset
|
2759 | g_return_val_if_fail(response != NULL, ""); |
|
33427
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
2760 | |
|
33626
2522d124d883
update purple_http_response_get_data to take a second parameter that is a return address for the size of the data
Gary Kramlich <grim@reaperworld.com>
parents:
33522
diff
changeset
|
2761 | if (response->contents != NULL) { |
|
2522d124d883
update purple_http_response_get_data to take a second parameter that is a return address for the size of the data
Gary Kramlich <grim@reaperworld.com>
parents:
33522
diff
changeset
|
2762 | ret = response->contents->str; |
|
2522d124d883
update purple_http_response_get_data to take a second parameter that is a return address for the size of the data
Gary Kramlich <grim@reaperworld.com>
parents:
33522
diff
changeset
|
2763 | if(len) |
|
2522d124d883
update purple_http_response_get_data to take a second parameter that is a return address for the size of the data
Gary Kramlich <grim@reaperworld.com>
parents:
33522
diff
changeset
|
2764 | *len = response->contents->len; |
|
2522d124d883
update purple_http_response_get_data to take a second parameter that is a return address for the size of the data
Gary Kramlich <grim@reaperworld.com>
parents:
33522
diff
changeset
|
2765 | } else { |
|
2522d124d883
update purple_http_response_get_data to take a second parameter that is a return address for the size of the data
Gary Kramlich <grim@reaperworld.com>
parents:
33522
diff
changeset
|
2766 | if(len) |
|
2522d124d883
update purple_http_response_get_data to take a second parameter that is a return address for the size of the data
Gary Kramlich <grim@reaperworld.com>
parents:
33522
diff
changeset
|
2767 | *len = 0; |
|
2522d124d883
update purple_http_response_get_data to take a second parameter that is a return address for the size of the data
Gary Kramlich <grim@reaperworld.com>
parents:
33522
diff
changeset
|
2768 | } |
|
2522d124d883
update purple_http_response_get_data to take a second parameter that is a return address for the size of the data
Gary Kramlich <grim@reaperworld.com>
parents:
33522
diff
changeset
|
2769 | |
|
2522d124d883
update purple_http_response_get_data to take a second parameter that is a return address for the size of the data
Gary Kramlich <grim@reaperworld.com>
parents:
33522
diff
changeset
|
2770 | return ret; |
|
33427
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
2771 | } |
|
33429
1ce1faf4e675
Extend URL parsing
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33427
diff
changeset
|
2772 | |
|
33451
27d0e5dbc2a1
Implement missing getters/setters and corresponding features
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33450
diff
changeset
|
2773 | const GList * purple_http_response_get_all_headers(PurpleHttpResponse *response) |
|
27d0e5dbc2a1
Implement missing getters/setters and corresponding features
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33450
diff
changeset
|
2774 | { |
|
27d0e5dbc2a1
Implement missing getters/setters and corresponding features
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33450
diff
changeset
|
2775 | g_return_val_if_fail(response != NULL, NULL); |
|
27d0e5dbc2a1
Implement missing getters/setters and corresponding features
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33450
diff
changeset
|
2776 | |
|
27d0e5dbc2a1
Implement missing getters/setters and corresponding features
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33450
diff
changeset
|
2777 | return purple_http_headers_get_all(response->headers); |
|
27d0e5dbc2a1
Implement missing getters/setters and corresponding features
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33450
diff
changeset
|
2778 | } |
|
27d0e5dbc2a1
Implement missing getters/setters and corresponding features
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33450
diff
changeset
|
2779 | |
|
27d0e5dbc2a1
Implement missing getters/setters and corresponding features
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33450
diff
changeset
|
2780 | const GList * purple_http_response_get_headers_by_name( |
|
27d0e5dbc2a1
Implement missing getters/setters and corresponding features
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33450
diff
changeset
|
2781 | PurpleHttpResponse *response, const gchar *name) |
|
27d0e5dbc2a1
Implement missing getters/setters and corresponding features
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33450
diff
changeset
|
2782 | { |
|
27d0e5dbc2a1
Implement missing getters/setters and corresponding features
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33450
diff
changeset
|
2783 | g_return_val_if_fail(response != NULL, NULL); |
|
27d0e5dbc2a1
Implement missing getters/setters and corresponding features
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33450
diff
changeset
|
2784 | g_return_val_if_fail(name != NULL, NULL); |
|
27d0e5dbc2a1
Implement missing getters/setters and corresponding features
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33450
diff
changeset
|
2785 | |
|
27d0e5dbc2a1
Implement missing getters/setters and corresponding features
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33450
diff
changeset
|
2786 | return purple_http_headers_get_all_by_name(response->headers, name); |
|
27d0e5dbc2a1
Implement missing getters/setters and corresponding features
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33450
diff
changeset
|
2787 | } |
|
27d0e5dbc2a1
Implement missing getters/setters and corresponding features
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33450
diff
changeset
|
2788 | |
|
27d0e5dbc2a1
Implement missing getters/setters and corresponding features
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33450
diff
changeset
|
2789 | const gchar * purple_http_response_get_header(PurpleHttpResponse *response, |
|
27d0e5dbc2a1
Implement missing getters/setters and corresponding features
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33450
diff
changeset
|
2790 | const gchar *name) |
|
27d0e5dbc2a1
Implement missing getters/setters and corresponding features
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33450
diff
changeset
|
2791 | { |
|
27d0e5dbc2a1
Implement missing getters/setters and corresponding features
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33450
diff
changeset
|
2792 | g_return_val_if_fail(response != NULL, NULL); |
|
27d0e5dbc2a1
Implement missing getters/setters and corresponding features
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33450
diff
changeset
|
2793 | g_return_val_if_fail(name != NULL, NULL); |
|
27d0e5dbc2a1
Implement missing getters/setters and corresponding features
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33450
diff
changeset
|
2794 | |
|
27d0e5dbc2a1
Implement missing getters/setters and corresponding features
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33450
diff
changeset
|
2795 | return purple_http_headers_get(response->headers, name); |
|
27d0e5dbc2a1
Implement missing getters/setters and corresponding features
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33450
diff
changeset
|
2796 | } |
|
27d0e5dbc2a1
Implement missing getters/setters and corresponding features
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33450
diff
changeset
|
2797 | |
|
33429
1ce1faf4e675
Extend URL parsing
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33427
diff
changeset
|
2798 | /*** URL functions ************************************************************/ |
|
1ce1faf4e675
Extend URL parsing
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33427
diff
changeset
|
2799 | |
|
34218
de45cb0670a5
HTTP: make purple_url_parse deprecated in favor of purple_http_url_parse
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33868
diff
changeset
|
2800 | PurpleHttpURL * |
|
de45cb0670a5
HTTP: make purple_url_parse deprecated in favor of purple_http_url_parse
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33868
diff
changeset
|
2801 | purple_http_url_parse(const char *raw_url) |
|
33429
1ce1faf4e675
Extend URL parsing
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33427
diff
changeset
|
2802 | { |
|
33439
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
2803 | PurpleHttpURL *url; |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
2804 | GMatchInfo *match_info; |
|
33429
1ce1faf4e675
Extend URL parsing
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33427
diff
changeset
|
2805 | |
|
33439
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
2806 | gchar *host_full, *tmp; |
|
33429
1ce1faf4e675
Extend URL parsing
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33427
diff
changeset
|
2807 | |
|
33439
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
2808 | g_return_val_if_fail(raw_url != NULL, NULL); |
|
33429
1ce1faf4e675
Extend URL parsing
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33427
diff
changeset
|
2809 | |
|
33439
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
2810 | url = g_new0(PurpleHttpURL, 1); |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
2811 | |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
2812 | if (!g_regex_match(purple_http_re_url, raw_url, 0, &match_info)) { |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
2813 | if (purple_debug_is_verbose() && purple_debug_is_unsafe()) { |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
2814 | purple_debug_warning("http", |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
2815 | "Invalid URL provided: %s\n", |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
2816 | raw_url); |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
2817 | } |
|
33429
1ce1faf4e675
Extend URL parsing
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33427
diff
changeset
|
2818 | return NULL; |
|
1ce1faf4e675
Extend URL parsing
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33427
diff
changeset
|
2819 | } |
|
1ce1faf4e675
Extend URL parsing
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33427
diff
changeset
|
2820 | |
|
33439
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
2821 | url->protocol = g_match_info_fetch(match_info, 1); |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
2822 | host_full = g_match_info_fetch(match_info, 2); |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
2823 | url->path = g_match_info_fetch(match_info, 3); |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
2824 | url->fragment = g_match_info_fetch(match_info, 4); |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
2825 | g_match_info_free(match_info); |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
2826 | |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
2827 | if (url->protocol[0] == '\0') { |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
2828 | g_free(url->protocol); |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
2829 | url->protocol = NULL; |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
2830 | } else if (url->protocol != NULL) { |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
2831 | tmp = url->protocol; |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
2832 | url->protocol = g_ascii_strdown(url->protocol, -1); |
|
33431
704de181d1d2
Let's request
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33430
diff
changeset
|
2833 | g_free(tmp); |
|
704de181d1d2
Let's request
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33430
diff
changeset
|
2834 | } |
|
33439
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
2835 | if (host_full[0] == '\0') { |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
2836 | g_free(host_full); |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
2837 | host_full = NULL; |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
2838 | } |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
2839 | if (url->path[0] == '\0') { |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
2840 | g_free(url->path); |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
2841 | url->path = NULL; |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
2842 | } |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
2843 | if ((url->protocol == NULL) != (host_full == NULL)) |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
2844 | purple_debug_warning("http", "Protocol or host not present " |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
2845 | "(unlikely case)\n"); |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
2846 | |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
2847 | if (host_full) { |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
2848 | gchar *port_str; |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
2849 | |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
2850 | if (!g_regex_match(purple_http_re_url_host, host_full, 0, |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
2851 | &match_info)) { |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
2852 | if (purple_debug_is_verbose() && |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
2853 | purple_debug_is_unsafe()) { |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
2854 | purple_debug_warning("http", |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
2855 | "Invalid host provided for URL: %s\n", |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
2856 | raw_url); |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
2857 | } |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
2858 | |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
2859 | g_free(host_full); |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
2860 | purple_http_url_free(url); |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
2861 | return NULL; |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
2862 | } |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
2863 | |
|
34219
eee308def583
HTTP: get rid of purple_url_parse
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34218
diff
changeset
|
2864 | url->username = g_match_info_fetch(match_info, 1); |
|
33439
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
2865 | url->password = g_match_info_fetch(match_info, 2); |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
2866 | url->host = g_match_info_fetch(match_info, 3); |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
2867 | port_str = g_match_info_fetch(match_info, 4); |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
2868 | |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
2869 | if (port_str && port_str[0]) |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
2870 | url->port = atoi(port_str); |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
2871 | |
|
34219
eee308def583
HTTP: get rid of purple_url_parse
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34218
diff
changeset
|
2872 | if (url->username[0] == '\0') { |
|
eee308def583
HTTP: get rid of purple_url_parse
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34218
diff
changeset
|
2873 | g_free(url->username); |
|
eee308def583
HTTP: get rid of purple_url_parse
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34218
diff
changeset
|
2874 | url->username = NULL; |
|
33439
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
2875 | } |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
2876 | if (url->password[0] == '\0') { |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
2877 | g_free(url->password); |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
2878 | url->password = NULL; |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
2879 | } |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
2880 | if (url->host[0] == '\0') { |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
2881 | g_free(url->host); |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
2882 | url->host = NULL; |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
2883 | } else if (url->host != NULL) { |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
2884 | tmp = url->host; |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
2885 | url->host = g_ascii_strdown(url->host, -1); |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
2886 | g_free(tmp); |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
2887 | } |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
2888 | |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
2889 | g_free(port_str); |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
2890 | g_match_info_free(match_info); |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
2891 | |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
2892 | g_free(host_full); |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
2893 | host_full = NULL; |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
2894 | } |
|
33431
704de181d1d2
Let's request
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33430
diff
changeset
|
2895 | |
|
33439
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
2896 | if (url->host != NULL) { |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
2897 | if (url->protocol == NULL) |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
2898 | url->protocol = g_strdup("http"); |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
2899 | if (url->port == 0 && 0 == strcmp(url->protocol, "http")) |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
2900 | url->port = 80; |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
2901 | if (url->port == 0 && 0 == strcmp(url->protocol, "https")) |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
2902 | url->port = 443; |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
2903 | if (url->path == NULL) |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
2904 | url->path = g_strdup("/"); |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
2905 | if (url->path[0] != '/') |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
2906 | purple_debug_warning("http", |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
2907 | "URL path doesn't start with slash\n"); |
|
33431
704de181d1d2
Let's request
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33430
diff
changeset
|
2908 | } |
|
704de181d1d2
Let's request
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33430
diff
changeset
|
2909 | |
|
33439
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
2910 | return url; |
|
33429
1ce1faf4e675
Extend URL parsing
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33427
diff
changeset
|
2911 | } |
|
1ce1faf4e675
Extend URL parsing
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33427
diff
changeset
|
2912 | |
|
34218
de45cb0670a5
HTTP: make purple_url_parse deprecated in favor of purple_http_url_parse
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33868
diff
changeset
|
2913 | void |
|
de45cb0670a5
HTTP: make purple_url_parse deprecated in favor of purple_http_url_parse
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33868
diff
changeset
|
2914 | purple_http_url_free(PurpleHttpURL *parsed_url) |
|
33429
1ce1faf4e675
Extend URL parsing
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33427
diff
changeset
|
2915 | { |
|
1ce1faf4e675
Extend URL parsing
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33427
diff
changeset
|
2916 | if (parsed_url == NULL) |
|
1ce1faf4e675
Extend URL parsing
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33427
diff
changeset
|
2917 | return; |
|
1ce1faf4e675
Extend URL parsing
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33427
diff
changeset
|
2918 | |
|
1ce1faf4e675
Extend URL parsing
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33427
diff
changeset
|
2919 | g_free(parsed_url->protocol); |
|
34219
eee308def583
HTTP: get rid of purple_url_parse
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34218
diff
changeset
|
2920 | g_free(parsed_url->username); |
|
33439
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
2921 | g_free(parsed_url->password); |
|
33429
1ce1faf4e675
Extend URL parsing
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33427
diff
changeset
|
2922 | g_free(parsed_url->host); |
|
1ce1faf4e675
Extend URL parsing
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33427
diff
changeset
|
2923 | g_free(parsed_url->path); |
|
33439
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
2924 | g_free(parsed_url->fragment); |
|
33429
1ce1faf4e675
Extend URL parsing
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33427
diff
changeset
|
2925 | g_free(parsed_url); |
|
1ce1faf4e675
Extend URL parsing
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33427
diff
changeset
|
2926 | } |
|
1ce1faf4e675
Extend URL parsing
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33427
diff
changeset
|
2927 | |
|
34218
de45cb0670a5
HTTP: make purple_url_parse deprecated in favor of purple_http_url_parse
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33868
diff
changeset
|
2928 | void |
|
de45cb0670a5
HTTP: make purple_url_parse deprecated in favor of purple_http_url_parse
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33868
diff
changeset
|
2929 | purple_http_url_relative(PurpleHttpURL *base_url, PurpleHttpURL *relative_url) |
|
33439
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
2930 | { |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
2931 | g_return_if_fail(base_url != NULL); |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
2932 | g_return_if_fail(relative_url != NULL); |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
2933 | |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
2934 | if (relative_url->host) { |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
2935 | g_free(base_url->protocol); |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
2936 | base_url->protocol = g_strdup(relative_url->protocol); |
|
34219
eee308def583
HTTP: get rid of purple_url_parse
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34218
diff
changeset
|
2937 | g_free(base_url->username); |
|
eee308def583
HTTP: get rid of purple_url_parse
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34218
diff
changeset
|
2938 | base_url->username = g_strdup(relative_url->username); |
|
33439
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
2939 | g_free(base_url->password); |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
2940 | base_url->password = g_strdup(relative_url->password); |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
2941 | g_free(base_url->host); |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
2942 | base_url->host = g_strdup(relative_url->host); |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
2943 | base_url->port = relative_url->port; |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
2944 | |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
2945 | g_free(base_url->path); |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
2946 | base_url->path = NULL; |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
2947 | } |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
2948 | |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
2949 | if (relative_url->path) { |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
2950 | if (relative_url->path[0] == '/' || |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
2951 | base_url->path == NULL) { |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
2952 | g_free(base_url->path); |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
2953 | base_url->path = g_strdup(relative_url->path); |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
2954 | } else { |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
2955 | gchar *last_slash = strrchr(base_url->path, '/'); |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
2956 | gchar *tmp; |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
2957 | if (last_slash == NULL) |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
2958 | base_url->path[0] = '\0'; |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
2959 | else |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
2960 | last_slash[1] = '\0'; |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
2961 | tmp = base_url->path; |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
2962 | base_url->path = g_strconcat(base_url->path, |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
2963 | relative_url->path, NULL); |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
2964 | g_free(tmp); |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
2965 | } |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
2966 | } |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
2967 | |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
2968 | g_free(base_url->fragment); |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
2969 | base_url->fragment = g_strdup(relative_url->fragment); |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
2970 | } |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
2971 | |
|
34218
de45cb0670a5
HTTP: make purple_url_parse deprecated in favor of purple_http_url_parse
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33868
diff
changeset
|
2972 | gchar * |
|
de45cb0670a5
HTTP: make purple_url_parse deprecated in favor of purple_http_url_parse
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33868
diff
changeset
|
2973 | purple_http_url_print(PurpleHttpURL *parsed_url) |
|
33429
1ce1faf4e675
Extend URL parsing
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33427
diff
changeset
|
2974 | { |
|
33438
66c4b90ff08a
More debug prints
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33437
diff
changeset
|
2975 | GString *url = g_string_new(""); |
|
66c4b90ff08a
More debug prints
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33437
diff
changeset
|
2976 | gboolean before_host_printed = FALSE, host_printed = FALSE; |
|
33439
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
2977 | gboolean port_is_default = FALSE; |
|
33430
013c5aebb665
Let's connect
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33429
diff
changeset
|
2978 | |
|
33439
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
2979 | if (parsed_url->protocol) { |
|
33438
66c4b90ff08a
More debug prints
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33437
diff
changeset
|
2980 | g_string_append_printf(url, "%s://", parsed_url->protocol); |
|
66c4b90ff08a
More debug prints
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33437
diff
changeset
|
2981 | before_host_printed = TRUE; |
|
33439
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
2982 | if (parsed_url->port == 80 && 0 == strcmp(parsed_url->protocol, |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
2983 | "http")) |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
2984 | port_is_default = TRUE; |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
2985 | if (parsed_url->port == 443 && 0 == strcmp(parsed_url->protocol, |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
2986 | "https")) |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
2987 | port_is_default = TRUE; |
|
33438
66c4b90ff08a
More debug prints
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33437
diff
changeset
|
2988 | } |
|
34219
eee308def583
HTTP: get rid of purple_url_parse
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34218
diff
changeset
|
2989 | if (parsed_url->username || parsed_url->password) { |
|
eee308def583
HTTP: get rid of purple_url_parse
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34218
diff
changeset
|
2990 | if (parsed_url->username) |
|
eee308def583
HTTP: get rid of purple_url_parse
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34218
diff
changeset
|
2991 | g_string_append(url, parsed_url->username); |
|
33438
66c4b90ff08a
More debug prints
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33437
diff
changeset
|
2992 | g_string_append_printf(url, ":%s", parsed_url->password); |
|
66c4b90ff08a
More debug prints
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33437
diff
changeset
|
2993 | g_string_append(url, "@"); |
|
66c4b90ff08a
More debug prints
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33437
diff
changeset
|
2994 | before_host_printed = TRUE; |
|
66c4b90ff08a
More debug prints
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33437
diff
changeset
|
2995 | } |
|
33439
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
2996 | if (parsed_url->host || parsed_url->port) { |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
2997 | if (!parsed_url->host) |
|
33438
66c4b90ff08a
More debug prints
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33437
diff
changeset
|
2998 | g_string_append_printf(url, "{???}:%d", |
|
66c4b90ff08a
More debug prints
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33437
diff
changeset
|
2999 | parsed_url->port); |
|
66c4b90ff08a
More debug prints
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33437
diff
changeset
|
3000 | else { |
|
66c4b90ff08a
More debug prints
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33437
diff
changeset
|
3001 | g_string_append(url, parsed_url->host); |
|
33439
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
3002 | if (!port_is_default) |
|
33438
66c4b90ff08a
More debug prints
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33437
diff
changeset
|
3003 | g_string_append_printf(url, ":%d", |
|
66c4b90ff08a
More debug prints
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33437
diff
changeset
|
3004 | parsed_url->port); |
|
66c4b90ff08a
More debug prints
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33437
diff
changeset
|
3005 | } |
|
66c4b90ff08a
More debug prints
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33437
diff
changeset
|
3006 | host_printed = TRUE; |
|
66c4b90ff08a
More debug prints
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33437
diff
changeset
|
3007 | } |
|
33439
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
3008 | if (parsed_url->path) { |
|
33438
66c4b90ff08a
More debug prints
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33437
diff
changeset
|
3009 | if (!host_printed && before_host_printed) |
|
66c4b90ff08a
More debug prints
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33437
diff
changeset
|
3010 | g_string_append(url, "{???}"); |
|
66c4b90ff08a
More debug prints
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33437
diff
changeset
|
3011 | g_string_append(url, parsed_url->path); |
|
66c4b90ff08a
More debug prints
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33437
diff
changeset
|
3012 | } |
|
33439
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
3013 | if (parsed_url->fragment) |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
3014 | g_string_append_printf(url, "#%s", parsed_url->fragment); |
|
33429
1ce1faf4e675
Extend URL parsing
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33427
diff
changeset
|
3015 | |
|
33438
66c4b90ff08a
More debug prints
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33437
diff
changeset
|
3016 | return g_string_free(url, FALSE); |
|
33429
1ce1faf4e675
Extend URL parsing
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33427
diff
changeset
|
3017 | } |
|
33439
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
3018 | |
|
34218
de45cb0670a5
HTTP: make purple_url_parse deprecated in favor of purple_http_url_parse
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33868
diff
changeset
|
3019 | const gchar * |
|
de45cb0670a5
HTTP: make purple_url_parse deprecated in favor of purple_http_url_parse
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33868
diff
changeset
|
3020 | purple_http_url_get_protocol(const PurpleHttpURL *parsed_url) |
|
de45cb0670a5
HTTP: make purple_url_parse deprecated in favor of purple_http_url_parse
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33868
diff
changeset
|
3021 | { |
|
de45cb0670a5
HTTP: make purple_url_parse deprecated in favor of purple_http_url_parse
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33868
diff
changeset
|
3022 | g_return_val_if_fail(parsed_url != NULL, NULL); |
|
de45cb0670a5
HTTP: make purple_url_parse deprecated in favor of purple_http_url_parse
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33868
diff
changeset
|
3023 | |
|
de45cb0670a5
HTTP: make purple_url_parse deprecated in favor of purple_http_url_parse
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33868
diff
changeset
|
3024 | return parsed_url->protocol; |
|
de45cb0670a5
HTTP: make purple_url_parse deprecated in favor of purple_http_url_parse
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33868
diff
changeset
|
3025 | } |
|
de45cb0670a5
HTTP: make purple_url_parse deprecated in favor of purple_http_url_parse
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33868
diff
changeset
|
3026 | |
|
de45cb0670a5
HTTP: make purple_url_parse deprecated in favor of purple_http_url_parse
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33868
diff
changeset
|
3027 | const gchar * |
|
34219
eee308def583
HTTP: get rid of purple_url_parse
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34218
diff
changeset
|
3028 | purple_http_url_get_username(const PurpleHttpURL *parsed_url) |
|
34218
de45cb0670a5
HTTP: make purple_url_parse deprecated in favor of purple_http_url_parse
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33868
diff
changeset
|
3029 | { |
|
de45cb0670a5
HTTP: make purple_url_parse deprecated in favor of purple_http_url_parse
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33868
diff
changeset
|
3030 | g_return_val_if_fail(parsed_url != NULL, NULL); |
|
de45cb0670a5
HTTP: make purple_url_parse deprecated in favor of purple_http_url_parse
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33868
diff
changeset
|
3031 | |
|
34219
eee308def583
HTTP: get rid of purple_url_parse
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34218
diff
changeset
|
3032 | return parsed_url->username; |
|
34218
de45cb0670a5
HTTP: make purple_url_parse deprecated in favor of purple_http_url_parse
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33868
diff
changeset
|
3033 | } |
|
de45cb0670a5
HTTP: make purple_url_parse deprecated in favor of purple_http_url_parse
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33868
diff
changeset
|
3034 | |
|
de45cb0670a5
HTTP: make purple_url_parse deprecated in favor of purple_http_url_parse
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33868
diff
changeset
|
3035 | const gchar * |
|
de45cb0670a5
HTTP: make purple_url_parse deprecated in favor of purple_http_url_parse
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33868
diff
changeset
|
3036 | purple_http_url_get_password(const PurpleHttpURL *parsed_url) |
|
de45cb0670a5
HTTP: make purple_url_parse deprecated in favor of purple_http_url_parse
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33868
diff
changeset
|
3037 | { |
|
de45cb0670a5
HTTP: make purple_url_parse deprecated in favor of purple_http_url_parse
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33868
diff
changeset
|
3038 | g_return_val_if_fail(parsed_url != NULL, NULL); |
|
de45cb0670a5
HTTP: make purple_url_parse deprecated in favor of purple_http_url_parse
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33868
diff
changeset
|
3039 | |
|
de45cb0670a5
HTTP: make purple_url_parse deprecated in favor of purple_http_url_parse
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33868
diff
changeset
|
3040 | return parsed_url->password; |
|
de45cb0670a5
HTTP: make purple_url_parse deprecated in favor of purple_http_url_parse
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33868
diff
changeset
|
3041 | } |
|
de45cb0670a5
HTTP: make purple_url_parse deprecated in favor of purple_http_url_parse
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33868
diff
changeset
|
3042 | |
|
de45cb0670a5
HTTP: make purple_url_parse deprecated in favor of purple_http_url_parse
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33868
diff
changeset
|
3043 | const gchar * |
|
de45cb0670a5
HTTP: make purple_url_parse deprecated in favor of purple_http_url_parse
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33868
diff
changeset
|
3044 | purple_http_url_get_host(const PurpleHttpURL *parsed_url) |
|
de45cb0670a5
HTTP: make purple_url_parse deprecated in favor of purple_http_url_parse
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33868
diff
changeset
|
3045 | { |
|
de45cb0670a5
HTTP: make purple_url_parse deprecated in favor of purple_http_url_parse
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33868
diff
changeset
|
3046 | g_return_val_if_fail(parsed_url != NULL, NULL); |
|
de45cb0670a5
HTTP: make purple_url_parse deprecated in favor of purple_http_url_parse
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33868
diff
changeset
|
3047 | |
|
de45cb0670a5
HTTP: make purple_url_parse deprecated in favor of purple_http_url_parse
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33868
diff
changeset
|
3048 | return parsed_url->host; |
|
de45cb0670a5
HTTP: make purple_url_parse deprecated in favor of purple_http_url_parse
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33868
diff
changeset
|
3049 | } |
|
de45cb0670a5
HTTP: make purple_url_parse deprecated in favor of purple_http_url_parse
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33868
diff
changeset
|
3050 | |
|
de45cb0670a5
HTTP: make purple_url_parse deprecated in favor of purple_http_url_parse
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33868
diff
changeset
|
3051 | int |
|
de45cb0670a5
HTTP: make purple_url_parse deprecated in favor of purple_http_url_parse
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33868
diff
changeset
|
3052 | purple_http_url_get_port(const PurpleHttpURL *parsed_url) |
|
de45cb0670a5
HTTP: make purple_url_parse deprecated in favor of purple_http_url_parse
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33868
diff
changeset
|
3053 | { |
|
de45cb0670a5
HTTP: make purple_url_parse deprecated in favor of purple_http_url_parse
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33868
diff
changeset
|
3054 | g_return_val_if_fail(parsed_url != NULL, 0); |
|
de45cb0670a5
HTTP: make purple_url_parse deprecated in favor of purple_http_url_parse
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33868
diff
changeset
|
3055 | |
|
de45cb0670a5
HTTP: make purple_url_parse deprecated in favor of purple_http_url_parse
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33868
diff
changeset
|
3056 | return parsed_url->port; |
|
de45cb0670a5
HTTP: make purple_url_parse deprecated in favor of purple_http_url_parse
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33868
diff
changeset
|
3057 | } |
|
de45cb0670a5
HTTP: make purple_url_parse deprecated in favor of purple_http_url_parse
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33868
diff
changeset
|
3058 | |
|
de45cb0670a5
HTTP: make purple_url_parse deprecated in favor of purple_http_url_parse
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33868
diff
changeset
|
3059 | const gchar * |
|
de45cb0670a5
HTTP: make purple_url_parse deprecated in favor of purple_http_url_parse
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33868
diff
changeset
|
3060 | purple_http_url_get_path(const PurpleHttpURL *parsed_url) |
|
de45cb0670a5
HTTP: make purple_url_parse deprecated in favor of purple_http_url_parse
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33868
diff
changeset
|
3061 | { |
|
de45cb0670a5
HTTP: make purple_url_parse deprecated in favor of purple_http_url_parse
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33868
diff
changeset
|
3062 | g_return_val_if_fail(parsed_url != NULL, NULL); |
|
de45cb0670a5
HTTP: make purple_url_parse deprecated in favor of purple_http_url_parse
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33868
diff
changeset
|
3063 | |
|
de45cb0670a5
HTTP: make purple_url_parse deprecated in favor of purple_http_url_parse
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33868
diff
changeset
|
3064 | return parsed_url->path; |
|
de45cb0670a5
HTTP: make purple_url_parse deprecated in favor of purple_http_url_parse
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33868
diff
changeset
|
3065 | } |
|
de45cb0670a5
HTTP: make purple_url_parse deprecated in favor of purple_http_url_parse
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33868
diff
changeset
|
3066 | |
|
de45cb0670a5
HTTP: make purple_url_parse deprecated in favor of purple_http_url_parse
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33868
diff
changeset
|
3067 | const gchar * |
|
de45cb0670a5
HTTP: make purple_url_parse deprecated in favor of purple_http_url_parse
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33868
diff
changeset
|
3068 | purple_http_url_get_fragment(const PurpleHttpURL *parsed_url) |
|
de45cb0670a5
HTTP: make purple_url_parse deprecated in favor of purple_http_url_parse
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33868
diff
changeset
|
3069 | { |
|
de45cb0670a5
HTTP: make purple_url_parse deprecated in favor of purple_http_url_parse
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33868
diff
changeset
|
3070 | g_return_val_if_fail(parsed_url != NULL, NULL); |
|
de45cb0670a5
HTTP: make purple_url_parse deprecated in favor of purple_http_url_parse
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33868
diff
changeset
|
3071 | |
|
de45cb0670a5
HTTP: make purple_url_parse deprecated in favor of purple_http_url_parse
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33868
diff
changeset
|
3072 | return parsed_url->fragment; |
|
de45cb0670a5
HTTP: make purple_url_parse deprecated in favor of purple_http_url_parse
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33868
diff
changeset
|
3073 | } |
|
de45cb0670a5
HTTP: make purple_url_parse deprecated in favor of purple_http_url_parse
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33868
diff
changeset
|
3074 | |
|
33439
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
3075 | /*** HTTP Subsystem ***********************************************************/ |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
3076 | |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
3077 | void purple_http_init(void) |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
3078 | { |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
3079 | purple_http_re_url = g_regex_new("^" |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
3080 | |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
3081 | "(?:" /* host part beginning */ |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
3082 | "([a-z]+)\\:/*" /* protocol */ |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
3083 | "([^/]+)" /* username, password, host, port */ |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
3084 | ")?" /* host part ending */ |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
3085 | |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
3086 | "([^#]*)" /* path */ |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
3087 | |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
3088 | "(?:#" "(.*)" ")?" /* fragment */ |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
3089 | |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
3090 | "$", G_REGEX_OPTIMIZE | G_REGEX_CASELESS, |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
3091 | G_REGEX_MATCH_NOTEMPTY, NULL); |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
3092 | |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
3093 | purple_http_re_url_host = g_regex_new("^" |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
3094 | |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
3095 | "(?:" /* user credentials part beginning */ |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
3096 | "([" PURPLE_HTTP_URL_CREDENTIALS_CHARS "]+)" /* username */ |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
3097 | "(?::([" PURPLE_HTTP_URL_CREDENTIALS_CHARS "]+))" /* password */ |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
3098 | "@)?" /* user credentials part ending */ |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
3099 | |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
3100 | "([a-z0-9.-]+)" /* host */ |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
3101 | "(?::([0-9]+))?" /* port*/ |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
3102 | |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
3103 | "$", G_REGEX_OPTIMIZE | G_REGEX_CASELESS, |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
3104 | G_REGEX_MATCH_NOTEMPTY, NULL); |
|
33448
4d41b1f7b95f
Cancelling all HTTP connections on account disconnect or app shutdown
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33447
diff
changeset
|
3105 | |
|
33460
c37dd51516aa
Deleting (or expiring) a cookie
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33459
diff
changeset
|
3106 | purple_http_re_rfc1123 = g_regex_new( |
|
c37dd51516aa
Deleting (or expiring) a cookie
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33459
diff
changeset
|
3107 | "^[a-z]+, " /* weekday */ |
|
c37dd51516aa
Deleting (or expiring) a cookie
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33459
diff
changeset
|
3108 | "([0-9]+) " /* date */ |
|
c37dd51516aa
Deleting (or expiring) a cookie
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33459
diff
changeset
|
3109 | "([a-z]+) " /* month */ |
|
c37dd51516aa
Deleting (or expiring) a cookie
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33459
diff
changeset
|
3110 | "([0-9]+) " /* year */ |
|
c37dd51516aa
Deleting (or expiring) a cookie
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33459
diff
changeset
|
3111 | "([0-9]+:[0-9]+:[0-9]+) " /* time */ |
|
c37dd51516aa
Deleting (or expiring) a cookie
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33459
diff
changeset
|
3112 | "(?:GMT|UTC)$", |
|
c37dd51516aa
Deleting (or expiring) a cookie
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33459
diff
changeset
|
3113 | G_REGEX_OPTIMIZE | G_REGEX_CASELESS, |
|
c37dd51516aa
Deleting (or expiring) a cookie
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33459
diff
changeset
|
3114 | G_REGEX_MATCH_NOTEMPTY, NULL); |
|
c37dd51516aa
Deleting (or expiring) a cookie
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33459
diff
changeset
|
3115 | |
|
33448
4d41b1f7b95f
Cancelling all HTTP connections on account disconnect or app shutdown
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33447
diff
changeset
|
3116 | purple_http_hc_list = NULL; |
|
4d41b1f7b95f
Cancelling all HTTP connections on account disconnect or app shutdown
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33447
diff
changeset
|
3117 | purple_http_hc_by_ptr = g_hash_table_new(g_direct_hash, g_direct_equal); |
|
4d41b1f7b95f
Cancelling all HTTP connections on account disconnect or app shutdown
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33447
diff
changeset
|
3118 | purple_http_hc_by_gc = g_hash_table_new_full(g_direct_hash, |
|
4d41b1f7b95f
Cancelling all HTTP connections on account disconnect or app shutdown
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33447
diff
changeset
|
3119 | g_direct_equal, NULL, (GDestroyNotify)g_list_free); |
|
34262
3b8ce83bac96
HTTP: get rid of one (of two) msn's own http implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34261
diff
changeset
|
3120 | purple_http_cancelling_gc = g_hash_table_new(g_direct_hash, g_direct_equal); |
|
33448
4d41b1f7b95f
Cancelling all HTTP connections on account disconnect or app shutdown
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33447
diff
changeset
|
3121 | } |
|
4d41b1f7b95f
Cancelling all HTTP connections on account disconnect or app shutdown
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33447
diff
changeset
|
3122 | |
|
4d41b1f7b95f
Cancelling all HTTP connections on account disconnect or app shutdown
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33447
diff
changeset
|
3123 | static void purple_http_foreach_conn_cancel(gpointer _hc, gpointer user_data) |
|
4d41b1f7b95f
Cancelling all HTTP connections on account disconnect or app shutdown
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33447
diff
changeset
|
3124 | { |
|
4d41b1f7b95f
Cancelling all HTTP connections on account disconnect or app shutdown
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33447
diff
changeset
|
3125 | PurpleHttpConnection *hc = _hc; |
|
4d41b1f7b95f
Cancelling all HTTP connections on account disconnect or app shutdown
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33447
diff
changeset
|
3126 | purple_http_conn_cancel(hc); |
|
33439
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
3127 | } |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
3128 | |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
3129 | void purple_http_uninit(void) |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
3130 | { |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
3131 | g_regex_unref(purple_http_re_url); |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
3132 | purple_http_re_url = NULL; |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
3133 | g_regex_unref(purple_http_re_url_host); |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
3134 | purple_http_re_url_host = NULL; |
|
33460
c37dd51516aa
Deleting (or expiring) a cookie
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33459
diff
changeset
|
3135 | g_regex_unref(purple_http_re_rfc1123); |
|
c37dd51516aa
Deleting (or expiring) a cookie
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33459
diff
changeset
|
3136 | purple_http_re_rfc1123 = NULL; |
|
33448
4d41b1f7b95f
Cancelling all HTTP connections on account disconnect or app shutdown
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33447
diff
changeset
|
3137 | |
|
4d41b1f7b95f
Cancelling all HTTP connections on account disconnect or app shutdown
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33447
diff
changeset
|
3138 | g_list_foreach(purple_http_hc_list, purple_http_foreach_conn_cancel, |
|
4d41b1f7b95f
Cancelling all HTTP connections on account disconnect or app shutdown
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33447
diff
changeset
|
3139 | NULL); |
|
4d41b1f7b95f
Cancelling all HTTP connections on account disconnect or app shutdown
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33447
diff
changeset
|
3140 | |
|
4d41b1f7b95f
Cancelling all HTTP connections on account disconnect or app shutdown
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33447
diff
changeset
|
3141 | if (purple_http_hc_list != NULL || |
|
4d41b1f7b95f
Cancelling all HTTP connections on account disconnect or app shutdown
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33447
diff
changeset
|
3142 | 0 != g_hash_table_size(purple_http_hc_by_ptr) || |
|
4d41b1f7b95f
Cancelling all HTTP connections on account disconnect or app shutdown
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33447
diff
changeset
|
3143 | 0 != g_hash_table_size(purple_http_hc_by_gc)) |
|
4d41b1f7b95f
Cancelling all HTTP connections on account disconnect or app shutdown
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33447
diff
changeset
|
3144 | purple_debug_warning("http", |
|
4d41b1f7b95f
Cancelling all HTTP connections on account disconnect or app shutdown
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33447
diff
changeset
|
3145 | "Couldn't cleanup all connections.\n"); |
|
4d41b1f7b95f
Cancelling all HTTP connections on account disconnect or app shutdown
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33447
diff
changeset
|
3146 | |
|
4d41b1f7b95f
Cancelling all HTTP connections on account disconnect or app shutdown
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33447
diff
changeset
|
3147 | g_list_free(purple_http_hc_list); |
|
4d41b1f7b95f
Cancelling all HTTP connections on account disconnect or app shutdown
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33447
diff
changeset
|
3148 | purple_http_hc_list = NULL; |
|
4d41b1f7b95f
Cancelling all HTTP connections on account disconnect or app shutdown
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33447
diff
changeset
|
3149 | g_hash_table_destroy(purple_http_hc_by_gc); |
|
4d41b1f7b95f
Cancelling all HTTP connections on account disconnect or app shutdown
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33447
diff
changeset
|
3150 | purple_http_hc_by_gc = NULL; |
|
4d41b1f7b95f
Cancelling all HTTP connections on account disconnect or app shutdown
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33447
diff
changeset
|
3151 | g_hash_table_destroy(purple_http_hc_by_ptr); |
|
4d41b1f7b95f
Cancelling all HTTP connections on account disconnect or app shutdown
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33447
diff
changeset
|
3152 | purple_http_hc_by_ptr = NULL; |
|
34262
3b8ce83bac96
HTTP: get rid of one (of two) msn's own http implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34261
diff
changeset
|
3153 | g_hash_table_destroy(purple_http_cancelling_gc); |
|
3b8ce83bac96
HTTP: get rid of one (of two) msn's own http implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34261
diff
changeset
|
3154 | purple_http_cancelling_gc = NULL; |
|
33439
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
3155 | } |