Tue, 23 Jul 2013 12:55:31 +0200
HTTP: queuing requests for Keep-Alive connections
|
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 | |
|
33430
013c5aebb665
Let's connect
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33429
diff
changeset
|
43 | typedef struct _PurpleHttpSocket PurpleHttpSocket; |
|
013c5aebb665
Let's connect
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33429
diff
changeset
|
44 | |
|
33432
9c4acb75b2e6
Let's parse response headers
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33431
diff
changeset
|
45 | typedef struct _PurpleHttpHeaders PurpleHttpHeaders; |
|
9c4acb75b2e6
Let's parse response headers
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33431
diff
changeset
|
46 | |
|
34263
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
47 | typedef struct _PurpleHttpKeepaliveHost PurpleHttpKeepaliveHost; |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
48 | |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
49 | typedef struct _PurpleHttpKeepaliveRequest PurpleHttpKeepaliveRequest; |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
50 | |
|
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
|
51 | 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
|
52 | 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
|
53 | |
|
33430
013c5aebb665
Let's connect
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33429
diff
changeset
|
54 | struct _PurpleHttpSocket |
|
013c5aebb665
Let's connect
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33429
diff
changeset
|
55 | { |
|
013c5aebb665
Let's connect
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33429
diff
changeset
|
56 | gboolean is_ssl; |
|
34260
7a55eaa31da6
HTTP: implement keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34257
diff
changeset
|
57 | gboolean is_busy; |
|
7a55eaa31da6
HTTP: implement keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34257
diff
changeset
|
58 | uint use_count; |
|
34263
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
59 | PurpleHttpKeepaliveHost *host; |
|
34260
7a55eaa31da6
HTTP: implement keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34257
diff
changeset
|
60 | |
|
33430
013c5aebb665
Let's connect
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33429
diff
changeset
|
61 | PurpleSslConnection *ssl_connection; |
|
013c5aebb665
Let's connect
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33429
diff
changeset
|
62 | PurpleProxyConnectData *raw_connection; |
|
013c5aebb665
Let's connect
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33429
diff
changeset
|
63 | int fd; |
|
013c5aebb665
Let's connect
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33429
diff
changeset
|
64 | 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
|
65 | 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
|
66 | 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
|
67 | gpointer cb_data; |
|
33430
013c5aebb665
Let's connect
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33429
diff
changeset
|
68 | }; |
|
013c5aebb665
Let's connect
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33429
diff
changeset
|
69 | |
|
33427
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
70 | struct _PurpleHttpRequest |
|
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
71 | { |
|
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
72 | int ref_count; |
|
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 | gchar *url; |
|
33451
27d0e5dbc2a1
Implement missing getters/setters and corresponding features
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33450
diff
changeset
|
75 | 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
|
76 | PurpleHttpHeaders *headers; |
|
33456
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
77 | 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
|
78 | PurpleHttpKeepalivePool *keepalive_pool; |
|
33444
b3afec292014
New features: http version switching and limits for redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33443
diff
changeset
|
79 | |
|
33457
81f92a310aff
Writing request contents
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33456
diff
changeset
|
80 | gchar *contents; |
|
81f92a310aff
Writing request contents
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33456
diff
changeset
|
81 | int contents_length; |
|
33466
918507303f45
HTTP API: PurpleHttpContentReader support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33464
diff
changeset
|
82 | PurpleHttpContentReader contents_reader; |
|
918507303f45
HTTP API: PurpleHttpContentReader support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33464
diff
changeset
|
83 | gpointer contents_reader_data; |
|
33517
ddd9e37c4b07
HTTP: PurpleHttpContentWriter support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33469
diff
changeset
|
84 | PurpleHttpContentWriter response_writer; |
|
ddd9e37c4b07
HTTP: PurpleHttpContentWriter support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33469
diff
changeset
|
85 | gpointer response_writer_data; |
|
33457
81f92a310aff
Writing request contents
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33456
diff
changeset
|
86 | |
|
33450
4042907bcdf1
Timeout support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33448
diff
changeset
|
87 | int timeout; |
|
33444
b3afec292014
New features: http version switching and limits for redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33443
diff
changeset
|
88 | int max_redirects; |
|
b3afec292014
New features: http version switching and limits for redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33443
diff
changeset
|
89 | gboolean http11; |
|
33446
95fda782966c
New feature: setting maximum length of response
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33445
diff
changeset
|
90 | int max_length; |
|
33427
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
91 | }; |
|
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
92 | |
|
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
93 | struct _PurpleHttpConnection |
|
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 | PurpleConnection *gc; |
|
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
96 | PurpleHttpCallback callback; |
|
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
97 | gpointer user_data; |
|
33468
b057fee9d11a
HTTP progress watcher support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33466
diff
changeset
|
98 | 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
|
99 | gboolean is_keepalive; |
|
34263
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
100 | gboolean is_cancelling; |
|
33427
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
101 | |
|
33429
1ce1faf4e675
Extend URL parsing
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33427
diff
changeset
|
102 | PurpleHttpURL *url; |
|
1ce1faf4e675
Extend URL parsing
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33427
diff
changeset
|
103 | PurpleHttpRequest *request; |
|
33427
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
104 | PurpleHttpResponse *response; |
|
33430
013c5aebb665
Let's connect
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33429
diff
changeset
|
105 | |
|
34263
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
106 | PurpleHttpKeepaliveRequest *socket_request; |
|
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
|
107 | PurpleHttpSocket *socket; |
|
33431
704de181d1d2
Let's request
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33430
diff
changeset
|
108 | GString *request_header; |
|
33457
81f92a310aff
Writing request contents
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33456
diff
changeset
|
109 | int request_header_written, request_contents_written; |
|
33432
9c4acb75b2e6
Let's parse response headers
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33431
diff
changeset
|
110 | gboolean main_header_got, headers_got; |
|
9c4acb75b2e6
Let's parse response headers
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33431
diff
changeset
|
111 | GString *response_buffer; |
|
33433
fb7ac52ed7df
Let's get response contents
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33432
diff
changeset
|
112 | |
|
33466
918507303f45
HTTP API: PurpleHttpContentReader support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33464
diff
changeset
|
113 | GString *contents_reader_buffer; |
|
918507303f45
HTTP API: PurpleHttpContentReader support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33464
diff
changeset
|
114 | gboolean contents_reader_requested; |
|
918507303f45
HTTP API: PurpleHttpContentReader support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33464
diff
changeset
|
115 | |
|
33444
b3afec292014
New features: http version switching and limits for redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33443
diff
changeset
|
116 | int redirects_count; |
|
33446
95fda782966c
New feature: setting maximum length of response
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33445
diff
changeset
|
117 | int data_length_got; |
|
33444
b3afec292014
New features: http version switching and limits for redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33443
diff
changeset
|
118 | |
|
33433
fb7ac52ed7df
Let's get response contents
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33432
diff
changeset
|
119 | int length_expected, length_got; |
|
33434
ec4f343af107
Chunked file transfers support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33433
diff
changeset
|
120 | |
|
ec4f343af107
Chunked file transfers support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33433
diff
changeset
|
121 | gboolean is_chunked, in_chunk, chunks_done; |
|
ec4f343af107
Chunked file transfers support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33433
diff
changeset
|
122 | 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
|
123 | |
|
4d41b1f7b95f
Cancelling all HTTP connections on account disconnect or app shutdown
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33447
diff
changeset
|
124 | GList *link_global, *link_gc; |
|
33450
4042907bcdf1
Timeout support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33448
diff
changeset
|
125 | |
|
4042907bcdf1
Timeout support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33448
diff
changeset
|
126 | guint timeout_handle; |
|
33468
b057fee9d11a
HTTP progress watcher support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33466
diff
changeset
|
127 | |
|
b057fee9d11a
HTTP progress watcher support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33466
diff
changeset
|
128 | PurpleHttpProgressWatcher watcher; |
|
b057fee9d11a
HTTP progress watcher support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33466
diff
changeset
|
129 | gpointer watcher_user_data; |
|
b057fee9d11a
HTTP progress watcher support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33466
diff
changeset
|
130 | guint watcher_interval_threshold; |
|
b057fee9d11a
HTTP progress watcher support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33466
diff
changeset
|
131 | 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
|
132 | guint watcher_delayed_handle; |
|
33427
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
133 | }; |
|
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
134 | |
|
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
135 | struct _PurpleHttpResponse |
|
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 | int code; |
|
33430
013c5aebb665
Let's connect
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33429
diff
changeset
|
138 | gchar *error; |
|
33427
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
139 | |
|
33433
fb7ac52ed7df
Let's get response contents
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33432
diff
changeset
|
140 | GString *contents; |
|
33432
9c4acb75b2e6
Let's parse response headers
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33431
diff
changeset
|
141 | PurpleHttpHeaders *headers; |
|
33427
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
142 | }; |
|
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
143 | |
|
33429
1ce1faf4e675
Extend URL parsing
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33427
diff
changeset
|
144 | struct _PurpleHttpURL |
|
1ce1faf4e675
Extend URL parsing
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33427
diff
changeset
|
145 | { |
|
1ce1faf4e675
Extend URL parsing
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33427
diff
changeset
|
146 | gchar *protocol; |
|
34219
eee308def583
HTTP: get rid of purple_url_parse
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34218
diff
changeset
|
147 | gchar *username; |
|
33439
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
148 | gchar *password; |
|
33429
1ce1faf4e675
Extend URL parsing
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33427
diff
changeset
|
149 | gchar *host; |
|
1ce1faf4e675
Extend URL parsing
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33427
diff
changeset
|
150 | int port; |
|
1ce1faf4e675
Extend URL parsing
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33427
diff
changeset
|
151 | gchar *path; |
|
33439
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
152 | gchar *fragment; |
|
33429
1ce1faf4e675
Extend URL parsing
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33427
diff
changeset
|
153 | }; |
|
1ce1faf4e675
Extend URL parsing
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33427
diff
changeset
|
154 | |
|
33432
9c4acb75b2e6
Let's parse response headers
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33431
diff
changeset
|
155 | struct _PurpleHttpHeaders |
|
9c4acb75b2e6
Let's parse response headers
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33431
diff
changeset
|
156 | { |
|
9c4acb75b2e6
Let's parse response headers
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33431
diff
changeset
|
157 | GList *list; |
|
9c4acb75b2e6
Let's parse response headers
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33431
diff
changeset
|
158 | GHashTable *by_name; |
|
9c4acb75b2e6
Let's parse response headers
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33431
diff
changeset
|
159 | }; |
|
9c4acb75b2e6
Let's parse response headers
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33431
diff
changeset
|
160 | |
|
33459
722a6d753cb2
Better cookies, better chunked transfer support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33458
diff
changeset
|
161 | typedef struct |
|
722a6d753cb2
Better cookies, better chunked transfer support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33458
diff
changeset
|
162 | { |
|
722a6d753cb2
Better cookies, better chunked transfer support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33458
diff
changeset
|
163 | time_t expires; |
|
722a6d753cb2
Better cookies, better chunked transfer support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33458
diff
changeset
|
164 | gchar *value; |
|
722a6d753cb2
Better cookies, better chunked transfer support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33458
diff
changeset
|
165 | } PurpleHttpCookie; |
|
722a6d753cb2
Better cookies, better chunked transfer support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33458
diff
changeset
|
166 | |
|
33456
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
167 | struct _PurpleHttpCookieJar |
|
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
168 | { |
|
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
169 | int ref_count; |
|
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 | GHashTable *tab; |
|
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 | |
|
34263
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
174 | struct _PurpleHttpKeepaliveRequest |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
175 | { |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
176 | PurpleConnection *gc; |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
177 | PurpleHttpSocketConnectCb cb; |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
178 | gpointer user_data; |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
179 | |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
180 | PurpleHttpKeepaliveHost *host; |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
181 | PurpleHttpSocket *hs; |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
182 | }; |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
183 | |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
184 | struct _PurpleHttpKeepaliveHost |
|
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 | PurpleHttpKeepalivePool *pool; |
|
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 | gchar *host; |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
189 | int port; |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
190 | gboolean is_ssl; |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
191 | |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
192 | GSList *sockets; /* list of PurpleHttpSocket */ |
|
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 *queue; /* list of PurpleHttpKeepaliveRequest */ |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
195 | guint process_queue_timeout; |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
196 | }; |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
197 | |
|
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
|
198 | 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
|
199 | { |
|
34263
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
200 | gboolean is_destroying; |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
201 | |
|
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
|
202 | int ref_count; |
|
34260
7a55eaa31da6
HTTP: implement keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34257
diff
changeset
|
203 | |
|
34263
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
204 | guint limit_per_host; |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
205 | |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
206 | /* key: purple_http_socket_hash, value: PurpleHttpKeepaliveHost */ |
|
34260
7a55eaa31da6
HTTP: implement keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34257
diff
changeset
|
207 | 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
|
208 | }; |
|
935120490eb2
HTTP: isolate socket-related code in http module; initial implementation for keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34234
diff
changeset
|
209 | |
| 33462 | 210 | static time_t purple_http_rfc1123_to_time(const gchar *str); |
| 211 | ||
|
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
|
212 | 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
|
213 | 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
|
214 | |
|
33429
1ce1faf4e675
Extend URL parsing
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33427
diff
changeset
|
215 | 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
|
216 | PurpleHttpRequest *request, PurpleConnection *gc); |
|
33427
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
217 | static void purple_http_connection_terminate(PurpleHttpConnection *hc); |
|
33468
b057fee9d11a
HTTP progress watcher support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33466
diff
changeset
|
218 | 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
|
219 | static void |
|
7a55eaa31da6
HTTP: implement keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34257
diff
changeset
|
220 | 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
|
221 | |
|
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
222 | 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
|
223 | 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
|
224 | |
|
33456
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
225 | static void purple_http_cookie_jar_parse(PurpleHttpCookieJar *cookie_jar, |
|
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
226 | GList *values); |
|
33458
59b3364f690e
Sending cookies
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33457
diff
changeset
|
227 | 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
|
228 | gchar * purple_http_cookie_jar_dump(PurpleHttpCookieJar *cjar); |
|
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
229 | |
|
34263
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
230 | static PurpleHttpKeepaliveRequest * |
|
34260
7a55eaa31da6
HTTP: implement keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34257
diff
changeset
|
231 | purple_http_keepalive_pool_request(PurpleHttpKeepalivePool *pool, |
|
7a55eaa31da6
HTTP: implement keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34257
diff
changeset
|
232 | 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
|
233 | PurpleHttpSocketConnectCb cb, gpointer user_data); |
|
7a55eaa31da6
HTTP: implement keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34257
diff
changeset
|
234 | static void |
|
34263
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
235 | 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
|
236 | static void |
|
34260
7a55eaa31da6
HTTP: implement keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34257
diff
changeset
|
237 | 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
|
238 | |
|
33460
c37dd51516aa
Deleting (or expiring) a cookie
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33459
diff
changeset
|
239 | 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
|
240 | *purple_http_re_rfc1123; |
|
33432
9c4acb75b2e6
Let's parse response headers
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33431
diff
changeset
|
241 | |
|
33448
4d41b1f7b95f
Cancelling all HTTP connections on account disconnect or app shutdown
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33447
diff
changeset
|
242 | /** |
|
4d41b1f7b95f
Cancelling all HTTP connections on account disconnect or app shutdown
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33447
diff
changeset
|
243 | * 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
|
244 | */ |
|
4d41b1f7b95f
Cancelling all HTTP connections on account disconnect or app shutdown
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33447
diff
changeset
|
245 | 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
|
246 | |
|
4d41b1f7b95f
Cancelling all HTTP connections on account disconnect or app shutdown
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33447
diff
changeset
|
247 | /** |
|
4d41b1f7b95f
Cancelling all HTTP connections on account disconnect or app shutdown
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33447
diff
changeset
|
248 | * 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
|
249 | * 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
|
250 | */ |
|
4d41b1f7b95f
Cancelling all HTTP connections on account disconnect or app shutdown
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33447
diff
changeset
|
251 | 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
|
252 | |
|
4d41b1f7b95f
Cancelling all HTTP connections on account disconnect or app shutdown
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33447
diff
changeset
|
253 | /** |
|
34262
3b8ce83bac96
HTTP: get rid of one (of two) msn's own http implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34261
diff
changeset
|
254 | * 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
|
255 | * 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
|
256 | */ |
|
3b8ce83bac96
HTTP: get rid of one (of two) msn's own http implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34261
diff
changeset
|
257 | 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
|
258 | |
|
3b8ce83bac96
HTTP: get rid of one (of two) msn's own http implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34261
diff
changeset
|
259 | /** |
|
33448
4d41b1f7b95f
Cancelling all HTTP connections on account disconnect or app shutdown
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33447
diff
changeset
|
260 | * 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
|
261 | * 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
|
262 | */ |
|
4d41b1f7b95f
Cancelling all HTTP connections on account disconnect or app shutdown
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33447
diff
changeset
|
263 | 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
|
264 | |
|
33460
c37dd51516aa
Deleting (or expiring) a cookie
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33459
diff
changeset
|
265 | /*** Helper functions *********************************************************/ |
|
c37dd51516aa
Deleting (or expiring) a cookie
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33459
diff
changeset
|
266 | |
|
c37dd51516aa
Deleting (or expiring) a cookie
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33459
diff
changeset
|
267 | 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
|
268 | { |
|
c37dd51516aa
Deleting (or expiring) a cookie
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33459
diff
changeset
|
269 | 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
|
270 | "jul", "aug", "sep", "oct", "nov", "dec", NULL}; |
|
c37dd51516aa
Deleting (or expiring) a cookie
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33459
diff
changeset
|
271 | GMatchInfo *match_info; |
|
c37dd51516aa
Deleting (or expiring) a cookie
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33459
diff
changeset
|
272 | 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
|
273 | int month; |
|
c37dd51516aa
Deleting (or expiring) a cookie
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33459
diff
changeset
|
274 | gchar *iso_date; |
|
c37dd51516aa
Deleting (or expiring) a cookie
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33459
diff
changeset
|
275 | time_t t; |
|
c37dd51516aa
Deleting (or expiring) a cookie
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33459
diff
changeset
|
276 | |
|
c37dd51516aa
Deleting (or expiring) a cookie
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33459
diff
changeset
|
277 | g_return_val_if_fail(str != NULL, 0); |
|
c37dd51516aa
Deleting (or expiring) a cookie
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33459
diff
changeset
|
278 | |
|
c37dd51516aa
Deleting (or expiring) a cookie
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33459
diff
changeset
|
279 | 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
|
280 | if (!g_match_info_matches(match_info)) { |
|
c37dd51516aa
Deleting (or expiring) a cookie
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33459
diff
changeset
|
281 | g_match_info_free(match_info); |
|
c37dd51516aa
Deleting (or expiring) a cookie
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33459
diff
changeset
|
282 | return 0; |
|
c37dd51516aa
Deleting (or expiring) a cookie
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33459
diff
changeset
|
283 | } |
|
c37dd51516aa
Deleting (or expiring) a cookie
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33459
diff
changeset
|
284 | g_match_info_free(match_info); |
|
c37dd51516aa
Deleting (or expiring) a cookie
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33459
diff
changeset
|
285 | |
|
c37dd51516aa
Deleting (or expiring) a cookie
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33459
diff
changeset
|
286 | 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
|
287 | 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
|
288 | 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
|
289 | 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
|
290 | |
|
c37dd51516aa
Deleting (or expiring) a cookie
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33459
diff
changeset
|
291 | month = 0; |
|
c37dd51516aa
Deleting (or expiring) a cookie
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33459
diff
changeset
|
292 | while (months[month] != NULL) |
|
c37dd51516aa
Deleting (or expiring) a cookie
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33459
diff
changeset
|
293 | { |
|
c37dd51516aa
Deleting (or expiring) a cookie
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33459
diff
changeset
|
294 | 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
|
295 | break; |
|
c37dd51516aa
Deleting (or expiring) a cookie
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33459
diff
changeset
|
296 | month++; |
|
c37dd51516aa
Deleting (or expiring) a cookie
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33459
diff
changeset
|
297 | } |
|
c37dd51516aa
Deleting (or expiring) a cookie
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33459
diff
changeset
|
298 | month++; |
|
c37dd51516aa
Deleting (or expiring) a cookie
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33459
diff
changeset
|
299 | |
|
c37dd51516aa
Deleting (or expiring) a cookie
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33459
diff
changeset
|
300 | 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
|
301 | d_year, month, d_date, d_time); |
|
c37dd51516aa
Deleting (or expiring) a cookie
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33459
diff
changeset
|
302 | |
|
c37dd51516aa
Deleting (or expiring) a cookie
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33459
diff
changeset
|
303 | g_free(d_date); |
|
c37dd51516aa
Deleting (or expiring) a cookie
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33459
diff
changeset
|
304 | g_free(d_month); |
|
c37dd51516aa
Deleting (or expiring) a cookie
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33459
diff
changeset
|
305 | g_free(d_year); |
|
c37dd51516aa
Deleting (or expiring) a cookie
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33459
diff
changeset
|
306 | g_free(d_time); |
|
c37dd51516aa
Deleting (or expiring) a cookie
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33459
diff
changeset
|
307 | |
|
c37dd51516aa
Deleting (or expiring) a cookie
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33459
diff
changeset
|
308 | if (month > 12) { |
|
c37dd51516aa
Deleting (or expiring) a cookie
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33459
diff
changeset
|
309 | 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
|
310 | g_free(iso_date); |
|
c37dd51516aa
Deleting (or expiring) a cookie
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33459
diff
changeset
|
311 | return 0; |
|
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 | |
|
c37dd51516aa
Deleting (or expiring) a cookie
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33459
diff
changeset
|
314 | 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
|
315 | |
|
c37dd51516aa
Deleting (or expiring) a cookie
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33459
diff
changeset
|
316 | g_free(iso_date); |
|
c37dd51516aa
Deleting (or expiring) a cookie
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33459
diff
changeset
|
317 | |
|
c37dd51516aa
Deleting (or expiring) a cookie
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33459
diff
changeset
|
318 | return t; |
|
c37dd51516aa
Deleting (or expiring) a cookie
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33459
diff
changeset
|
319 | } |
|
c37dd51516aa
Deleting (or expiring) a cookie
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33459
diff
changeset
|
320 | |
|
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
|
321 | /*** 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
|
322 | |
|
935120490eb2
HTTP: isolate socket-related code in http module; initial implementation for keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34234
diff
changeset
|
323 | 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
|
324 | 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
|
325 | { |
|
935120490eb2
HTTP: isolate socket-related code in http module; initial implementation for keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34234
diff
changeset
|
326 | 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
|
327 | |
|
935120490eb2
HTTP: isolate socket-related code in http module; initial implementation for keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34234
diff
changeset
|
328 | 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
|
329 | |
|
935120490eb2
HTTP: isolate socket-related code in http module; initial implementation for keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34234
diff
changeset
|
330 | 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
|
331 | 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
|
332 | 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
|
333 | 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
|
334 | 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
|
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 | |
|
935120490eb2
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 | 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
|
338 | 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
|
339 | } |
|
935120490eb2
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 | 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
|
342 | 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
|
343 | { |
|
935120490eb2
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 | 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
|
345 | |
|
935120490eb2
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->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
|
347 | 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
|
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 | 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
|
351 | 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
|
352 | 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
|
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 | 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
|
355 | |
|
935120490eb2
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 | 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
|
357 | 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
|
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 | |
|
34260
7a55eaa31da6
HTTP: implement keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34257
diff
changeset
|
360 | static gchar * |
|
7a55eaa31da6
HTTP: implement keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34257
diff
changeset
|
361 | 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
|
362 | { |
|
7a55eaa31da6
HTTP: implement keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34257
diff
changeset
|
363 | 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
|
364 | } |
|
7a55eaa31da6
HTTP: implement keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34257
diff
changeset
|
365 | |
|
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
|
366 | 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
|
367 | 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
|
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 | 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
|
370 | 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
|
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 | 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
|
373 | 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
|
374 | |
|
935120490eb2
HTTP: isolate socket-related code in http module; initial implementation for keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34234
diff
changeset
|
375 | 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
|
376 | 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
|
377 | 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
|
378 | 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
|
379 | |
|
935120490eb2
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 | 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
|
381 | 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
|
382 | 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
|
383 | 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
|
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 | |
|
935120490eb2
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 | 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
|
387 | 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
|
388 | _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
|
389 | _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
|
390 | /* 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
|
391 | 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
|
392 | 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
|
393 | */ |
|
935120490eb2
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 | } 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
|
395 | 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
|
396 | 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
|
397 | _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
|
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 | |
|
935120490eb2
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 | 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
|
401 | 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
|
402 | 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
|
403 | 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
|
404 | } |
|
935120490eb2
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 | |
|
34260
7a55eaa31da6
HTTP: implement keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34257
diff
changeset
|
406 | if (purple_debug_is_verbose()) |
|
7a55eaa31da6
HTTP: implement keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34257
diff
changeset
|
407 | 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
|
408 | |
|
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
|
409 | 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
|
410 | } |
|
935120490eb2
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 | 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
|
413 | 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
|
414 | { |
|
935120490eb2
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_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
|
416 | 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
|
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 | 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
|
419 | 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
|
420 | 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
|
421 | 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
|
422 | } |
|
935120490eb2
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 | 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
|
425 | 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
|
426 | { |
|
935120490eb2
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 | 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
|
428 | 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
|
429 | |
|
935120490eb2
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 | 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
|
431 | 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
|
432 | 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
|
433 | 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
|
434 | } |
|
935120490eb2
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 | 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
|
437 | 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
|
438 | { |
|
935120490eb2
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 | 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
|
440 | |
|
935120490eb2
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_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
|
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 | 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
|
444 | } |
|
935120490eb2
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 | |
|
935120490eb2
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 | 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
|
447 | 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
|
448 | 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
|
449 | { |
|
935120490eb2
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 | 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
|
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 | 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
|
453 | 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
|
454 | 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
|
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 | 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
|
457 | 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
|
458 | 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
|
459 | 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
|
460 | _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
|
461 | } |
|
935120490eb2
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 | 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
|
463 | 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
|
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 | |
|
935120490eb2
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 | static void |
|
34260
7a55eaa31da6
HTTP: implement keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34257
diff
changeset
|
467 | purple_http_socket_dontwatch(PurpleHttpSocket *hs) |
|
7a55eaa31da6
HTTP: implement keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34257
diff
changeset
|
468 | { |
|
7a55eaa31da6
HTTP: implement keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34257
diff
changeset
|
469 | g_return_if_fail(hs != NULL); |
|
7a55eaa31da6
HTTP: implement keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34257
diff
changeset
|
470 | |
|
7a55eaa31da6
HTTP: implement keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34257
diff
changeset
|
471 | if (hs->inpa > 0) |
|
7a55eaa31da6
HTTP: implement keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34257
diff
changeset
|
472 | purple_input_remove(hs->inpa); |
|
7a55eaa31da6
HTTP: implement keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34257
diff
changeset
|
473 | 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
|
474 | 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
|
475 | purple_ssl_input_remove(hs->ssl_connection); |
|
34260
7a55eaa31da6
HTTP: implement keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34257
diff
changeset
|
476 | } |
|
7a55eaa31da6
HTTP: implement keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34257
diff
changeset
|
477 | |
|
7a55eaa31da6
HTTP: implement keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34257
diff
changeset
|
478 | 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
|
479 | 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
|
480 | { |
|
935120490eb2
HTTP: isolate socket-related code in http module; initial implementation for keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34234
diff
changeset
|
481 | 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
|
482 | 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
|
483 | |
|
34260
7a55eaa31da6
HTTP: implement keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34257
diff
changeset
|
484 | if (purple_debug_is_verbose()) |
|
7a55eaa31da6
HTTP: implement keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34257
diff
changeset
|
485 | 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
|
486 | |
|
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
|
487 | 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
|
488 | 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
|
489 | |
|
935120490eb2
HTTP: isolate socket-related code in http module; initial implementation for keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34234
diff
changeset
|
490 | 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
|
491 | 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
|
492 | 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
|
493 | } 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
|
494 | 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
|
495 | 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
|
496 | 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
|
497 | 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
|
498 | } |
|
34260
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 | 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
|
501 | } |
|
935120490eb2
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 | |
|
33432
9c4acb75b2e6
Let's parse response headers
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33431
diff
changeset
|
503 | /*** Headers collection *******************************************************/ |
|
9c4acb75b2e6
Let's parse response headers
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33431
diff
changeset
|
504 | |
|
9c4acb75b2e6
Let's parse response headers
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33431
diff
changeset
|
505 | static PurpleHttpHeaders * purple_http_headers_new(void); |
|
9c4acb75b2e6
Let's parse response headers
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33431
diff
changeset
|
506 | static void purple_http_headers_free(PurpleHttpHeaders *hdrs); |
|
9c4acb75b2e6
Let's parse response headers
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33431
diff
changeset
|
507 | 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
|
508 | const gchar *value); |
|
9c4acb75b2e6
Let's parse response headers
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33431
diff
changeset
|
509 | 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
|
510 | 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
|
511 | PurpleHttpHeaders *hdrs, const gchar *key); |
|
33433
fb7ac52ed7df
Let's get response contents
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33432
diff
changeset
|
512 | 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
|
513 | const gchar *key); |
|
fb7ac52ed7df
Let's get response contents
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33432
diff
changeset
|
514 | 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
|
515 | const gchar *key, int *dst); |
|
33434
ec4f343af107
Chunked file transfers support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33433
diff
changeset
|
516 | static gboolean purple_http_headers_match(PurpleHttpHeaders *hdrs, |
|
ec4f343af107
Chunked file transfers support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33433
diff
changeset
|
517 | const gchar *key, const gchar *value); |
|
33432
9c4acb75b2e6
Let's parse response headers
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33431
diff
changeset
|
518 | static gchar * purple_http_headers_dump(PurpleHttpHeaders *hdrs); |
|
9c4acb75b2e6
Let's parse response headers
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33431
diff
changeset
|
519 | |
|
9c4acb75b2e6
Let's parse response headers
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33431
diff
changeset
|
520 | static PurpleHttpHeaders * purple_http_headers_new(void) |
|
9c4acb75b2e6
Let's parse response headers
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33431
diff
changeset
|
521 | { |
|
9c4acb75b2e6
Let's parse response headers
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33431
diff
changeset
|
522 | PurpleHttpHeaders *hdrs = g_new0(PurpleHttpHeaders, 1); |
|
9c4acb75b2e6
Let's parse response headers
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33431
diff
changeset
|
523 | |
|
33437
fb792f8b6265
Fix leak caused by my previous temporary fix
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33436
diff
changeset
|
524 | 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
|
525 | (GDestroyNotify)g_list_free); |
|
33432
9c4acb75b2e6
Let's parse response headers
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33431
diff
changeset
|
526 | |
|
9c4acb75b2e6
Let's parse response headers
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33431
diff
changeset
|
527 | return hdrs; |
|
9c4acb75b2e6
Let's parse response headers
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33431
diff
changeset
|
528 | } |
|
9c4acb75b2e6
Let's parse response headers
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33431
diff
changeset
|
529 | |
|
9c4acb75b2e6
Let's parse response headers
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33431
diff
changeset
|
530 | 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
|
531 | { |
|
9c4acb75b2e6
Let's parse response headers
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33431
diff
changeset
|
532 | g_free(kvp->key); |
|
9c4acb75b2e6
Let's parse response headers
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33431
diff
changeset
|
533 | g_free(kvp->value); |
|
9c4acb75b2e6
Let's parse response headers
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33431
diff
changeset
|
534 | g_free(kvp); |
|
9c4acb75b2e6
Let's parse response headers
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33431
diff
changeset
|
535 | } |
|
9c4acb75b2e6
Let's parse response headers
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33431
diff
changeset
|
536 | |
|
9c4acb75b2e6
Let's parse response headers
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33431
diff
changeset
|
537 | static void purple_http_headers_free(PurpleHttpHeaders *hdrs) |
|
9c4acb75b2e6
Let's parse response headers
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33431
diff
changeset
|
538 | { |
|
9c4acb75b2e6
Let's parse response headers
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33431
diff
changeset
|
539 | if (hdrs == NULL) |
|
9c4acb75b2e6
Let's parse response headers
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33431
diff
changeset
|
540 | return; |
|
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 | g_hash_table_destroy(hdrs->by_name); |
|
9c4acb75b2e6
Let's parse response headers
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33431
diff
changeset
|
543 | g_list_free_full(hdrs->list, |
|
9c4acb75b2e6
Let's parse response headers
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33431
diff
changeset
|
544 | (GDestroyNotify)purple_http_headers_free_kvp); |
|
9c4acb75b2e6
Let's parse response headers
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33431
diff
changeset
|
545 | g_free(hdrs); |
|
9c4acb75b2e6
Let's parse response headers
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33431
diff
changeset
|
546 | } |
|
9c4acb75b2e6
Let's parse response headers
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33431
diff
changeset
|
547 | |
|
9c4acb75b2e6
Let's parse response headers
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33431
diff
changeset
|
548 | 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
|
549 | const gchar *value) |
|
9c4acb75b2e6
Let's parse response headers
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33431
diff
changeset
|
550 | { |
|
9c4acb75b2e6
Let's parse response headers
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33431
diff
changeset
|
551 | PurpleKeyValuePair *kvp; |
|
33437
fb792f8b6265
Fix leak caused by my previous temporary fix
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33436
diff
changeset
|
552 | 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
|
553 | gchar *key_low; |
|
33432
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_return_if_fail(hdrs != NULL); |
|
9c4acb75b2e6
Let's parse response headers
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33431
diff
changeset
|
556 | g_return_if_fail(key != NULL); |
|
9c4acb75b2e6
Let's parse response headers
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33431
diff
changeset
|
557 | g_return_if_fail(value != NULL); |
|
9c4acb75b2e6
Let's parse response headers
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33431
diff
changeset
|
558 | |
|
9c4acb75b2e6
Let's parse response headers
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33431
diff
changeset
|
559 | 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
|
560 | kvp->key = g_strdup(key); |
|
33432
9c4acb75b2e6
Let's parse response headers
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33431
diff
changeset
|
561 | kvp->value = g_strdup(value); |
|
9c4acb75b2e6
Let's parse response headers
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33431
diff
changeset
|
562 | hdrs->list = g_list_append(hdrs->list, kvp); |
|
9c4acb75b2e6
Let's parse response headers
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33431
diff
changeset
|
563 | |
|
33447
b890f231e15f
Request headers support, wrapping new API with legacy purple_util_fetch_url
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33446
diff
changeset
|
564 | 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
|
565 | 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
|
566 | 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
|
567 | 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
|
568 | 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
|
569 | else |
|
b890f231e15f
Request headers support, wrapping new API with legacy purple_util_fetch_url
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33446
diff
changeset
|
570 | 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
|
571 | } |
|
b890f231e15f
Request headers support, wrapping new API with legacy purple_util_fetch_url
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33446
diff
changeset
|
572 | |
|
b890f231e15f
Request headers support, wrapping new API with legacy purple_util_fetch_url
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33446
diff
changeset
|
573 | 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
|
574 | 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
|
575 | { |
|
b890f231e15f
Request headers support, wrapping new API with legacy purple_util_fetch_url
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33446
diff
changeset
|
576 | 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
|
577 | |
|
b890f231e15f
Request headers support, wrapping new API with legacy purple_util_fetch_url
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33446
diff
changeset
|
578 | 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
|
579 | 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
|
580 | |
|
b890f231e15f
Request headers support, wrapping new API with legacy purple_util_fetch_url
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33446
diff
changeset
|
581 | 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
|
582 | return; |
|
b890f231e15f
Request headers support, wrapping new API with legacy purple_util_fetch_url
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33446
diff
changeset
|
583 | |
|
b890f231e15f
Request headers support, wrapping new API with legacy purple_util_fetch_url
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33446
diff
changeset
|
584 | /* 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
|
585 | 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
|
586 | 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
|
587 | { |
|
b890f231e15f
Request headers support, wrapping new API with legacy purple_util_fetch_url
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33446
diff
changeset
|
588 | 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
|
589 | 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
|
590 | 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
|
591 | 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
|
592 | continue; |
|
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 | 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
|
595 | 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
|
596 | } |
|
33432
9c4acb75b2e6
Let's parse response headers
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33431
diff
changeset
|
597 | } |
|
9c4acb75b2e6
Let's parse response headers
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33431
diff
changeset
|
598 | |
|
9c4acb75b2e6
Let's parse response headers
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33431
diff
changeset
|
599 | 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
|
600 | { |
|
9c4acb75b2e6
Let's parse response headers
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33431
diff
changeset
|
601 | return hdrs->list; |
|
9c4acb75b2e6
Let's parse response headers
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33431
diff
changeset
|
602 | } |
|
9c4acb75b2e6
Let's parse response headers
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33431
diff
changeset
|
603 | |
|
33456
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
604 | /* return const */ |
|
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
605 | 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
|
606 | PurpleHttpHeaders *hdrs, const gchar *key) |
|
33433
fb7ac52ed7df
Let's get response contents
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33432
diff
changeset
|
607 | { |
|
fb7ac52ed7df
Let's get response contents
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33432
diff
changeset
|
608 | GList *values; |
|
33434
ec4f343af107
Chunked file transfers support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33433
diff
changeset
|
609 | gchar *key_low; |
|
33433
fb7ac52ed7df
Let's get response contents
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33432
diff
changeset
|
610 | |
|
fb7ac52ed7df
Let's get response contents
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33432
diff
changeset
|
611 | g_return_val_if_fail(hdrs != NULL, NULL); |
|
fb7ac52ed7df
Let's get response contents
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33432
diff
changeset
|
612 | g_return_val_if_fail(key != NULL, NULL); |
|
fb7ac52ed7df
Let's get response contents
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33432
diff
changeset
|
613 | |
|
33434
ec4f343af107
Chunked file transfers support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33433
diff
changeset
|
614 | key_low = g_ascii_strdown(key, -1); |
|
ec4f343af107
Chunked file transfers support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33433
diff
changeset
|
615 | 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
|
616 | g_free(key_low); |
|
33451
27d0e5dbc2a1
Implement missing getters/setters and corresponding features
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33450
diff
changeset
|
617 | |
|
27d0e5dbc2a1
Implement missing getters/setters and corresponding features
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33450
diff
changeset
|
618 | return values; |
|
27d0e5dbc2a1
Implement missing getters/setters and corresponding features
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33450
diff
changeset
|
619 | } |
|
27d0e5dbc2a1
Implement missing getters/setters and corresponding features
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33450
diff
changeset
|
620 | |
|
27d0e5dbc2a1
Implement missing getters/setters and corresponding features
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33450
diff
changeset
|
621 | 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
|
622 | const gchar *key) |
|
27d0e5dbc2a1
Implement missing getters/setters and corresponding features
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33450
diff
changeset
|
623 | { |
|
27d0e5dbc2a1
Implement missing getters/setters and corresponding features
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33450
diff
changeset
|
624 | 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
|
625 | |
|
33433
fb7ac52ed7df
Let's get response contents
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33432
diff
changeset
|
626 | if (!values) |
|
fb7ac52ed7df
Let's get response contents
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33432
diff
changeset
|
627 | return NULL; |
|
fb7ac52ed7df
Let's get response contents
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33432
diff
changeset
|
628 | |
|
fb7ac52ed7df
Let's get response contents
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33432
diff
changeset
|
629 | return values->data; |
|
fb7ac52ed7df
Let's get response contents
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33432
diff
changeset
|
630 | } |
|
fb7ac52ed7df
Let's get response contents
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33432
diff
changeset
|
631 | |
|
fb7ac52ed7df
Let's get response contents
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33432
diff
changeset
|
632 | 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
|
633 | const gchar *key, int *dst) |
|
fb7ac52ed7df
Let's get response contents
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33432
diff
changeset
|
634 | { |
|
fb7ac52ed7df
Let's get response contents
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33432
diff
changeset
|
635 | int val; |
|
fb7ac52ed7df
Let's get response contents
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33432
diff
changeset
|
636 | const gchar *str; |
|
fb7ac52ed7df
Let's get response contents
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33432
diff
changeset
|
637 | |
|
fb7ac52ed7df
Let's get response contents
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33432
diff
changeset
|
638 | str = purple_http_headers_get(hdrs, key); |
|
fb7ac52ed7df
Let's get response contents
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33432
diff
changeset
|
639 | if (!str) |
|
fb7ac52ed7df
Let's get response contents
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33432
diff
changeset
|
640 | return FALSE; |
|
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 | if (1 != sscanf(str, "%d", &val)) |
|
fb7ac52ed7df
Let's get response contents
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33432
diff
changeset
|
643 | return FALSE; |
|
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 | *dst = val; |
|
fb7ac52ed7df
Let's get response contents
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33432
diff
changeset
|
646 | return TRUE; |
|
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 | |
|
33434
ec4f343af107
Chunked file transfers support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33433
diff
changeset
|
649 | static gboolean purple_http_headers_match(PurpleHttpHeaders *hdrs, |
|
ec4f343af107
Chunked file transfers support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33433
diff
changeset
|
650 | const gchar *key, const gchar *value) |
|
ec4f343af107
Chunked file transfers support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33433
diff
changeset
|
651 | { |
|
ec4f343af107
Chunked file transfers support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33433
diff
changeset
|
652 | const gchar *str; |
|
ec4f343af107
Chunked file transfers support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33433
diff
changeset
|
653 | |
|
ec4f343af107
Chunked file transfers support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33433
diff
changeset
|
654 | str = purple_http_headers_get(hdrs, key); |
|
ec4f343af107
Chunked file transfers support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33433
diff
changeset
|
655 | if (str == NULL || value == NULL) |
|
ec4f343af107
Chunked file transfers support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33433
diff
changeset
|
656 | return str == value; |
|
ec4f343af107
Chunked file transfers support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33433
diff
changeset
|
657 | |
|
ec4f343af107
Chunked file transfers support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33433
diff
changeset
|
658 | return (g_ascii_strcasecmp(str, value) == 0); |
|
ec4f343af107
Chunked file transfers support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33433
diff
changeset
|
659 | } |
|
ec4f343af107
Chunked file transfers support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33433
diff
changeset
|
660 | |
|
33432
9c4acb75b2e6
Let's parse response headers
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33431
diff
changeset
|
661 | static gchar * purple_http_headers_dump(PurpleHttpHeaders *hdrs) |
|
9c4acb75b2e6
Let's parse response headers
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33431
diff
changeset
|
662 | { |
|
9c4acb75b2e6
Let's parse response headers
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33431
diff
changeset
|
663 | const GList *hdr; |
|
9c4acb75b2e6
Let's parse response headers
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33431
diff
changeset
|
664 | |
|
9c4acb75b2e6
Let's parse response headers
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33431
diff
changeset
|
665 | GString *s = g_string_new(""); |
|
9c4acb75b2e6
Let's parse response headers
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33431
diff
changeset
|
666 | |
|
9c4acb75b2e6
Let's parse response headers
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33431
diff
changeset
|
667 | hdr = purple_http_headers_get_all(hdrs); |
|
9c4acb75b2e6
Let's parse response headers
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33431
diff
changeset
|
668 | while (hdr) { |
|
9c4acb75b2e6
Let's parse response headers
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33431
diff
changeset
|
669 | PurpleKeyValuePair *kvp = hdr->data; |
|
9c4acb75b2e6
Let's parse response headers
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33431
diff
changeset
|
670 | hdr = g_list_next(hdr); |
|
9c4acb75b2e6
Let's parse response headers
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33431
diff
changeset
|
671 | |
|
9c4acb75b2e6
Let's parse response headers
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33431
diff
changeset
|
672 | 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
|
673 | (gchar*)kvp->value, hdr ? "\n" : ""); |
|
9c4acb75b2e6
Let's parse response headers
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33431
diff
changeset
|
674 | } |
|
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 | return g_string_free(s, FALSE); |
|
9c4acb75b2e6
Let's parse response headers
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33431
diff
changeset
|
677 | } |
|
33429
1ce1faf4e675
Extend URL parsing
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33427
diff
changeset
|
678 | |
|
33430
013c5aebb665
Let's connect
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33429
diff
changeset
|
679 | /*** HTTP protocol backend ****************************************************/ |
|
013c5aebb665
Let's connect
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33429
diff
changeset
|
680 | |
|
34260
7a55eaa31da6
HTTP: implement keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34257
diff
changeset
|
681 | static void _purple_http_disconnect(PurpleHttpConnection *hc, |
|
7a55eaa31da6
HTTP: implement keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34257
diff
changeset
|
682 | gboolean is_graceful); |
|
33430
013c5aebb665
Let's connect
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33429
diff
changeset
|
683 | |
|
33431
704de181d1d2
Let's request
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33430
diff
changeset
|
684 | 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
|
685 | 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
|
686 | 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
|
687 | PurpleInputCondition cond); |
|
33430
013c5aebb665
Let's connect
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33429
diff
changeset
|
688 | 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
|
689 | |
|
013c5aebb665
Let's connect
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33429
diff
changeset
|
690 | /* closes current connection (if exists), estabilishes one and proceeds with |
|
013c5aebb665
Let's connect
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33429
diff
changeset
|
691 | * request */ |
|
013c5aebb665
Let's connect
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33429
diff
changeset
|
692 | static gboolean _purple_http_reconnect(PurpleHttpConnection *hc); |
|
013c5aebb665
Let's connect
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33429
diff
changeset
|
693 | |
|
013c5aebb665
Let's connect
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33429
diff
changeset
|
694 | static void _purple_http_error(PurpleHttpConnection *hc, const char *format, |
|
013c5aebb665
Let's connect
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33429
diff
changeset
|
695 | ...) G_GNUC_PRINTF(2, 3); |
|
013c5aebb665
Let's connect
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33429
diff
changeset
|
696 | |
|
013c5aebb665
Let's connect
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33429
diff
changeset
|
697 | static void _purple_http_error(PurpleHttpConnection *hc, const char *format, |
|
013c5aebb665
Let's connect
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33429
diff
changeset
|
698 | ...) |
|
013c5aebb665
Let's connect
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33429
diff
changeset
|
699 | { |
|
013c5aebb665
Let's connect
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33429
diff
changeset
|
700 | va_list args; |
|
013c5aebb665
Let's connect
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33429
diff
changeset
|
701 | |
|
013c5aebb665
Let's connect
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33429
diff
changeset
|
702 | va_start(args, format); |
|
013c5aebb665
Let's connect
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33429
diff
changeset
|
703 | hc->response->error = g_strdup_vprintf(format, args); |
|
013c5aebb665
Let's connect
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33429
diff
changeset
|
704 | va_end(args); |
|
013c5aebb665
Let's connect
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33429
diff
changeset
|
705 | |
|
013c5aebb665
Let's connect
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33429
diff
changeset
|
706 | purple_http_conn_cancel(hc); |
|
013c5aebb665
Let's connect
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33429
diff
changeset
|
707 | } |
|
013c5aebb665
Let's connect
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33429
diff
changeset
|
708 | |
|
33431
704de181d1d2
Let's request
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33430
diff
changeset
|
709 | static void _purple_http_gen_headers(PurpleHttpConnection *hc) |
|
704de181d1d2
Let's request
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33430
diff
changeset
|
710 | { |
|
704de181d1d2
Let's request
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33430
diff
changeset
|
711 | GString *h; |
|
704de181d1d2
Let's request
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33430
diff
changeset
|
712 | 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
|
713 | const GList *hdr; |
|
33451
27d0e5dbc2a1
Implement missing getters/setters and corresponding features
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33450
diff
changeset
|
714 | PurpleHttpRequest *req; |
|
27d0e5dbc2a1
Implement missing getters/setters and corresponding features
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33450
diff
changeset
|
715 | PurpleHttpHeaders *hdrs; |
|
33453
3cb58ea9667c
HTTP Proxy support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33452
diff
changeset
|
716 | gchar *request_url, *tmp_url = NULL; |
|
3cb58ea9667c
HTTP Proxy support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33452
diff
changeset
|
717 | |
|
3cb58ea9667c
HTTP Proxy support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33452
diff
changeset
|
718 | PurpleProxyInfo *proxy; |
|
3cb58ea9667c
HTTP Proxy support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33452
diff
changeset
|
719 | gboolean proxy_http = FALSE; |
|
3cb58ea9667c
HTTP Proxy support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33452
diff
changeset
|
720 | const gchar *proxy_username, *proxy_password; |
|
33431
704de181d1d2
Let's request
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33430
diff
changeset
|
721 | |
|
704de181d1d2
Let's request
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33430
diff
changeset
|
722 | g_return_if_fail(hc != NULL); |
|
704de181d1d2
Let's request
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33430
diff
changeset
|
723 | |
|
704de181d1d2
Let's request
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33430
diff
changeset
|
724 | if (hc->request_header != NULL) |
|
704de181d1d2
Let's request
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33430
diff
changeset
|
725 | return; |
|
704de181d1d2
Let's request
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33430
diff
changeset
|
726 | |
|
33451
27d0e5dbc2a1
Implement missing getters/setters and corresponding features
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33450
diff
changeset
|
727 | req = hc->request; |
|
33431
704de181d1d2
Let's request
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33430
diff
changeset
|
728 | url = hc->url; |
|
33451
27d0e5dbc2a1
Implement missing getters/setters and corresponding features
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33450
diff
changeset
|
729 | hdrs = req->headers; |
|
33431
704de181d1d2
Let's request
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33430
diff
changeset
|
730 | proxy = purple_proxy_get_setup(hc->gc ? |
|
704de181d1d2
Let's request
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33430
diff
changeset
|
731 | purple_connection_get_account(hc->gc) : NULL); |
|
704de181d1d2
Let's request
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33430
diff
changeset
|
732 | |
|
33453
3cb58ea9667c
HTTP Proxy support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33452
diff
changeset
|
733 | 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
|
734 | 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
|
735 | /* 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
|
736 | 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
|
737 | proxy_http = FALSE; |
|
33453
3cb58ea9667c
HTTP Proxy support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33452
diff
changeset
|
738 | |
|
33431
704de181d1d2
Let's request
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33430
diff
changeset
|
739 | hc->request_header = h = g_string_new(""); |
|
704de181d1d2
Let's request
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33430
diff
changeset
|
740 | hc->request_header_written = 0; |
|
33457
81f92a310aff
Writing request contents
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33456
diff
changeset
|
741 | hc->request_contents_written = 0; |
|
33431
704de181d1d2
Let's request
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33430
diff
changeset
|
742 | |
|
33453
3cb58ea9667c
HTTP Proxy support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33452
diff
changeset
|
743 | if (proxy_http) |
|
3cb58ea9667c
HTTP Proxy support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33452
diff
changeset
|
744 | request_url = tmp_url = purple_http_url_print(url); |
|
3cb58ea9667c
HTTP Proxy support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33452
diff
changeset
|
745 | else |
|
3cb58ea9667c
HTTP Proxy support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33452
diff
changeset
|
746 | request_url = url->path; |
|
3cb58ea9667c
HTTP Proxy support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33452
diff
changeset
|
747 | |
|
33451
27d0e5dbc2a1
Implement missing getters/setters and corresponding features
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33450
diff
changeset
|
748 | 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
|
749 | req->method ? req->method : "GET", |
|
33453
3cb58ea9667c
HTTP Proxy support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33452
diff
changeset
|
750 | request_url, |
|
33451
27d0e5dbc2a1
Implement missing getters/setters and corresponding features
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33450
diff
changeset
|
751 | 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
|
752 | |
|
33453
3cb58ea9667c
HTTP Proxy support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33452
diff
changeset
|
753 | if (tmp_url) |
|
3cb58ea9667c
HTTP Proxy support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33452
diff
changeset
|
754 | g_free(tmp_url); |
|
3cb58ea9667c
HTTP Proxy support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33452
diff
changeset
|
755 | |
|
33451
27d0e5dbc2a1
Implement missing getters/setters and corresponding features
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33450
diff
changeset
|
756 | 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
|
757 | 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
|
758 | 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
|
759 | 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
|
760 | 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
|
761 | "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
|
762 | } |
|
33451
27d0e5dbc2a1
Implement missing getters/setters and corresponding features
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33450
diff
changeset
|
763 | if (!purple_http_headers_get(hdrs, "accept")) |
|
33453
3cb58ea9667c
HTTP Proxy support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33452
diff
changeset
|
764 | g_string_append(h, "Accept: */*\r\n"); |
|
3cb58ea9667c
HTTP Proxy support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33452
diff
changeset
|
765 | |
|
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
|
766 | 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
|
767 | 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
|
768 | 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
|
769 | { |
|
33457
81f92a310aff
Writing request contents
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33456
diff
changeset
|
770 | g_string_append_printf(h, "Content-Length: %u\r\n", |
|
81f92a310aff
Writing request contents
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33456
diff
changeset
|
771 | 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
|
772 | } |
|
33457
81f92a310aff
Writing request contents
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33456
diff
changeset
|
773 | |
|
33453
3cb58ea9667c
HTTP Proxy support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33452
diff
changeset
|
774 | 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
|
775 | 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
|
776 | |
|
3cb58ea9667c
HTTP Proxy support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33452
diff
changeset
|
777 | proxy_username = purple_proxy_info_get_username(proxy); |
|
3cb58ea9667c
HTTP Proxy support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33452
diff
changeset
|
778 | if (proxy_http && proxy_username != NULL && proxy_username[0] != '\0') { |
|
3cb58ea9667c
HTTP Proxy support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33452
diff
changeset
|
779 | gchar *proxy_auth, *ntlm_type1, *tmp; |
|
3cb58ea9667c
HTTP Proxy support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33452
diff
changeset
|
780 | int len; |
|
3cb58ea9667c
HTTP Proxy support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33452
diff
changeset
|
781 | |
|
3cb58ea9667c
HTTP Proxy support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33452
diff
changeset
|
782 | proxy_password = purple_proxy_info_get_password(proxy); |
|
3cb58ea9667c
HTTP Proxy support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33452
diff
changeset
|
783 | if (proxy_password == NULL) |
|
3cb58ea9667c
HTTP Proxy support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33452
diff
changeset
|
784 | proxy_password = ""; |
|
3cb58ea9667c
HTTP Proxy support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33452
diff
changeset
|
785 | |
|
3cb58ea9667c
HTTP Proxy support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33452
diff
changeset
|
786 | tmp = g_strdup_printf("%s:%s", proxy_username, proxy_password); |
|
3cb58ea9667c
HTTP Proxy support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33452
diff
changeset
|
787 | len = strlen(tmp); |
|
3cb58ea9667c
HTTP Proxy support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33452
diff
changeset
|
788 | proxy_auth = purple_base64_encode((const guchar *)tmp, len); |
|
3cb58ea9667c
HTTP Proxy support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33452
diff
changeset
|
789 | memset(tmp, 0, len); |
|
3cb58ea9667c
HTTP Proxy support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33452
diff
changeset
|
790 | g_free(tmp); |
|
3cb58ea9667c
HTTP Proxy support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33452
diff
changeset
|
791 | |
|
33469
6c2fa6d8037d
HTTP: simplify hostname getting
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33468
diff
changeset
|
792 | 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
|
793 | |
|
3cb58ea9667c
HTTP Proxy support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33452
diff
changeset
|
794 | 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
|
795 | proxy_auth); |
|
3cb58ea9667c
HTTP Proxy support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33452
diff
changeset
|
796 | 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
|
797 | 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
|
798 | 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
|
799 | |
|
3cb58ea9667c
HTTP Proxy support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33452
diff
changeset
|
800 | memset(proxy_auth, 0, strlen(proxy_auth)); |
|
3cb58ea9667c
HTTP Proxy support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33452
diff
changeset
|
801 | g_free(proxy_auth); |
|
3cb58ea9667c
HTTP Proxy support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33452
diff
changeset
|
802 | g_free(ntlm_type1); |
|
3cb58ea9667c
HTTP Proxy support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33452
diff
changeset
|
803 | } |
|
33431
704de181d1d2
Let's request
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33430
diff
changeset
|
804 | |
|
33451
27d0e5dbc2a1
Implement missing getters/setters and corresponding features
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33450
diff
changeset
|
805 | 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
|
806 | 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
|
807 | 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
|
808 | hdr = g_list_next(hdr); |
|
33431
704de181d1d2
Let's request
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33430
diff
changeset
|
809 | |
|
33447
b890f231e15f
Request headers support, wrapping new API with legacy purple_util_fetch_url
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33446
diff
changeset
|
810 | 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
|
811 | 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
|
812 | } |
|
33431
704de181d1d2
Let's request
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33430
diff
changeset
|
813 | |
|
33458
59b3364f690e
Sending cookies
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33457
diff
changeset
|
814 | if (!purple_http_cookie_jar_is_empty(req->cookie_jar)) { |
|
59b3364f690e
Sending cookies
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33457
diff
changeset
|
815 | gchar * cookies = purple_http_cookie_jar_gen(req->cookie_jar); |
|
59b3364f690e
Sending cookies
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33457
diff
changeset
|
816 | g_string_append_printf(h, "Cookie: %s\r\n", cookies); |
|
59b3364f690e
Sending cookies
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33457
diff
changeset
|
817 | g_free(cookies); |
|
59b3364f690e
Sending cookies
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33457
diff
changeset
|
818 | } |
|
33456
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
819 | |
|
33431
704de181d1d2
Let's request
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33430
diff
changeset
|
820 | g_string_append_printf(h, "\r\n"); |
|
704de181d1d2
Let's request
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33430
diff
changeset
|
821 | |
|
704de181d1d2
Let's request
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33430
diff
changeset
|
822 | if (purple_debug_is_unsafe() && purple_debug_is_verbose()) { |
|
704de181d1d2
Let's request
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33430
diff
changeset
|
823 | purple_debug_misc("http", "Generated request headers:\n%s", |
|
704de181d1d2
Let's request
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33430
diff
changeset
|
824 | h->str); |
|
704de181d1d2
Let's request
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33430
diff
changeset
|
825 | } |
|
704de181d1d2
Let's request
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33430
diff
changeset
|
826 | } |
|
704de181d1d2
Let's request
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33430
diff
changeset
|
827 | |
|
33433
fb7ac52ed7df
Let's get response contents
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33432
diff
changeset
|
828 | 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
|
829 | const gchar *buf, int len) |
|
9c4acb75b2e6
Let's parse response headers
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33431
diff
changeset
|
830 | { |
|
9c4acb75b2e6
Let's parse response headers
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33431
diff
changeset
|
831 | gchar *eol, *delim; |
|
9c4acb75b2e6
Let's parse response headers
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33431
diff
changeset
|
832 | |
|
33435
ab0560aa8ca4
Segfault shotgun debugging
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33434
diff
changeset
|
833 | if (hc->headers_got) { |
|
ab0560aa8ca4
Segfault shotgun debugging
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33434
diff
changeset
|
834 | purple_debug_error("http", "Headers already got\n"); |
|
ab0560aa8ca4
Segfault shotgun debugging
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33434
diff
changeset
|
835 | _purple_http_error(hc, _("Error parsing HTTP")); |
|
ab0560aa8ca4
Segfault shotgun debugging
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33434
diff
changeset
|
836 | return FALSE; |
|
ab0560aa8ca4
Segfault shotgun debugging
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33434
diff
changeset
|
837 | } |
|
ab0560aa8ca4
Segfault shotgun debugging
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33434
diff
changeset
|
838 | |
|
33443
ab563d4c927a
Don't eat resources with malicious http server
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33439
diff
changeset
|
839 | 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
|
840 | 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
|
841 | purple_debug_error("http", |
|
ab563d4c927a
Don't eat resources with malicious http server
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33439
diff
changeset
|
842 | "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
|
843 | _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
|
844 | return FALSE; |
|
ab563d4c927a
Don't eat resources with malicious http server
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33439
diff
changeset
|
845 | } |
|
ab563d4c927a
Don't eat resources with malicious http server
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33439
diff
changeset
|
846 | |
|
33432
9c4acb75b2e6
Let's parse response headers
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33431
diff
changeset
|
847 | 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
|
848 | != NULL) { |
|
9c4acb75b2e6
Let's parse response headers
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33431
diff
changeset
|
849 | gchar *hdrline = hc->response_buffer->str; |
|
9c4acb75b2e6
Let's parse response headers
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33431
diff
changeset
|
850 | int hdrline_len = eol - hdrline; |
|
9c4acb75b2e6
Let's parse response headers
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33431
diff
changeset
|
851 | |
|
9c4acb75b2e6
Let's parse response headers
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33431
diff
changeset
|
852 | hdrline[hdrline_len] = '\0'; |
|
9c4acb75b2e6
Let's parse response headers
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33431
diff
changeset
|
853 | |
|
9c4acb75b2e6
Let's parse response headers
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33431
diff
changeset
|
854 | if (hdrline[0] == '\0') { |
|
34260
7a55eaa31da6
HTTP: implement keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34257
diff
changeset
|
855 | if (!hc->main_header_got && hc->is_keepalive) { |
|
7a55eaa31da6
HTTP: implement keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34257
diff
changeset
|
856 | if (purple_debug_is_verbose()) { |
|
7a55eaa31da6
HTTP: implement keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34257
diff
changeset
|
857 | purple_debug_misc("http", "Got keep-" |
|
7a55eaa31da6
HTTP: implement keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34257
diff
changeset
|
858 | "alive terminator from previous" |
|
7a55eaa31da6
HTTP: implement keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34257
diff
changeset
|
859 | " request\n"); |
|
7a55eaa31da6
HTTP: implement keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34257
diff
changeset
|
860 | } |
|
7a55eaa31da6
HTTP: implement keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34257
diff
changeset
|
861 | } else if (!hc->main_header_got) { |
|
33432
9c4acb75b2e6
Let's parse response headers
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33431
diff
changeset
|
862 | hc->response->code = 0; |
|
33433
fb7ac52ed7df
Let's get response contents
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33432
diff
changeset
|
863 | purple_debug_warning("http", |
|
fb7ac52ed7df
Let's get response contents
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33432
diff
changeset
|
864 | "Main header not present\n"); |
|
33432
9c4acb75b2e6
Let's parse response headers
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33431
diff
changeset
|
865 | _purple_http_error(hc, _("Error parsing HTTP")); |
|
33433
fb7ac52ed7df
Let's get response contents
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33432
diff
changeset
|
866 | return FALSE; |
|
34260
7a55eaa31da6
HTTP: implement keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34257
diff
changeset
|
867 | } else /* hc->main_header_got */ { |
|
7a55eaa31da6
HTTP: implement keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34257
diff
changeset
|
868 | hc->headers_got = TRUE; |
|
7a55eaa31da6
HTTP: implement keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34257
diff
changeset
|
869 | if (purple_debug_is_verbose()) { |
|
7a55eaa31da6
HTTP: implement keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34257
diff
changeset
|
870 | purple_debug_misc("http", "Got headers " |
|
7a55eaa31da6
HTTP: implement keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34257
diff
changeset
|
871 | "end\n"); |
|
7a55eaa31da6
HTTP: implement keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34257
diff
changeset
|
872 | } |
|
33432
9c4acb75b2e6
Let's parse response headers
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33431
diff
changeset
|
873 | } |
|
9c4acb75b2e6
Let's parse response headers
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33431
diff
changeset
|
874 | } else if (!hc->main_header_got) { |
|
9c4acb75b2e6
Let's parse response headers
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33431
diff
changeset
|
875 | hc->main_header_got = TRUE; |
|
9c4acb75b2e6
Let's parse response headers
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33431
diff
changeset
|
876 | delim = strchr(hdrline, ' '); |
|
9c4acb75b2e6
Let's parse response headers
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33431
diff
changeset
|
877 | if (delim == NULL || 1 != sscanf(delim + 1, "%d", |
|
9c4acb75b2e6
Let's parse response headers
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33431
diff
changeset
|
878 | &hc->response->code)) { |
|
33433
fb7ac52ed7df
Let's get response contents
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33432
diff
changeset
|
879 | purple_debug_warning("http", |
|
fb7ac52ed7df
Let's get response contents
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33432
diff
changeset
|
880 | "Invalid response code\n"); |
|
33432
9c4acb75b2e6
Let's parse response headers
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33431
diff
changeset
|
881 | _purple_http_error(hc, _("Error parsing HTTP")); |
|
33433
fb7ac52ed7df
Let's get response contents
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33432
diff
changeset
|
882 | return FALSE; |
|
33432
9c4acb75b2e6
Let's parse response headers
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33431
diff
changeset
|
883 | } |
|
33433
fb7ac52ed7df
Let's get response contents
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33432
diff
changeset
|
884 | if (purple_debug_is_verbose()) |
|
33453
3cb58ea9667c
HTTP Proxy support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33452
diff
changeset
|
885 | purple_debug_misc("http", |
|
3cb58ea9667c
HTTP Proxy support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33452
diff
changeset
|
886 | "Got main header with code %d\n", |
|
3cb58ea9667c
HTTP Proxy support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33452
diff
changeset
|
887 | hc->response->code); |
|
33432
9c4acb75b2e6
Let's parse response headers
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33431
diff
changeset
|
888 | } else { |
|
33433
fb7ac52ed7df
Let's get response contents
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33432
diff
changeset
|
889 | if (purple_debug_is_verbose() && |
|
fb7ac52ed7df
Let's get response contents
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33432
diff
changeset
|
890 | purple_debug_is_unsafe()) |
|
fb7ac52ed7df
Let's get response contents
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33432
diff
changeset
|
891 | purple_debug_misc("http", "Got header: %s\n", |
|
fb7ac52ed7df
Let's get response contents
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33432
diff
changeset
|
892 | hdrline); |
|
33432
9c4acb75b2e6
Let's parse response headers
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33431
diff
changeset
|
893 | delim = strchr(hdrline, ':'); |
|
9c4acb75b2e6
Let's parse response headers
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33431
diff
changeset
|
894 | if (delim == NULL || delim == hdrline) { |
|
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 | "Bad header delimiter\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 | } |
|
9c4acb75b2e6
Let's parse response headers
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33431
diff
changeset
|
900 | *delim++ = '\0'; |
|
9c4acb75b2e6
Let's parse response headers
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33431
diff
changeset
|
901 | while (*delim == ' ') |
|
9c4acb75b2e6
Let's parse response headers
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33431
diff
changeset
|
902 | delim++; |
|
9c4acb75b2e6
Let's parse response headers
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33431
diff
changeset
|
903 | |
|
9c4acb75b2e6
Let's parse response headers
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33431
diff
changeset
|
904 | 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
|
905 | } |
|
9c4acb75b2e6
Let's parse response headers
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33431
diff
changeset
|
906 | |
|
9c4acb75b2e6
Let's parse response headers
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33431
diff
changeset
|
907 | 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
|
908 | if (hc->headers_got) |
|
fb7ac52ed7df
Let's get response contents
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33432
diff
changeset
|
909 | break; |
|
33432
9c4acb75b2e6
Let's parse response headers
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33431
diff
changeset
|
910 | } |
|
33433
fb7ac52ed7df
Let's get response contents
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33432
diff
changeset
|
911 | return TRUE; |
|
fb7ac52ed7df
Let's get response contents
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33432
diff
changeset
|
912 | } |
|
fb7ac52ed7df
Let's get response contents
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33432
diff
changeset
|
913 | |
|
33517
ddd9e37c4b07
HTTP: PurpleHttpContentWriter support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33469
diff
changeset
|
914 | 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
|
915 | const gchar *buf, int len) |
|
ec4f343af107
Chunked file transfers support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33433
diff
changeset
|
916 | { |
|
33517
ddd9e37c4b07
HTTP: PurpleHttpContentWriter support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33469
diff
changeset
|
917 | int current_offset = hc->data_length_got; |
|
ddd9e37c4b07
HTTP: PurpleHttpContentWriter support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33469
diff
changeset
|
918 | |
|
33446
95fda782966c
New feature: setting maximum length of response
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33445
diff
changeset
|
919 | if (hc->request->max_length >= 0) { |
|
95fda782966c
New feature: setting maximum length of response
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33445
diff
changeset
|
920 | if (hc->data_length_got + len > hc->request->max_length) { |
|
95fda782966c
New feature: setting maximum length of response
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33445
diff
changeset
|
921 | len = hc->request->max_length - hc->data_length_got; |
|
95fda782966c
New feature: setting maximum length of response
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33445
diff
changeset
|
922 | hc->length_expected = hc->length_got; |
|
95fda782966c
New feature: setting maximum length of response
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33445
diff
changeset
|
923 | } |
|
33517
ddd9e37c4b07
HTTP: PurpleHttpContentWriter support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33469
diff
changeset
|
924 | } |
|
ddd9e37c4b07
HTTP: PurpleHttpContentWriter support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33469
diff
changeset
|
925 | hc->data_length_got += len; |
|
ddd9e37c4b07
HTTP: PurpleHttpContentWriter support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33469
diff
changeset
|
926 | |
|
ddd9e37c4b07
HTTP: PurpleHttpContentWriter support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33469
diff
changeset
|
927 | if (len == 0) |
|
ddd9e37c4b07
HTTP: PurpleHttpContentWriter support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33469
diff
changeset
|
928 | return TRUE; |
|
ddd9e37c4b07
HTTP: PurpleHttpContentWriter support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33469
diff
changeset
|
929 | |
|
ddd9e37c4b07
HTTP: PurpleHttpContentWriter support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33469
diff
changeset
|
930 | if (hc->request->response_writer != NULL) { |
|
ddd9e37c4b07
HTTP: PurpleHttpContentWriter support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33469
diff
changeset
|
931 | gboolean succ; |
|
ddd9e37c4b07
HTTP: PurpleHttpContentWriter support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33469
diff
changeset
|
932 | succ = hc->request->response_writer(hc, hc->response, buf, |
|
ddd9e37c4b07
HTTP: PurpleHttpContentWriter support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33469
diff
changeset
|
933 | current_offset, len, hc->request->response_writer_data); |
|
ddd9e37c4b07
HTTP: PurpleHttpContentWriter support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33469
diff
changeset
|
934 | if (!succ) { |
|
ddd9e37c4b07
HTTP: PurpleHttpContentWriter support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33469
diff
changeset
|
935 | purple_debug_error("http", |
|
ddd9e37c4b07
HTTP: PurpleHttpContentWriter support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33469
diff
changeset
|
936 | "Cannot write using callback\n"); |
|
ddd9e37c4b07
HTTP: PurpleHttpContentWriter support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33469
diff
changeset
|
937 | _purple_http_error(hc, |
|
ddd9e37c4b07
HTTP: PurpleHttpContentWriter support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33469
diff
changeset
|
938 | _("Error handling retrieved data")); |
|
ddd9e37c4b07
HTTP: PurpleHttpContentWriter support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33469
diff
changeset
|
939 | return FALSE; |
|
ddd9e37c4b07
HTTP: PurpleHttpContentWriter support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33469
diff
changeset
|
940 | } |
|
ddd9e37c4b07
HTTP: PurpleHttpContentWriter support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33469
diff
changeset
|
941 | } else { |
|
ddd9e37c4b07
HTTP: PurpleHttpContentWriter support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33469
diff
changeset
|
942 | if (hc->response->contents == NULL) |
|
ddd9e37c4b07
HTTP: PurpleHttpContentWriter support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33469
diff
changeset
|
943 | hc->response->contents = g_string_new(""); |
|
ddd9e37c4b07
HTTP: PurpleHttpContentWriter support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33469
diff
changeset
|
944 | 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
|
945 | } |
|
95fda782966c
New feature: setting maximum length of response
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33445
diff
changeset
|
946 | |
|
33468
b057fee9d11a
HTTP progress watcher support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33466
diff
changeset
|
947 | purple_http_conn_notify_progress_watcher(hc); |
|
33517
ddd9e37c4b07
HTTP: PurpleHttpContentWriter support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33469
diff
changeset
|
948 | return TRUE; |
|
33434
ec4f343af107
Chunked file transfers support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33433
diff
changeset
|
949 | } |
|
ec4f343af107
Chunked file transfers support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33433
diff
changeset
|
950 | |
|
ec4f343af107
Chunked file transfers support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33433
diff
changeset
|
951 | static gboolean _purple_http_recv_body_chunked(PurpleHttpConnection *hc, |
|
ec4f343af107
Chunked file transfers support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33433
diff
changeset
|
952 | const gchar *buf, int len) |
|
ec4f343af107
Chunked file transfers support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33433
diff
changeset
|
953 | { |
|
ec4f343af107
Chunked file transfers support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33433
diff
changeset
|
954 | gchar *eol, *line; |
|
ec4f343af107
Chunked file transfers support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33433
diff
changeset
|
955 | int line_len; |
|
ec4f343af107
Chunked file transfers support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33433
diff
changeset
|
956 | |
|
ec4f343af107
Chunked file transfers support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33433
diff
changeset
|
957 | if (hc->chunks_done) |
|
ec4f343af107
Chunked file transfers support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33433
diff
changeset
|
958 | return FALSE; |
|
ec4f343af107
Chunked file transfers support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33433
diff
changeset
|
959 | if (!hc->response_buffer) |
|
ec4f343af107
Chunked file transfers support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33433
diff
changeset
|
960 | hc->response_buffer = g_string_new(""); |
|
33436
abec627c3a47
Segfault found, temporarily fixed
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33435
diff
changeset
|
961 | |
|
33443
ab563d4c927a
Don't eat resources with malicious http server
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33439
diff
changeset
|
962 | 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
|
963 | 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
|
964 | purple_debug_error("http", |
|
ab563d4c927a
Don't eat resources with malicious http server
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33439
diff
changeset
|
965 | "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
|
966 | _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
|
967 | return FALSE; |
|
ab563d4c927a
Don't eat resources with malicious http server
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33439
diff
changeset
|
968 | } |
|
ab563d4c927a
Don't eat resources with malicious http server
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33439
diff
changeset
|
969 | |
|
33434
ec4f343af107
Chunked file transfers support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33433
diff
changeset
|
970 | while (hc->response_buffer->len > 0) { |
|
ec4f343af107
Chunked file transfers support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33433
diff
changeset
|
971 | if (hc->in_chunk) { |
|
ec4f343af107
Chunked file transfers support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33433
diff
changeset
|
972 | int got_now = hc->response_buffer->len; |
|
ec4f343af107
Chunked file transfers support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33433
diff
changeset
|
973 | if (hc->chunk_got + got_now > hc->chunk_length) |
|
ec4f343af107
Chunked file transfers support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33433
diff
changeset
|
974 | got_now = hc->chunk_length - hc->chunk_got; |
|
ec4f343af107
Chunked file transfers support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33433
diff
changeset
|
975 | hc->chunk_got += got_now; |
|
ec4f343af107
Chunked file transfers support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33433
diff
changeset
|
976 | |
|
33517
ddd9e37c4b07
HTTP: PurpleHttpContentWriter support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33469
diff
changeset
|
977 | if (!_purple_http_recv_body_data(hc, |
|
ddd9e37c4b07
HTTP: PurpleHttpContentWriter support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33469
diff
changeset
|
978 | hc->response_buffer->str, got_now)) |
|
ddd9e37c4b07
HTTP: PurpleHttpContentWriter support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33469
diff
changeset
|
979 | return FALSE; |
|
33459
722a6d753cb2
Better cookies, better chunked transfer support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33458
diff
changeset
|
980 | |
|
33434
ec4f343af107
Chunked file transfers support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33433
diff
changeset
|
981 | g_string_erase(hc->response_buffer, 0, got_now); |
|
ec4f343af107
Chunked file transfers support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33433
diff
changeset
|
982 | hc->in_chunk = (hc->chunk_got < hc->chunk_length); |
|
ec4f343af107
Chunked file transfers support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33433
diff
changeset
|
983 | |
|
ec4f343af107
Chunked file transfers support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33433
diff
changeset
|
984 | if (purple_debug_is_verbose()) |
|
ec4f343af107
Chunked file transfers support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33433
diff
changeset
|
985 | purple_debug_misc("http", "Chunk (%d/%d)\n", |
|
ec4f343af107
Chunked file transfers support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33433
diff
changeset
|
986 | hc->chunk_got, hc->chunk_length); |
|
ec4f343af107
Chunked file transfers support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33433
diff
changeset
|
987 | |
|
ec4f343af107
Chunked file transfers support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33433
diff
changeset
|
988 | continue; |
|
ec4f343af107
Chunked file transfers support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33433
diff
changeset
|
989 | } |
|
ec4f343af107
Chunked file transfers support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33433
diff
changeset
|
990 | |
|
ec4f343af107
Chunked file transfers support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33433
diff
changeset
|
991 | line = hc->response_buffer->str; |
|
ec4f343af107
Chunked file transfers support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33433
diff
changeset
|
992 | eol = strstr(line, "\r\n"); |
|
33459
722a6d753cb2
Better cookies, better chunked transfer support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33458
diff
changeset
|
993 | if (eol == line) { |
|
722a6d753cb2
Better cookies, better chunked transfer support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33458
diff
changeset
|
994 | 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
|
995 | line = hc->response_buffer->str; |
|
722a6d753cb2
Better cookies, better chunked transfer support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33458
diff
changeset
|
996 | eol = strstr(line, "\r\n"); |
|
722a6d753cb2
Better cookies, better chunked transfer support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33458
diff
changeset
|
997 | } |
|
33434
ec4f343af107
Chunked file transfers support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33433
diff
changeset
|
998 | if (eol == NULL) { |
|
ec4f343af107
Chunked file transfers support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33433
diff
changeset
|
999 | /* waiting for more data (unlikely, but possible) */ |
|
ec4f343af107
Chunked file transfers support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33433
diff
changeset
|
1000 | if (hc->response_buffer->len > 20) { |
|
ec4f343af107
Chunked file transfers support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33433
diff
changeset
|
1001 | purple_debug_warning("http", "Chunk length not " |
|
ec4f343af107
Chunked file transfers support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33433
diff
changeset
|
1002 | "found (buffer too large)\n"); |
|
ec4f343af107
Chunked file transfers support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33433
diff
changeset
|
1003 | _purple_http_error(hc, _("Error parsing HTTP")); |
|
ec4f343af107
Chunked file transfers support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33433
diff
changeset
|
1004 | return FALSE; |
|
ec4f343af107
Chunked file transfers support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33433
diff
changeset
|
1005 | } |
|
ec4f343af107
Chunked file transfers support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33433
diff
changeset
|
1006 | return TRUE; |
|
ec4f343af107
Chunked file transfers support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33433
diff
changeset
|
1007 | } |
|
ec4f343af107
Chunked file transfers support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33433
diff
changeset
|
1008 | line_len = eol - line; |
|
ec4f343af107
Chunked file transfers support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33433
diff
changeset
|
1009 | |
|
ec4f343af107
Chunked file transfers support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33433
diff
changeset
|
1010 | if (1 != sscanf(line, "%x", &hc->chunk_length)) { |
|
33450
4042907bcdf1
Timeout support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33448
diff
changeset
|
1011 | if (purple_debug_is_unsafe()) |
|
4042907bcdf1
Timeout support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33448
diff
changeset
|
1012 | purple_debug_warning("http", |
|
4042907bcdf1
Timeout support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33448
diff
changeset
|
1013 | "Chunk length not found in [%s]\n", |
|
4042907bcdf1
Timeout support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33448
diff
changeset
|
1014 | line); |
|
4042907bcdf1
Timeout support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33448
diff
changeset
|
1015 | else |
|
4042907bcdf1
Timeout support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33448
diff
changeset
|
1016 | purple_debug_warning("http", |
|
4042907bcdf1
Timeout support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33448
diff
changeset
|
1017 | "Chunk length not found\n"); |
|
33434
ec4f343af107
Chunked file transfers support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33433
diff
changeset
|
1018 | _purple_http_error(hc, _("Error parsing HTTP")); |
|
ec4f343af107
Chunked file transfers support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33433
diff
changeset
|
1019 | return FALSE; |
|
ec4f343af107
Chunked file transfers support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33433
diff
changeset
|
1020 | } |
|
ec4f343af107
Chunked file transfers support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33433
diff
changeset
|
1021 | hc->chunk_got = 0; |
|
ec4f343af107
Chunked file transfers support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33433
diff
changeset
|
1022 | hc->in_chunk = TRUE; |
|
ec4f343af107
Chunked file transfers support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33433
diff
changeset
|
1023 | |
|
ec4f343af107
Chunked file transfers support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33433
diff
changeset
|
1024 | if (purple_debug_is_verbose()) |
|
ec4f343af107
Chunked file transfers support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33433
diff
changeset
|
1025 | 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
|
1026 | |
|
ec4f343af107
Chunked file transfers support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33433
diff
changeset
|
1027 | 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
|
1028 | |
|
ec4f343af107
Chunked file transfers support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33433
diff
changeset
|
1029 | if (hc->chunk_length == 0) { |
|
ec4f343af107
Chunked file transfers support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33433
diff
changeset
|
1030 | hc->chunks_done = TRUE; |
|
ec4f343af107
Chunked file transfers support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33433
diff
changeset
|
1031 | hc->in_chunk = FALSE; |
|
ec4f343af107
Chunked file transfers support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33433
diff
changeset
|
1032 | return TRUE; |
|
ec4f343af107
Chunked file transfers support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33433
diff
changeset
|
1033 | } |
|
ec4f343af107
Chunked file transfers support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33433
diff
changeset
|
1034 | } |
|
ec4f343af107
Chunked file transfers support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33433
diff
changeset
|
1035 | |
|
ec4f343af107
Chunked file transfers support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33433
diff
changeset
|
1036 | return TRUE; |
|
ec4f343af107
Chunked file transfers support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33433
diff
changeset
|
1037 | } |
|
ec4f343af107
Chunked file transfers support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33433
diff
changeset
|
1038 | |
|
ec4f343af107
Chunked file transfers support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33433
diff
changeset
|
1039 | 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
|
1040 | const gchar *buf, int len) |
|
fb7ac52ed7df
Let's get response contents
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33432
diff
changeset
|
1041 | { |
|
33434
ec4f343af107
Chunked file transfers support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33433
diff
changeset
|
1042 | if (hc->is_chunked) |
|
33435
ab0560aa8ca4
Segfault shotgun debugging
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33434
diff
changeset
|
1043 | { |
|
ab0560aa8ca4
Segfault shotgun debugging
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33434
diff
changeset
|
1044 | hc->length_got += len; |
|
33434
ec4f343af107
Chunked file transfers support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33433
diff
changeset
|
1045 | return _purple_http_recv_body_chunked(hc, buf, len); |
|
33435
ab0560aa8ca4
Segfault shotgun debugging
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33434
diff
changeset
|
1046 | } |
|
33433
fb7ac52ed7df
Let's get response contents
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33432
diff
changeset
|
1047 | |
|
33434
ec4f343af107
Chunked file transfers support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33433
diff
changeset
|
1048 | if (hc->length_expected >= 0 && |
|
ec4f343af107
Chunked file transfers support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33433
diff
changeset
|
1049 | len + hc->length_got > hc->length_expected) |
|
33433
fb7ac52ed7df
Let's get response contents
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33432
diff
changeset
|
1050 | len = hc->length_expected - hc->length_got; |
|
fb7ac52ed7df
Let's get response contents
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33432
diff
changeset
|
1051 | hc->length_got += len; |
|
fb7ac52ed7df
Let's get response contents
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33432
diff
changeset
|
1052 | |
|
33517
ddd9e37c4b07
HTTP: PurpleHttpContentWriter support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33469
diff
changeset
|
1053 | 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
|
1054 | } |
|
9c4acb75b2e6
Let's parse response headers
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33431
diff
changeset
|
1055 | |
|
33522
7a3d131c3086
HTTP: don't freeze download on files larger than buffer size
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33521
diff
changeset
|
1056 | 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
|
1057 | { |
|
704de181d1d2
Let's request
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33430
diff
changeset
|
1058 | int len; |
|
33432
9c4acb75b2e6
Let's parse response headers
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33431
diff
changeset
|
1059 | 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
|
1060 | gboolean got_anything; |
|
33431
704de181d1d2
Let's request
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33430
diff
changeset
|
1061 | |
|
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
|
1062 | 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
|
1063 | got_anything = (len > 0); |
|
33431
704de181d1d2
Let's request
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33430
diff
changeset
|
1064 | |
|
704de181d1d2
Let's request
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33430
diff
changeset
|
1065 | 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
|
1066 | return FALSE; |
|
33431
704de181d1d2
Let's request
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33430
diff
changeset
|
1067 | |
|
704de181d1d2
Let's request
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33430
diff
changeset
|
1068 | if (len < 0) { |
|
704de181d1d2
Let's request
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33430
diff
changeset
|
1069 | _purple_http_error(hc, _("Error reading from %s: %s"), |
|
704de181d1d2
Let's request
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33430
diff
changeset
|
1070 | 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
|
1071 | return FALSE; |
|
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 | |
|
33439
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
1074 | /* EOF */ |
|
33435
ab0560aa8ca4
Segfault shotgun debugging
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33434
diff
changeset
|
1075 | if (len == 0) { |
|
ab0560aa8ca4
Segfault shotgun debugging
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33434
diff
changeset
|
1076 | if (hc->length_expected >= 0 && |
|
ab0560aa8ca4
Segfault shotgun debugging
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33434
diff
changeset
|
1077 | hc->length_got < hc->length_expected) { |
|
ab0560aa8ca4
Segfault shotgun debugging
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33434
diff
changeset
|
1078 | purple_debug_warning("http", "No more data while reading" |
|
ab0560aa8ca4
Segfault shotgun debugging
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33434
diff
changeset
|
1079 | " contents\n"); |
|
ab0560aa8ca4
Segfault shotgun debugging
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33434
diff
changeset
|
1080 | _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
|
1081 | return FALSE; |
|
33435
ab0560aa8ca4
Segfault shotgun debugging
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33434
diff
changeset
|
1082 | } |
|
ab0560aa8ca4
Segfault shotgun debugging
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33434
diff
changeset
|
1083 | if (hc->headers_got) |
|
ab0560aa8ca4
Segfault shotgun debugging
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33434
diff
changeset
|
1084 | hc->length_expected = hc->length_got; |
|
34260
7a55eaa31da6
HTTP: implement keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34257
diff
changeset
|
1085 | 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
|
1086 | purple_debug_info("http", "Keep-alive connection " |
|
7a55eaa31da6
HTTP: implement keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34257
diff
changeset
|
1087 | "expired, retrying...\n"); |
|
7a55eaa31da6
HTTP: implement keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34257
diff
changeset
|
1088 | purple_http_conn_retry(hc); |
|
7a55eaa31da6
HTTP: implement keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34257
diff
changeset
|
1089 | return FALSE; |
|
7a55eaa31da6
HTTP: implement keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34257
diff
changeset
|
1090 | } else { |
|
33435
ab0560aa8ca4
Segfault shotgun debugging
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33434
diff
changeset
|
1091 | purple_debug_warning("http", "No more data while " |
|
ab0560aa8ca4
Segfault shotgun debugging
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33434
diff
changeset
|
1092 | "parsing headers\n"); |
|
ab0560aa8ca4
Segfault shotgun debugging
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33434
diff
changeset
|
1093 | _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
|
1094 | return FALSE; |
|
33435
ab0560aa8ca4
Segfault shotgun debugging
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33434
diff
changeset
|
1095 | } |
|
ab0560aa8ca4
Segfault shotgun debugging
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33434
diff
changeset
|
1096 | } |
|
33433
fb7ac52ed7df
Let's get response contents
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33432
diff
changeset
|
1097 | |
|
fb7ac52ed7df
Let's get response contents
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33432
diff
changeset
|
1098 | if (!hc->headers_got && len > 0) { |
|
fb7ac52ed7df
Let's get response contents
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33432
diff
changeset
|
1099 | 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
|
1100 | return FALSE; |
|
33459
722a6d753cb2
Better cookies, better chunked transfer support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33458
diff
changeset
|
1101 | len = 0; |
|
33433
fb7ac52ed7df
Let's get response contents
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33432
diff
changeset
|
1102 | if (hc->headers_got) { |
|
fb7ac52ed7df
Let's get response contents
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33432
diff
changeset
|
1103 | 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
|
1104 | "Content-Length", &hc->length_expected)) |
|
fb7ac52ed7df
Let's get response contents
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33432
diff
changeset
|
1105 | hc->length_expected = -1; |
|
33434
ec4f343af107
Chunked file transfers support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33433
diff
changeset
|
1106 | hc->is_chunked = (purple_http_headers_match( |
|
ec4f343af107
Chunked file transfers support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33433
diff
changeset
|
1107 | hc->response->headers, |
|
ec4f343af107
Chunked file transfers support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33433
diff
changeset
|
1108 | "Transfer-Encoding", "chunked")); |
|
ec4f343af107
Chunked file transfers support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33433
diff
changeset
|
1109 | } |
|
ec4f343af107
Chunked file transfers support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33433
diff
changeset
|
1110 | if (hc->headers_got && hc->response_buffer && |
|
ec4f343af107
Chunked file transfers support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33433
diff
changeset
|
1111 | hc->response_buffer->len > 0) { |
|
ec4f343af107
Chunked file transfers support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33433
diff
changeset
|
1112 | int buffer_len = hc->response_buffer->len; |
|
ec4f343af107
Chunked file transfers support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33433
diff
changeset
|
1113 | gchar *buffer = g_string_free(hc->response_buffer, FALSE); |
|
ec4f343af107
Chunked file transfers support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33433
diff
changeset
|
1114 | hc->response_buffer = NULL; |
|
ec4f343af107
Chunked file transfers support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33433
diff
changeset
|
1115 | _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
|
1116 | } |
|
33455
2de654702970
Print-like setting headers, vestigal keepalive support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33454
diff
changeset
|
1117 | 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
|
1118 | return got_anything; |
|
33433
fb7ac52ed7df
Let's get response contents
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33432
diff
changeset
|
1119 | } |
|
fb7ac52ed7df
Let's get response contents
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33432
diff
changeset
|
1120 | |
|
33434
ec4f343af107
Chunked file transfers support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33433
diff
changeset
|
1121 | if (len > 0) { |
|
ec4f343af107
Chunked file transfers support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33433
diff
changeset
|
1122 | 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
|
1123 | return FALSE; |
|
33434
ec4f343af107
Chunked file transfers support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33433
diff
changeset
|
1124 | } |
|
33433
fb7ac52ed7df
Let's get response contents
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33432
diff
changeset
|
1125 | |
|
33434
ec4f343af107
Chunked file transfers support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33433
diff
changeset
|
1126 | if (hc->is_chunked && hc->chunks_done) |
|
ec4f343af107
Chunked file transfers support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33433
diff
changeset
|
1127 | hc->length_expected = hc->length_got; |
|
ec4f343af107
Chunked file transfers support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33433
diff
changeset
|
1128 | |
|
ec4f343af107
Chunked file transfers support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33433
diff
changeset
|
1129 | 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
|
1130 | const gchar *redirect; |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
1131 | |
|
33432
9c4acb75b2e6
Let's parse response headers
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33431
diff
changeset
|
1132 | if (!hc->headers_got) { |
|
9c4acb75b2e6
Let's parse response headers
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33431
diff
changeset
|
1133 | hc->response->code = 0; |
|
33433
fb7ac52ed7df
Let's get response contents
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33432
diff
changeset
|
1134 | 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
|
1135 | _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
|
1136 | return FALSE; |
|
33432
9c4acb75b2e6
Let's parse response headers
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33431
diff
changeset
|
1137 | } |
|
9c4acb75b2e6
Let's parse response headers
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33431
diff
changeset
|
1138 | |
|
9c4acb75b2e6
Let's parse response headers
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33431
diff
changeset
|
1139 | 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
|
1140 | gchar *hdrs = purple_http_headers_dump( |
|
9c4acb75b2e6
Let's parse response headers
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33431
diff
changeset
|
1141 | hc->response->headers); |
|
9c4acb75b2e6
Let's parse response headers
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33431
diff
changeset
|
1142 | 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
|
1143 | hdrs); |
|
9c4acb75b2e6
Let's parse response headers
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33431
diff
changeset
|
1144 | g_free(hdrs); |
|
9c4acb75b2e6
Let's parse response headers
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33431
diff
changeset
|
1145 | } |
|
9c4acb75b2e6
Let's parse response headers
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33431
diff
changeset
|
1146 | |
|
33456
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
1147 | purple_http_cookie_jar_parse(hc->request->cookie_jar, |
|
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
1148 | purple_http_headers_get_all_by_name( |
|
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
1149 | hc->response->headers, "Set-Cookie")); |
|
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
1150 | |
|
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
1151 | if (purple_debug_is_unsafe() && purple_debug_is_verbose() && |
|
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
1152 | !purple_http_cookie_jar_is_empty( |
|
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
1153 | hc->request->cookie_jar)) { |
|
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
1154 | gchar *cookies = purple_http_cookie_jar_dump( |
|
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
1155 | hc->request->cookie_jar); |
|
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
1156 | purple_debug_misc("http", "Cookies: %s\n", cookies); |
|
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
1157 | g_free(cookies); |
|
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
1158 | } |
|
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
1159 | |
|
33453
3cb58ea9667c
HTTP Proxy support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33452
diff
changeset
|
1160 | if (hc->response->code == 407) { |
|
3cb58ea9667c
HTTP Proxy support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33452
diff
changeset
|
1161 | _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
|
1162 | return FALSE; |
|
33453
3cb58ea9667c
HTTP Proxy support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33452
diff
changeset
|
1163 | } |
|
3cb58ea9667c
HTTP Proxy support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33452
diff
changeset
|
1164 | |
|
33439
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
1165 | redirect = purple_http_headers_get(hc->response->headers, |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
1166 | "location"); |
|
33445
1bcbdca07787
Allow infinite amount of redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33444
diff
changeset
|
1167 | if (redirect && (hc->request->max_redirects == -1 || |
|
1bcbdca07787
Allow infinite amount of redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33444
diff
changeset
|
1168 | hc->request->max_redirects > hc->redirects_count)) { |
|
33439
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
1169 | PurpleHttpURL *url = purple_http_url_parse(redirect); |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
1170 | |
|
33444
b3afec292014
New features: http version switching and limits for redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33443
diff
changeset
|
1171 | hc->redirects_count++; |
|
b3afec292014
New features: http version switching and limits for redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33443
diff
changeset
|
1172 | |
|
33439
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
1173 | if (!url) { |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
1174 | if (purple_debug_is_unsafe()) |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
1175 | purple_debug_warning("http", |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
1176 | "Invalid redirect to %s\n", |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
1177 | redirect); |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
1178 | else |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
1179 | purple_debug_warning("http", |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
1180 | "Invalid redirect\n"); |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
1181 | _purple_http_error(hc, _("Error parsing HTTP")); |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
1182 | } |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
1183 | |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
1184 | purple_http_url_relative(hc->url, url); |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
1185 | purple_http_url_free(url); |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
1186 | |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
1187 | _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
|
1188 | return FALSE; |
|
33439
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
1189 | } |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
1190 | |
|
34260
7a55eaa31da6
HTTP: implement keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34257
diff
changeset
|
1191 | _purple_http_disconnect(hc, TRUE); |
|
33432
9c4acb75b2e6
Let's parse response headers
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33431
diff
changeset
|
1192 | 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
|
1193 | return FALSE; |
|
33432
9c4acb75b2e6
Let's parse response headers
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33431
diff
changeset
|
1194 | } |
|
33522
7a3d131c3086
HTTP: don't freeze download on files larger than buffer size
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33521
diff
changeset
|
1195 | |
|
7a3d131c3086
HTTP: don't freeze download on files larger than buffer size
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33521
diff
changeset
|
1196 | 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
|
1197 | } |
|
7a3d131c3086
HTTP: don't freeze download on files larger than buffer size
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33521
diff
changeset
|
1198 | |
|
7a3d131c3086
HTTP: don't freeze download on files larger than buffer size
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33521
diff
changeset
|
1199 | 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
|
1200 | { |
|
7a3d131c3086
HTTP: don't freeze download on files larger than buffer size
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33521
diff
changeset
|
1201 | 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
|
1202 | |
|
7a3d131c3086
HTTP: don't freeze download on files larger than buffer size
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33521
diff
changeset
|
1203 | while (_purple_http_recv_loopbody(hc, fd)); |
|
33431
704de181d1d2
Let's request
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33430
diff
changeset
|
1204 | } |
|
704de181d1d2
Let's request
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33430
diff
changeset
|
1205 | |
|
33466
918507303f45
HTTP API: PurpleHttpContentReader support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33464
diff
changeset
|
1206 | static void _purple_http_send_got_data(PurpleHttpConnection *hc, |
|
918507303f45
HTTP API: PurpleHttpContentReader support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33464
diff
changeset
|
1207 | gboolean success, gboolean eof, size_t stored) |
|
918507303f45
HTTP API: PurpleHttpContentReader support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33464
diff
changeset
|
1208 | { |
|
918507303f45
HTTP API: PurpleHttpContentReader support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33464
diff
changeset
|
1209 | int estimated_length; |
|
918507303f45
HTTP API: PurpleHttpContentReader support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33464
diff
changeset
|
1210 | |
|
918507303f45
HTTP API: PurpleHttpContentReader support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33464
diff
changeset
|
1211 | g_return_if_fail(hc != NULL); |
|
918507303f45
HTTP API: PurpleHttpContentReader support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33464
diff
changeset
|
1212 | |
|
918507303f45
HTTP API: PurpleHttpContentReader support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33464
diff
changeset
|
1213 | if (!success) { |
|
918507303f45
HTTP API: PurpleHttpContentReader support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33464
diff
changeset
|
1214 | _purple_http_error(hc, _("Error requesting data to write")); |
|
918507303f45
HTTP API: PurpleHttpContentReader support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33464
diff
changeset
|
1215 | return; |
|
918507303f45
HTTP API: PurpleHttpContentReader support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33464
diff
changeset
|
1216 | } |
|
918507303f45
HTTP API: PurpleHttpContentReader support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33464
diff
changeset
|
1217 | |
|
918507303f45
HTTP API: PurpleHttpContentReader support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33464
diff
changeset
|
1218 | hc->contents_reader_requested = FALSE; |
|
918507303f45
HTTP API: PurpleHttpContentReader support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33464
diff
changeset
|
1219 | g_string_set_size(hc->contents_reader_buffer, stored); |
|
918507303f45
HTTP API: PurpleHttpContentReader support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33464
diff
changeset
|
1220 | if (!eof) |
|
918507303f45
HTTP API: PurpleHttpContentReader support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33464
diff
changeset
|
1221 | return; |
|
918507303f45
HTTP API: PurpleHttpContentReader support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33464
diff
changeset
|
1222 | |
|
918507303f45
HTTP API: PurpleHttpContentReader support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33464
diff
changeset
|
1223 | estimated_length = hc->request_contents_written + stored; |
|
918507303f45
HTTP API: PurpleHttpContentReader support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33464
diff
changeset
|
1224 | |
|
918507303f45
HTTP API: PurpleHttpContentReader support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33464
diff
changeset
|
1225 | if (hc->request->contents_length != -1 && |
|
918507303f45
HTTP API: PurpleHttpContentReader support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33464
diff
changeset
|
1226 | hc->request->contents_length != estimated_length) { |
|
918507303f45
HTTP API: PurpleHttpContentReader support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33464
diff
changeset
|
1227 | purple_debug_warning("http", |
|
918507303f45
HTTP API: PurpleHttpContentReader support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33464
diff
changeset
|
1228 | "Invalid amount of data has been written\n"); |
|
918507303f45
HTTP API: PurpleHttpContentReader support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33464
diff
changeset
|
1229 | } |
|
918507303f45
HTTP API: PurpleHttpContentReader support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33464
diff
changeset
|
1230 | hc->request->contents_length = estimated_length; |
|
918507303f45
HTTP API: PurpleHttpContentReader support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33464
diff
changeset
|
1231 | } |
|
918507303f45
HTTP API: PurpleHttpContentReader support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33464
diff
changeset
|
1232 | |
|
33430
013c5aebb665
Let's connect
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33429
diff
changeset
|
1233 | 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
|
1234 | { |
|
33430
013c5aebb665
Let's connect
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33429
diff
changeset
|
1235 | PurpleHttpConnection *hc = _hc; |
|
33431
704de181d1d2
Let's request
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33430
diff
changeset
|
1236 | int written, write_len; |
|
704de181d1d2
Let's request
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33430
diff
changeset
|
1237 | const gchar *write_from; |
|
33457
81f92a310aff
Writing request contents
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33456
diff
changeset
|
1238 | gboolean writing_headers; |
|
33431
704de181d1d2
Let's request
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33430
diff
changeset
|
1239 | |
|
33466
918507303f45
HTTP API: PurpleHttpContentReader support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33464
diff
changeset
|
1240 | /* 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
|
1241 | * (and later, adding) hs->inpa. */ |
|
918507303f45
HTTP API: PurpleHttpContentReader support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33464
diff
changeset
|
1242 | if (hc->contents_reader_requested) |
|
918507303f45
HTTP API: PurpleHttpContentReader support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33464
diff
changeset
|
1243 | return; |
|
918507303f45
HTTP API: PurpleHttpContentReader support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33464
diff
changeset
|
1244 | |
|
33431
704de181d1d2
Let's request
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33430
diff
changeset
|
1245 | _purple_http_gen_headers(hc); |
|
33430
013c5aebb665
Let's connect
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33429
diff
changeset
|
1246 | |
|
33457
81f92a310aff
Writing request contents
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33456
diff
changeset
|
1247 | writing_headers = |
|
81f92a310aff
Writing request contents
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33456
diff
changeset
|
1248 | (hc->request_header_written < hc->request_header->len); |
|
81f92a310aff
Writing request contents
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33456
diff
changeset
|
1249 | if (writing_headers) { |
|
81f92a310aff
Writing request contents
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33456
diff
changeset
|
1250 | write_from = hc->request_header->str + |
|
81f92a310aff
Writing request contents
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33456
diff
changeset
|
1251 | hc->request_header_written; |
|
81f92a310aff
Writing request contents
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33456
diff
changeset
|
1252 | write_len = hc->request_header->len - |
|
81f92a310aff
Writing request contents
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33456
diff
changeset
|
1253 | hc->request_header_written; |
|
33466
918507303f45
HTTP API: PurpleHttpContentReader support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33464
diff
changeset
|
1254 | } else if (hc->request->contents_reader) { |
|
918507303f45
HTTP API: PurpleHttpContentReader support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33464
diff
changeset
|
1255 | if (hc->contents_reader_requested) |
|
918507303f45
HTTP API: PurpleHttpContentReader support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33464
diff
changeset
|
1256 | return; /* waiting for data */ |
|
918507303f45
HTTP API: PurpleHttpContentReader support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33464
diff
changeset
|
1257 | if (!hc->contents_reader_buffer) |
|
918507303f45
HTTP API: PurpleHttpContentReader support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33464
diff
changeset
|
1258 | hc->contents_reader_buffer = g_string_new(""); |
|
918507303f45
HTTP API: PurpleHttpContentReader support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33464
diff
changeset
|
1259 | if (hc->contents_reader_buffer->len == 0) { |
|
918507303f45
HTTP API: PurpleHttpContentReader support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33464
diff
changeset
|
1260 | hc->contents_reader_requested = TRUE; |
|
918507303f45
HTTP API: PurpleHttpContentReader support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33464
diff
changeset
|
1261 | g_string_set_size(hc->contents_reader_buffer, |
|
918507303f45
HTTP API: PurpleHttpContentReader support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33464
diff
changeset
|
1262 | PURPLE_HTTP_MAX_READ_BUFFER_LEN); |
|
918507303f45
HTTP API: PurpleHttpContentReader support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33464
diff
changeset
|
1263 | hc->request->contents_reader(hc, |
|
918507303f45
HTTP API: PurpleHttpContentReader support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33464
diff
changeset
|
1264 | hc->contents_reader_buffer->str, |
|
918507303f45
HTTP API: PurpleHttpContentReader support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33464
diff
changeset
|
1265 | hc->request_contents_written, |
|
918507303f45
HTTP API: PurpleHttpContentReader support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33464
diff
changeset
|
1266 | PURPLE_HTTP_MAX_READ_BUFFER_LEN, |
|
918507303f45
HTTP API: PurpleHttpContentReader support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33464
diff
changeset
|
1267 | hc->request->contents_reader_data, |
|
918507303f45
HTTP API: PurpleHttpContentReader support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33464
diff
changeset
|
1268 | _purple_http_send_got_data); |
|
918507303f45
HTTP API: PurpleHttpContentReader support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33464
diff
changeset
|
1269 | return; |
|
918507303f45
HTTP API: PurpleHttpContentReader support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33464
diff
changeset
|
1270 | } |
|
918507303f45
HTTP API: PurpleHttpContentReader support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33464
diff
changeset
|
1271 | write_from = hc->contents_reader_buffer->str; |
|
918507303f45
HTTP API: PurpleHttpContentReader support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33464
diff
changeset
|
1272 | write_len = hc->contents_reader_buffer->len; |
|
33457
81f92a310aff
Writing request contents
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33456
diff
changeset
|
1273 | } else { |
|
81f92a310aff
Writing request contents
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33456
diff
changeset
|
1274 | write_from = hc->request->contents + |
|
81f92a310aff
Writing request contents
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33456
diff
changeset
|
1275 | hc->request_contents_written; |
|
81f92a310aff
Writing request contents
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33456
diff
changeset
|
1276 | write_len = hc->request->contents_length - |
|
81f92a310aff
Writing request contents
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33456
diff
changeset
|
1277 | hc->request_contents_written; |
|
81f92a310aff
Writing request contents
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33456
diff
changeset
|
1278 | } |
|
33431
704de181d1d2
Let's request
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33430
diff
changeset
|
1279 | |
|
33457
81f92a310aff
Writing request contents
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33456
diff
changeset
|
1280 | if (write_len == 0) { |
|
81f92a310aff
Writing request contents
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33456
diff
changeset
|
1281 | purple_debug_warning("http", "Nothing to write\n"); |
|
81f92a310aff
Writing request contents
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33456
diff
changeset
|
1282 | 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
|
1283 | } 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
|
1284 | 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
|
1285 | 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
|
1286 | } |
|
33431
704de181d1d2
Let's request
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33430
diff
changeset
|
1287 | |
|
704de181d1d2
Let's request
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33430
diff
changeset
|
1288 | if (written < 0 && errno == EAGAIN) |
|
704de181d1d2
Let's request
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33430
diff
changeset
|
1289 | return; |
|
704de181d1d2
Let's request
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33430
diff
changeset
|
1290 | |
|
704de181d1d2
Let's request
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33430
diff
changeset
|
1291 | if (written < 0) { |
|
704de181d1d2
Let's request
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33430
diff
changeset
|
1292 | _purple_http_error(hc, _("Error writing to %s: %s"), |
|
704de181d1d2
Let's request
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33430
diff
changeset
|
1293 | hc->url->host, g_strerror(errno)); |
|
704de181d1d2
Let's request
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33430
diff
changeset
|
1294 | return; |
|
704de181d1d2
Let's request
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33430
diff
changeset
|
1295 | } |
|
704de181d1d2
Let's request
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33430
diff
changeset
|
1296 | |
|
33457
81f92a310aff
Writing request contents
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33456
diff
changeset
|
1297 | if (writing_headers) { |
|
81f92a310aff
Writing request contents
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33456
diff
changeset
|
1298 | hc->request_header_written += written; |
|
33468
b057fee9d11a
HTTP progress watcher support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33466
diff
changeset
|
1299 | purple_http_conn_notify_progress_watcher(hc); |
|
33457
81f92a310aff
Writing request contents
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33456
diff
changeset
|
1300 | if (hc->request_header_written < hc->request_header->len) |
|
81f92a310aff
Writing request contents
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33456
diff
changeset
|
1301 | return; |
|
81f92a310aff
Writing request contents
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33456
diff
changeset
|
1302 | if (hc->request->contents_length > 0) |
|
81f92a310aff
Writing request contents
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33456
diff
changeset
|
1303 | return; |
|
81f92a310aff
Writing request contents
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33456
diff
changeset
|
1304 | } else { |
|
81f92a310aff
Writing request contents
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33456
diff
changeset
|
1305 | hc->request_contents_written += written; |
|
33468
b057fee9d11a
HTTP progress watcher support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33466
diff
changeset
|
1306 | purple_http_conn_notify_progress_watcher(hc); |
|
33466
918507303f45
HTTP API: PurpleHttpContentReader support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33464
diff
changeset
|
1307 | if (hc->contents_reader_buffer) |
|
918507303f45
HTTP API: PurpleHttpContentReader support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33464
diff
changeset
|
1308 | g_string_erase(hc->contents_reader_buffer, 0, written); |
|
33457
81f92a310aff
Writing request contents
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33456
diff
changeset
|
1309 | if (hc->request_contents_written < hc->request->contents_length) |
|
81f92a310aff
Writing request contents
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33456
diff
changeset
|
1310 | return; |
|
81f92a310aff
Writing request contents
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33456
diff
changeset
|
1311 | } |
|
33431
704de181d1d2
Let's request
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33430
diff
changeset
|
1312 | |
|
704de181d1d2
Let's request
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33430
diff
changeset
|
1313 | /* 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
|
1314 | 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
|
1315 | 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
|
1316 | _purple_http_recv, hc); |
|
33430
013c5aebb665
Let's connect
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33429
diff
changeset
|
1317 | } |
|
013c5aebb665
Let's connect
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33429
diff
changeset
|
1318 | |
|
34260
7a55eaa31da6
HTTP: implement keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34257
diff
changeset
|
1319 | static void _purple_http_disconnect(PurpleHttpConnection *hc, |
|
7a55eaa31da6
HTTP: implement keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34257
diff
changeset
|
1320 | gboolean is_graceful) |
|
33430
013c5aebb665
Let's connect
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33429
diff
changeset
|
1321 | { |
|
013c5aebb665
Let's connect
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33429
diff
changeset
|
1322 | g_return_if_fail(hc != NULL); |
|
013c5aebb665
Let's connect
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33429
diff
changeset
|
1323 | |
|
33431
704de181d1d2
Let's request
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33430
diff
changeset
|
1324 | if (hc->request_header) |
|
704de181d1d2
Let's request
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33430
diff
changeset
|
1325 | g_string_free(hc->request_header, TRUE); |
|
704de181d1d2
Let's request
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33430
diff
changeset
|
1326 | hc->request_header = NULL; |
|
34260
7a55eaa31da6
HTTP: implement keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34257
diff
changeset
|
1327 | |
|
33432
9c4acb75b2e6
Let's parse response headers
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33431
diff
changeset
|
1328 | if (hc->response_buffer) |
|
9c4acb75b2e6
Let's parse response headers
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33431
diff
changeset
|
1329 | g_string_free(hc->response_buffer, TRUE); |
|
9c4acb75b2e6
Let's parse response headers
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33431
diff
changeset
|
1330 | hc->response_buffer = NULL; |
|
33430
013c5aebb665
Let's connect
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33429
diff
changeset
|
1331 | |
|
34263
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
1332 | if (hc->socket_request) |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
1333 | 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
|
1334 | else { |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
1335 | 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
|
1336 | hc->socket = NULL; |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
1337 | } |
|
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
|
1338 | } |
|
935120490eb2
HTTP: isolate socket-related code in http module; initial implementation for keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34234
diff
changeset
|
1339 | |
|
935120490eb2
HTTP: isolate socket-related code in http module; initial implementation for keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34234
diff
changeset
|
1340 | 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
|
1341 | { |
|
935120490eb2
HTTP: isolate socket-related code in http module; initial implementation for keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34234
diff
changeset
|
1342 | 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
|
1343 | |
|
34263
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
1344 | hc->socket_request = NULL; |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
1345 | hc->socket = hs; |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
1346 | |
|
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
|
1347 | 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
|
1348 | _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
|
1349 | 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
|
1350 | return; |
|
33430
013c5aebb665
Let's connect
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33429
diff
changeset
|
1351 | } |
|
34263
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
1352 | |
|
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
|
1353 | 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
|
1354 | } |
|
013c5aebb665
Let's connect
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33429
diff
changeset
|
1355 | |
|
013c5aebb665
Let's connect
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33429
diff
changeset
|
1356 | static gboolean _purple_http_reconnect(PurpleHttpConnection *hc) |
|
013c5aebb665
Let's connect
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33429
diff
changeset
|
1357 | { |
|
013c5aebb665
Let's connect
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33429
diff
changeset
|
1358 | PurpleHttpURL *url; |
|
013c5aebb665
Let's connect
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33429
diff
changeset
|
1359 | gboolean is_ssl = FALSE; |
|
013c5aebb665
Let's connect
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33429
diff
changeset
|
1360 | |
|
013c5aebb665
Let's connect
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33429
diff
changeset
|
1361 | g_return_val_if_fail(hc != NULL, FALSE); |
|
013c5aebb665
Let's connect
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33429
diff
changeset
|
1362 | g_return_val_if_fail(hc->url != NULL, FALSE); |
|
013c5aebb665
Let's connect
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33429
diff
changeset
|
1363 | |
|
34260
7a55eaa31da6
HTTP: implement keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34257
diff
changeset
|
1364 | _purple_http_disconnect(hc, TRUE); |
|
33430
013c5aebb665
Let's connect
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33429
diff
changeset
|
1365 | |
|
33438
66c4b90ff08a
More debug prints
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33437
diff
changeset
|
1366 | if (purple_debug_is_verbose()) { |
|
66c4b90ff08a
More debug prints
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33437
diff
changeset
|
1367 | if (purple_debug_is_unsafe()) { |
|
66c4b90ff08a
More debug prints
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33437
diff
changeset
|
1368 | gchar *url = purple_http_url_print(hc->url); |
|
66c4b90ff08a
More debug prints
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33437
diff
changeset
|
1369 | purple_debug_misc("http", "Connecting to %s...\n", url); |
|
66c4b90ff08a
More debug prints
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33437
diff
changeset
|
1370 | g_free(url); |
|
66c4b90ff08a
More debug prints
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33437
diff
changeset
|
1371 | } else |
|
66c4b90ff08a
More debug prints
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33437
diff
changeset
|
1372 | purple_debug_misc("http", "Connecting to %s...\n", |
|
66c4b90ff08a
More debug prints
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33437
diff
changeset
|
1373 | hc->url->host); |
|
66c4b90ff08a
More debug prints
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33437
diff
changeset
|
1374 | } |
|
66c4b90ff08a
More debug prints
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33437
diff
changeset
|
1375 | |
|
33430
013c5aebb665
Let's connect
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33429
diff
changeset
|
1376 | url = hc->url; |
|
013c5aebb665
Let's connect
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33429
diff
changeset
|
1377 | if (url->protocol[0] == '\0' || |
|
013c5aebb665
Let's connect
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33429
diff
changeset
|
1378 | g_ascii_strcasecmp(url->protocol, "http") == 0) { |
|
013c5aebb665
Let's connect
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33429
diff
changeset
|
1379 | /* do nothing */ |
|
013c5aebb665
Let's connect
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33429
diff
changeset
|
1380 | } else if (g_ascii_strcasecmp(url->protocol, "https") == 0) { |
|
013c5aebb665
Let's connect
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33429
diff
changeset
|
1381 | is_ssl = TRUE; |
|
013c5aebb665
Let's connect
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33429
diff
changeset
|
1382 | } else { |
|
013c5aebb665
Let's connect
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33429
diff
changeset
|
1383 | _purple_http_error(hc, _("Unsupported protocol: %s"), |
|
013c5aebb665
Let's connect
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33429
diff
changeset
|
1384 | url->protocol); |
|
013c5aebb665
Let's connect
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33429
diff
changeset
|
1385 | return FALSE; |
|
013c5aebb665
Let's connect
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33429
diff
changeset
|
1386 | } |
|
013c5aebb665
Let's connect
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33429
diff
changeset
|
1387 | |
|
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
|
1388 | 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
|
1389 | _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
|
1390 | 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
|
1391 | "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
|
1392 | return FALSE; |
|
33430
013c5aebb665
Let's connect
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33429
diff
changeset
|
1393 | } |
|
013c5aebb665
Let's connect
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33429
diff
changeset
|
1394 | |
|
34263
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
1395 | if (hc->request->keepalive_pool != NULL) { |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
1396 | 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
|
1397 | 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
|
1398 | 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
|
1399 | } else { |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
1400 | 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
|
1401 | 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
|
1402 | } |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
1403 | |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
1404 | if (hc->socket_request == NULL && hc->socket == NULL) { |
|
33430
013c5aebb665
Let's connect
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33429
diff
changeset
|
1405 | _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
|
1406 | return FALSE; |
|
013c5aebb665
Let's connect
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33429
diff
changeset
|
1407 | } |
|
33432
9c4acb75b2e6
Let's parse response headers
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33431
diff
changeset
|
1408 | |
|
9c4acb75b2e6
Let's parse response headers
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33431
diff
changeset
|
1409 | purple_http_headers_free(hc->response->headers); |
|
9c4acb75b2e6
Let's parse response headers
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33431
diff
changeset
|
1410 | hc->response->headers = purple_http_headers_new(); |
|
9c4acb75b2e6
Let's parse response headers
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33431
diff
changeset
|
1411 | hc->response_buffer = g_string_new(""); |
|
9c4acb75b2e6
Let's parse response headers
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33431
diff
changeset
|
1412 | hc->main_header_got = FALSE; |
|
9c4acb75b2e6
Let's parse response headers
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33431
diff
changeset
|
1413 | hc->headers_got = FALSE; |
|
33433
fb7ac52ed7df
Let's get response contents
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33432
diff
changeset
|
1414 | if (hc->response->contents != NULL) |
|
fb7ac52ed7df
Let's get response contents
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33432
diff
changeset
|
1415 | g_string_free(hc->response->contents, TRUE); |
|
fb7ac52ed7df
Let's get response contents
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33432
diff
changeset
|
1416 | hc->response->contents = NULL; |
|
fb7ac52ed7df
Let's get response contents
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33432
diff
changeset
|
1417 | hc->length_got = 0; |
|
33446
95fda782966c
New feature: setting maximum length of response
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33445
diff
changeset
|
1418 | hc->data_length_got = 0; |
|
33433
fb7ac52ed7df
Let's get response contents
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33432
diff
changeset
|
1419 | hc->length_expected = -1; |
|
33434
ec4f343af107
Chunked file transfers support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33433
diff
changeset
|
1420 | hc->is_chunked = FALSE; |
|
ec4f343af107
Chunked file transfers support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33433
diff
changeset
|
1421 | hc->in_chunk = FALSE; |
|
ec4f343af107
Chunked file transfers support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33433
diff
changeset
|
1422 | hc->chunks_done = FALSE; |
|
33430
013c5aebb665
Let's connect
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33429
diff
changeset
|
1423 | |
|
33468
b057fee9d11a
HTTP progress watcher support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33466
diff
changeset
|
1424 | purple_http_conn_notify_progress_watcher(hc); |
|
b057fee9d11a
HTTP progress watcher support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33466
diff
changeset
|
1425 | |
|
33430
013c5aebb665
Let's connect
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33429
diff
changeset
|
1426 | return TRUE; |
|
013c5aebb665
Let's connect
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33429
diff
changeset
|
1427 | } |
|
013c5aebb665
Let's connect
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33429
diff
changeset
|
1428 | |
|
33427
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
1429 | /*** Performing HTTP requests *************************************************/ |
|
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
1430 | |
|
33450
4042907bcdf1
Timeout support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33448
diff
changeset
|
1431 | static gboolean purple_http_request_timeout(gpointer _hc) |
|
4042907bcdf1
Timeout support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33448
diff
changeset
|
1432 | { |
|
4042907bcdf1
Timeout support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33448
diff
changeset
|
1433 | PurpleHttpConnection *hc = _hc; |
|
4042907bcdf1
Timeout support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33448
diff
changeset
|
1434 | |
|
4042907bcdf1
Timeout support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33448
diff
changeset
|
1435 | purple_debug_warning("http", "Timeout reached for request %p\n", hc); |
|
4042907bcdf1
Timeout support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33448
diff
changeset
|
1436 | |
|
4042907bcdf1
Timeout support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33448
diff
changeset
|
1437 | purple_http_conn_cancel(hc); |
|
4042907bcdf1
Timeout support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33448
diff
changeset
|
1438 | |
|
4042907bcdf1
Timeout support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33448
diff
changeset
|
1439 | return FALSE; |
|
4042907bcdf1
Timeout support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33448
diff
changeset
|
1440 | } |
|
4042907bcdf1
Timeout support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33448
diff
changeset
|
1441 | |
|
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
|
1442 | 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
|
1443 | 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
|
1444 | { |
|
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
1445 | PurpleHttpRequest *request; |
|
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
1446 | PurpleHttpConnection *hc; |
|
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
1447 | |
|
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
1448 | 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
|
1449 | |
|
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
1450 | request = purple_http_request_new(url); |
|
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
1451 | 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
|
1452 | purple_http_request_unref(request); |
|
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
1453 | |
|
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
1454 | return hc; |
|
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
1455 | } |
|
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
1456 | |
|
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
|
1457 | 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
|
1458 | 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
|
1459 | 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
|
1460 | { |
|
8bdcc4f84a5e
HTTP: introduce purple_http_get_printf, make purple_http_get consistent with it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34232
diff
changeset
|
1461 | 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
|
1462 | 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
|
1463 | 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
|
1464 | |
|
8bdcc4f84a5e
HTTP: introduce purple_http_get_printf, make purple_http_get consistent with it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34232
diff
changeset
|
1465 | 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
|
1466 | |
|
8bdcc4f84a5e
HTTP: introduce purple_http_get_printf, make purple_http_get consistent with it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34232
diff
changeset
|
1467 | 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
|
1468 | 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
|
1469 | 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
|
1470 | |
|
8bdcc4f84a5e
HTTP: introduce purple_http_get_printf, make purple_http_get consistent with it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34232
diff
changeset
|
1471 | 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
|
1472 | 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
|
1473 | |
|
8bdcc4f84a5e
HTTP: introduce purple_http_get_printf, make purple_http_get consistent with it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34232
diff
changeset
|
1474 | 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
|
1475 | } |
|
8bdcc4f84a5e
HTTP: introduce purple_http_get_printf, make purple_http_get consistent with it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34232
diff
changeset
|
1476 | |
|
33427
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
1477 | PurpleHttpConnection * purple_http_request(PurpleConnection *gc, |
|
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
1478 | PurpleHttpRequest *request, PurpleHttpCallback callback, |
|
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
1479 | gpointer user_data) |
|
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
1480 | { |
|
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
1481 | PurpleHttpConnection *hc; |
|
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
1482 | |
|
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
1483 | 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
|
1484 | |
|
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
|
1485 | 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
|
1486 | 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
|
1487 | "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
|
1488 | 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
|
1489 | } |
|
a5517f235e0f
HTTP: migrate purple_util_fetch_url_request to new API for GG prpl
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34225
diff
changeset
|
1490 | |
|
34262
3b8ce83bac96
HTTP: get rid of one (of two) msn's own http implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34261
diff
changeset
|
1491 | 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
|
1492 | 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
|
1493 | "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
|
1494 | "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
|
1495 | 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
|
1496 | } |
|
3b8ce83bac96
HTTP: get rid of one (of two) msn's own http implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34261
diff
changeset
|
1497 | |
|
33448
4d41b1f7b95f
Cancelling all HTTP connections on account disconnect or app shutdown
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33447
diff
changeset
|
1498 | 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
|
1499 | hc->callback = callback; |
|
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
1500 | hc->user_data = user_data; |
|
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
1501 | |
|
33429
1ce1faf4e675
Extend URL parsing
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33427
diff
changeset
|
1502 | if (purple_debug_is_unsafe()) |
|
1ce1faf4e675
Extend URL parsing
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33427
diff
changeset
|
1503 | 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
|
1504 | hc, request->url); |
|
1ce1faf4e675
Extend URL parsing
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33427
diff
changeset
|
1505 | else |
|
1ce1faf4e675
Extend URL parsing
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33427
diff
changeset
|
1506 | purple_debug_misc("http", "Performing new request %p.\n", hc); |
|
1ce1faf4e675
Extend URL parsing
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33427
diff
changeset
|
1507 | |
|
1ce1faf4e675
Extend URL parsing
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33427
diff
changeset
|
1508 | hc->url = purple_http_url_parse(request->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
|
1509 | 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
|
1510 | purple_debug_error("http", "Invalid URL requested.\n"); |
|
1ce1faf4e675
Extend URL parsing
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33427
diff
changeset
|
1511 | purple_http_connection_terminate(hc); |
|
1ce1faf4e675
Extend URL parsing
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33427
diff
changeset
|
1512 | return NULL; |
|
1ce1faf4e675
Extend URL parsing
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33427
diff
changeset
|
1513 | } |
|
33427
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
1514 | |
|
33430
013c5aebb665
Let's connect
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33429
diff
changeset
|
1515 | _purple_http_reconnect(hc); |
|
013c5aebb665
Let's connect
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33429
diff
changeset
|
1516 | |
|
33450
4042907bcdf1
Timeout support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33448
diff
changeset
|
1517 | hc->timeout_handle = purple_timeout_add_seconds(request->timeout, |
|
4042907bcdf1
Timeout support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33448
diff
changeset
|
1518 | purple_http_request_timeout, hc); |
|
33427
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
1519 | |
|
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
1520 | return hc; |
|
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
1521 | } |
|
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
1522 | |
|
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
1523 | /*** HTTP connection API ******************************************************/ |
|
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
1524 | |
|
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
1525 | 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
|
1526 | 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
|
1527 | |
|
33448
4d41b1f7b95f
Cancelling all HTTP connections on account disconnect or app shutdown
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33447
diff
changeset
|
1528 | 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
|
1529 | PurpleHttpRequest *request, PurpleConnection *gc) |
|
33427
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 | PurpleHttpConnection *hc = g_new0(PurpleHttpConnection, 1); |
|
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
1532 | |
|
33429
1ce1faf4e675
Extend URL parsing
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33427
diff
changeset
|
1533 | hc->request = request; |
|
1ce1faf4e675
Extend URL parsing
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33427
diff
changeset
|
1534 | purple_http_request_ref(request); |
|
33427
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
1535 | 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
|
1536 | 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
|
1537 | |
|
33448
4d41b1f7b95f
Cancelling all HTTP connections on account disconnect or app shutdown
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33447
diff
changeset
|
1538 | 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
|
1539 | 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
|
1540 | 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
|
1541 | if (gc) { |
|
4d41b1f7b95f
Cancelling all HTTP connections on account disconnect or app shutdown
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33447
diff
changeset
|
1542 | 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
|
1543 | 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
|
1544 | 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
|
1545 | 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
|
1546 | hc->gc = gc; |
|
4d41b1f7b95f
Cancelling all HTTP connections on account disconnect or app shutdown
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33447
diff
changeset
|
1547 | } |
|
4d41b1f7b95f
Cancelling all HTTP connections on account disconnect or app shutdown
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33447
diff
changeset
|
1548 | |
|
33427
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
1549 | return hc; |
|
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
1550 | } |
|
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
1551 | |
|
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
1552 | 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
|
1553 | { |
|
33450
4042907bcdf1
Timeout support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33448
diff
changeset
|
1554 | if (hc->timeout_handle) |
|
4042907bcdf1
Timeout support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33448
diff
changeset
|
1555 | 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
|
1556 | 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
|
1557 | purple_timeout_remove(hc->watcher_delayed_handle); |
|
33450
4042907bcdf1
Timeout support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33448
diff
changeset
|
1558 | |
|
33429
1ce1faf4e675
Extend URL parsing
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33427
diff
changeset
|
1559 | purple_http_url_free(hc->url); |
|
1ce1faf4e675
Extend URL parsing
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33427
diff
changeset
|
1560 | 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
|
1561 | purple_http_response_free(hc->response); |
|
33430
013c5aebb665
Let's connect
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33429
diff
changeset
|
1562 | |
|
33466
918507303f45
HTTP API: PurpleHttpContentReader support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33464
diff
changeset
|
1563 | if (hc->contents_reader_buffer) |
|
918507303f45
HTTP API: PurpleHttpContentReader support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33464
diff
changeset
|
1564 | g_string_free(hc->contents_reader_buffer, TRUE); |
|
918507303f45
HTTP API: PurpleHttpContentReader support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33464
diff
changeset
|
1565 | |
|
33431
704de181d1d2
Let's request
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33430
diff
changeset
|
1566 | if (hc->request_header) |
|
704de181d1d2
Let's request
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33430
diff
changeset
|
1567 | g_string_free(hc->request_header, TRUE); |
|
704de181d1d2
Let's request
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33430
diff
changeset
|
1568 | |
|
33448
4d41b1f7b95f
Cancelling all HTTP connections on account disconnect or app shutdown
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33447
diff
changeset
|
1569 | 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
|
1570 | hc->link_global); |
|
4d41b1f7b95f
Cancelling all HTTP connections on account disconnect or app shutdown
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33447
diff
changeset
|
1571 | 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
|
1572 | if (hc->gc) { |
|
4d41b1f7b95f
Cancelling all HTTP connections on account disconnect or app shutdown
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33447
diff
changeset
|
1573 | 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
|
1574 | 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
|
1575 | 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
|
1576 | |
|
4d41b1f7b95f
Cancelling all HTTP connections on account disconnect or app shutdown
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33447
diff
changeset
|
1577 | 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
|
1578 | 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
|
1579 | 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
|
1580 | 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
|
1581 | 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
|
1582 | 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
|
1583 | } |
|
4d41b1f7b95f
Cancelling all HTTP connections on account disconnect or app shutdown
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33447
diff
changeset
|
1584 | } |
|
4d41b1f7b95f
Cancelling all HTTP connections on account disconnect or app shutdown
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33447
diff
changeset
|
1585 | |
|
33427
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
1586 | g_free(hc); |
|
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
1587 | } |
|
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
1588 | |
|
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
1589 | /* call callback and do the cleanup */ |
|
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
1590 | 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
|
1591 | { |
|
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
1592 | g_return_if_fail(hc != NULL); |
|
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
1593 | |
|
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
1594 | purple_debug_misc("http", "Request %p performed %s.\n", hc, |
|
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
1595 | purple_http_response_is_successfull(hc->response) ? |
|
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
1596 | "successfully" : "without success"); |
|
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
1597 | |
|
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
1598 | if (hc->callback) |
|
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
1599 | 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
|
1600 | |
|
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
1601 | purple_http_connection_free(hc); |
|
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
1602 | } |
|
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
1603 | |
|
33430
013c5aebb665
Let's connect
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33429
diff
changeset
|
1604 | void purple_http_conn_cancel(PurpleHttpConnection *http_conn) |
|
013c5aebb665
Let's connect
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33429
diff
changeset
|
1605 | { |
|
33464
9605c0a2839e
Don't crash when cancelling non-existent HTTP connection
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33462
diff
changeset
|
1606 | if (http_conn == NULL) |
|
9605c0a2839e
Don't crash when cancelling non-existent HTTP connection
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33462
diff
changeset
|
1607 | return; |
|
9605c0a2839e
Don't crash when cancelling non-existent HTTP connection
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33462
diff
changeset
|
1608 | |
|
34263
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
1609 | if (http_conn->is_cancelling) |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
1610 | return; |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
1611 | http_conn->is_cancelling = TRUE; |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
1612 | |
|
34260
7a55eaa31da6
HTTP: implement keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34257
diff
changeset
|
1613 | if (purple_debug_is_verbose()) { |
|
7a55eaa31da6
HTTP: implement keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34257
diff
changeset
|
1614 | purple_debug_misc("http", "Cancelling connection %p...\n", |
|
7a55eaa31da6
HTTP: implement keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34257
diff
changeset
|
1615 | http_conn); |
|
7a55eaa31da6
HTTP: implement keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34257
diff
changeset
|
1616 | } |
|
7a55eaa31da6
HTTP: implement keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34257
diff
changeset
|
1617 | |
|
33430
013c5aebb665
Let's connect
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33429
diff
changeset
|
1618 | http_conn->response->code = 0; |
|
34260
7a55eaa31da6
HTTP: implement keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34257
diff
changeset
|
1619 | _purple_http_disconnect(http_conn, FALSE); |
|
33430
013c5aebb665
Let's connect
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33429
diff
changeset
|
1620 | purple_http_connection_terminate(http_conn); |
|
013c5aebb665
Let's connect
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33429
diff
changeset
|
1621 | } |
|
013c5aebb665
Let's connect
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33429
diff
changeset
|
1622 | |
|
34260
7a55eaa31da6
HTTP: implement keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34257
diff
changeset
|
1623 | static void |
|
7a55eaa31da6
HTTP: implement keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34257
diff
changeset
|
1624 | purple_http_conn_retry(PurpleHttpConnection *http_conn) |
|
7a55eaa31da6
HTTP: implement keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34257
diff
changeset
|
1625 | { |
|
7a55eaa31da6
HTTP: implement keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34257
diff
changeset
|
1626 | if (http_conn == NULL) |
|
7a55eaa31da6
HTTP: implement keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34257
diff
changeset
|
1627 | return; |
|
7a55eaa31da6
HTTP: implement keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34257
diff
changeset
|
1628 | |
|
7a55eaa31da6
HTTP: implement keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34257
diff
changeset
|
1629 | 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
|
1630 | |
|
7a55eaa31da6
HTTP: implement keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34257
diff
changeset
|
1631 | http_conn->response->code = 0; |
|
7a55eaa31da6
HTTP: implement keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34257
diff
changeset
|
1632 | _purple_http_disconnect(http_conn, FALSE); |
|
7a55eaa31da6
HTTP: implement keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34257
diff
changeset
|
1633 | _purple_http_reconnect(http_conn); |
|
7a55eaa31da6
HTTP: implement keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34257
diff
changeset
|
1634 | } |
|
7a55eaa31da6
HTTP: implement keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34257
diff
changeset
|
1635 | |
|
33427
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
1636 | 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
|
1637 | { |
|
33448
4d41b1f7b95f
Cancelling all HTTP connections on account disconnect or app shutdown
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33447
diff
changeset
|
1638 | 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
|
1639 | |
|
34262
3b8ce83bac96
HTTP: get rid of one (of two) msn's own http implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34261
diff
changeset
|
1640 | 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
|
1641 | |
|
33448
4d41b1f7b95f
Cancelling all HTTP connections on account disconnect or app shutdown
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33447
diff
changeset
|
1642 | while (gc_list) { |
|
4d41b1f7b95f
Cancelling all HTTP connections on account disconnect or app shutdown
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33447
diff
changeset
|
1643 | 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
|
1644 | 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
|
1645 | 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
|
1646 | } |
|
4d41b1f7b95f
Cancelling all HTTP connections on account disconnect or app shutdown
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33447
diff
changeset
|
1647 | |
|
34262
3b8ce83bac96
HTTP: get rid of one (of two) msn's own http implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34261
diff
changeset
|
1648 | 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
|
1649 | |
|
33448
4d41b1f7b95f
Cancelling all HTTP connections on account disconnect or app shutdown
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33447
diff
changeset
|
1650 | 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
|
1651 | 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
|
1652 | "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
|
1653 | } |
|
4d41b1f7b95f
Cancelling all HTTP connections on account disconnect or app shutdown
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33447
diff
changeset
|
1654 | |
|
4d41b1f7b95f
Cancelling all HTTP connections on account disconnect or app shutdown
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33447
diff
changeset
|
1655 | 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
|
1656 | { |
|
4d41b1f7b95f
Cancelling all HTTP connections on account disconnect or app shutdown
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33447
diff
changeset
|
1657 | 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
|
1658 | return FALSE; |
|
4d41b1f7b95f
Cancelling all HTTP connections on account disconnect or app shutdown
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33447
diff
changeset
|
1659 | 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
|
1660 | } |
|
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
1661 | |
|
33451
27d0e5dbc2a1
Implement missing getters/setters and corresponding features
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33450
diff
changeset
|
1662 | 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
|
1663 | { |
|
27d0e5dbc2a1
Implement missing getters/setters and corresponding features
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33450
diff
changeset
|
1664 | 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
|
1665 | |
|
27d0e5dbc2a1
Implement missing getters/setters and corresponding features
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33450
diff
changeset
|
1666 | return http_conn->request; |
|
27d0e5dbc2a1
Implement missing getters/setters and corresponding features
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33450
diff
changeset
|
1667 | } |
|
27d0e5dbc2a1
Implement missing getters/setters and corresponding features
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33450
diff
changeset
|
1668 | |
|
33456
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
1669 | PurpleHttpCookieJar * purple_http_conn_get_cookie_jar( |
|
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
1670 | PurpleHttpConnection *http_conn) |
|
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
1671 | { |
|
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
1672 | 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
|
1673 | http_conn)); |
|
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
1674 | } |
|
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
1675 | |
|
33451
27d0e5dbc2a1
Implement missing getters/setters and corresponding features
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33450
diff
changeset
|
1676 | 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
|
1677 | PurpleHttpConnection *http_conn) |
|
27d0e5dbc2a1
Implement missing getters/setters and corresponding features
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33450
diff
changeset
|
1678 | { |
|
27d0e5dbc2a1
Implement missing getters/setters and corresponding features
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33450
diff
changeset
|
1679 | 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
|
1680 | |
|
27d0e5dbc2a1
Implement missing getters/setters and corresponding features
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33450
diff
changeset
|
1681 | return http_conn->gc; |
|
27d0e5dbc2a1
Implement missing getters/setters and corresponding features
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33450
diff
changeset
|
1682 | } |
|
27d0e5dbc2a1
Implement missing getters/setters and corresponding features
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33450
diff
changeset
|
1683 | |
|
33468
b057fee9d11a
HTTP progress watcher support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33466
diff
changeset
|
1684 | 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
|
1685 | PurpleHttpProgressWatcher watcher, gpointer user_data, |
|
b057fee9d11a
HTTP progress watcher support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33466
diff
changeset
|
1686 | guint interval_threshold) |
|
b057fee9d11a
HTTP progress watcher support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33466
diff
changeset
|
1687 | { |
|
b057fee9d11a
HTTP progress watcher support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33466
diff
changeset
|
1688 | g_return_if_fail(http_conn != NULL); |
|
b057fee9d11a
HTTP progress watcher support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33466
diff
changeset
|
1689 | |
|
b057fee9d11a
HTTP progress watcher support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33466
diff
changeset
|
1690 | http_conn->watcher = watcher; |
|
b057fee9d11a
HTTP progress watcher support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33466
diff
changeset
|
1691 | http_conn->watcher_user_data = user_data; |
|
b057fee9d11a
HTTP progress watcher support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33466
diff
changeset
|
1692 | http_conn->watcher_interval_threshold = interval_threshold; |
|
b057fee9d11a
HTTP progress watcher support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33466
diff
changeset
|
1693 | } |
|
b057fee9d11a
HTTP progress watcher support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33466
diff
changeset
|
1694 | |
|
b057fee9d11a
HTTP progress watcher support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33466
diff
changeset
|
1695 | static void purple_http_conn_notify_progress_watcher( |
|
b057fee9d11a
HTTP progress watcher support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33466
diff
changeset
|
1696 | PurpleHttpConnection *hc) |
|
b057fee9d11a
HTTP progress watcher support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33466
diff
changeset
|
1697 | { |
|
b057fee9d11a
HTTP progress watcher support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33466
diff
changeset
|
1698 | gint64 now; |
|
b057fee9d11a
HTTP progress watcher support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33466
diff
changeset
|
1699 | gboolean reading_state; |
|
b057fee9d11a
HTTP progress watcher support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33466
diff
changeset
|
1700 | int processed, total; |
|
b057fee9d11a
HTTP progress watcher support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33466
diff
changeset
|
1701 | |
|
b057fee9d11a
HTTP progress watcher support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33466
diff
changeset
|
1702 | g_return_if_fail(hc != NULL); |
|
b057fee9d11a
HTTP progress watcher support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33466
diff
changeset
|
1703 | |
|
b057fee9d11a
HTTP progress watcher support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33466
diff
changeset
|
1704 | if (hc->watcher == NULL) |
|
b057fee9d11a
HTTP progress watcher support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33466
diff
changeset
|
1705 | return; |
|
b057fee9d11a
HTTP progress watcher support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33466
diff
changeset
|
1706 | |
|
b057fee9d11a
HTTP progress watcher support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33466
diff
changeset
|
1707 | reading_state = hc->is_reading; |
|
b057fee9d11a
HTTP progress watcher support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33466
diff
changeset
|
1708 | if (reading_state) { |
|
b057fee9d11a
HTTP progress watcher support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33466
diff
changeset
|
1709 | total = hc->length_expected; |
|
b057fee9d11a
HTTP progress watcher support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33466
diff
changeset
|
1710 | processed = hc->length_got; |
|
b057fee9d11a
HTTP progress watcher support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33466
diff
changeset
|
1711 | } else { |
|
b057fee9d11a
HTTP progress watcher support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33466
diff
changeset
|
1712 | total = hc->request->contents_length; |
|
b057fee9d11a
HTTP progress watcher support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33466
diff
changeset
|
1713 | processed = hc->request_contents_written; |
|
b057fee9d11a
HTTP progress watcher support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33466
diff
changeset
|
1714 | if (total == 0) |
|
b057fee9d11a
HTTP progress watcher support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33466
diff
changeset
|
1715 | total = -1; |
|
b057fee9d11a
HTTP progress watcher support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33466
diff
changeset
|
1716 | } |
|
b057fee9d11a
HTTP progress watcher support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33466
diff
changeset
|
1717 | if (total != -1 && total < processed) { |
|
b057fee9d11a
HTTP progress watcher support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33466
diff
changeset
|
1718 | purple_debug_warning("http", "Processed too much\n"); |
|
b057fee9d11a
HTTP progress watcher support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33466
diff
changeset
|
1719 | total = processed; |
|
b057fee9d11a
HTTP progress watcher support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33466
diff
changeset
|
1720 | } |
|
b057fee9d11a
HTTP progress watcher support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33466
diff
changeset
|
1721 | |
|
b057fee9d11a
HTTP progress watcher support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33466
diff
changeset
|
1722 | now = g_get_monotonic_time(); |
|
b057fee9d11a
HTTP progress watcher support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33466
diff
changeset
|
1723 | 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
|
1724 | > 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
|
1725 | 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
|
1726 | return; |
|
43c34cda245d
HTTP: don't forget to notify about progress before connection freeze
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33517
diff
changeset
|
1727 | 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
|
1728 | 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
|
1729 | purple_http_conn_notify_progress_watcher_timeout, hc); |
|
33468
b057fee9d11a
HTTP progress watcher support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33466
diff
changeset
|
1730 | return; |
|
33521
43c34cda245d
HTTP: don't forget to notify about progress before connection freeze
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33517
diff
changeset
|
1731 | } |
|
43c34cda245d
HTTP: don't forget to notify about progress before connection freeze
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33517
diff
changeset
|
1732 | |
|
43c34cda245d
HTTP: don't forget to notify about progress before connection freeze
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33517
diff
changeset
|
1733 | 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
|
1734 | 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
|
1735 | 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
|
1736 | |
|
33468
b057fee9d11a
HTTP progress watcher support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33466
diff
changeset
|
1737 | hc->watcher_last_call = now; |
|
b057fee9d11a
HTTP progress watcher support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33466
diff
changeset
|
1738 | 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
|
1739 | } |
|
b057fee9d11a
HTTP progress watcher support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33466
diff
changeset
|
1740 | |
|
33521
43c34cda245d
HTTP: don't forget to notify about progress before connection freeze
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33517
diff
changeset
|
1741 | 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
|
1742 | { |
|
43c34cda245d
HTTP: don't forget to notify about progress before connection freeze
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33517
diff
changeset
|
1743 | 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
|
1744 | |
|
43c34cda245d
HTTP: don't forget to notify about progress before connection freeze
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33517
diff
changeset
|
1745 | 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
|
1746 | |
|
43c34cda245d
HTTP: don't forget to notify about progress before connection freeze
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33517
diff
changeset
|
1747 | return FALSE; |
|
43c34cda245d
HTTP: don't forget to notify about progress before connection freeze
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33517
diff
changeset
|
1748 | } |
|
43c34cda245d
HTTP: don't forget to notify about progress before connection freeze
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33517
diff
changeset
|
1749 | |
|
33456
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
1750 | /*** Cookie jar API ***********************************************************/ |
|
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
1751 | |
|
33459
722a6d753cb2
Better cookies, better chunked transfer support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33458
diff
changeset
|
1752 | 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
|
1753 | void purple_http_cookie_free(PurpleHttpCookie *cookie); |
|
722a6d753cb2
Better cookies, better chunked transfer support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33458
diff
changeset
|
1754 | |
|
722a6d753cb2
Better cookies, better chunked transfer support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33458
diff
changeset
|
1755 | 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
|
1756 | 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
|
1757 | |
|
722a6d753cb2
Better cookies, better chunked transfer support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33458
diff
changeset
|
1758 | 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
|
1759 | { |
|
722a6d753cb2
Better cookies, better chunked transfer support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33458
diff
changeset
|
1760 | PurpleHttpCookie *cookie = g_new0(PurpleHttpCookie, 1); |
|
722a6d753cb2
Better cookies, better chunked transfer support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33458
diff
changeset
|
1761 | |
|
722a6d753cb2
Better cookies, better chunked transfer support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33458
diff
changeset
|
1762 | cookie->value = g_strdup(value); |
|
722a6d753cb2
Better cookies, better chunked transfer support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33458
diff
changeset
|
1763 | cookie->expires = -1; |
|
722a6d753cb2
Better cookies, better chunked transfer support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33458
diff
changeset
|
1764 | |
|
722a6d753cb2
Better cookies, better chunked transfer support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33458
diff
changeset
|
1765 | return cookie; |
|
722a6d753cb2
Better cookies, better chunked transfer support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33458
diff
changeset
|
1766 | } |
|
722a6d753cb2
Better cookies, better chunked transfer support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33458
diff
changeset
|
1767 | |
|
722a6d753cb2
Better cookies, better chunked transfer support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33458
diff
changeset
|
1768 | void purple_http_cookie_free(PurpleHttpCookie *cookie) |
|
722a6d753cb2
Better cookies, better chunked transfer support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33458
diff
changeset
|
1769 | { |
|
722a6d753cb2
Better cookies, better chunked transfer support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33458
diff
changeset
|
1770 | g_free(cookie->value); |
|
722a6d753cb2
Better cookies, better chunked transfer support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33458
diff
changeset
|
1771 | g_free(cookie); |
|
722a6d753cb2
Better cookies, better chunked transfer support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33458
diff
changeset
|
1772 | } |
|
722a6d753cb2
Better cookies, better chunked transfer support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33458
diff
changeset
|
1773 | |
|
33456
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
1774 | void purple_http_cookie_jar_free(PurpleHttpCookieJar *cookie_jar); |
|
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
1775 | |
|
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
1776 | PurpleHttpCookieJar * purple_http_cookie_jar_new(void) |
|
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
1777 | { |
|
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
1778 | PurpleHttpCookieJar *cjar = g_new0(PurpleHttpCookieJar, 1); |
|
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
1779 | |
|
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
1780 | cjar->ref_count = 1; |
|
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
1781 | 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
|
1782 | (GDestroyNotify)purple_http_cookie_free); |
|
33456
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
1783 | |
|
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
1784 | return cjar; |
|
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
1785 | } |
|
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
1786 | |
|
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
1787 | void purple_http_cookie_jar_free(PurpleHttpCookieJar *cookie_jar) |
|
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
1788 | { |
|
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
1789 | g_hash_table_destroy(cookie_jar->tab); |
|
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
1790 | g_free(cookie_jar); |
|
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
1791 | } |
|
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
1792 | |
|
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
1793 | void purple_http_cookie_jar_ref(PurpleHttpCookieJar *cookie_jar) |
|
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
1794 | { |
|
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
1795 | g_return_if_fail(cookie_jar != NULL); |
|
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
1796 | |
|
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
1797 | cookie_jar->ref_count++; |
|
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
1798 | } |
|
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
1799 | |
|
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
1800 | PurpleHttpCookieJar * purple_http_cookie_jar_unref( |
|
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
1801 | PurpleHttpCookieJar *cookie_jar) |
|
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
1802 | { |
|
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
1803 | if (cookie_jar == NULL) |
|
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
1804 | return NULL; |
|
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
1805 | |
|
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
1806 | 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
|
1807 | |
|
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
1808 | cookie_jar->ref_count--; |
|
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
1809 | if (cookie_jar->ref_count > 0) |
|
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
1810 | return cookie_jar; |
|
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
1811 | |
|
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
1812 | purple_http_cookie_jar_free(cookie_jar); |
|
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
1813 | return NULL; |
|
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
1814 | } |
|
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
1815 | |
|
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
1816 | static void purple_http_cookie_jar_parse(PurpleHttpCookieJar *cookie_jar, |
|
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
1817 | GList *values) |
|
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
1818 | { |
|
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
1819 | values = g_list_first(values); |
|
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
1820 | while (values) { |
|
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
1821 | const gchar *cookie = values->data; |
|
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
1822 | const gchar *eqsign, *semicolon; |
|
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
1823 | gchar *name, *value; |
|
33460
c37dd51516aa
Deleting (or expiring) a cookie
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33459
diff
changeset
|
1824 | time_t expires = -1; |
|
33456
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
1825 | values = g_list_next(values); |
|
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
1826 | |
|
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
1827 | eqsign = strchr(cookie, '='); |
|
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
1828 | semicolon = strchr(cookie, ';'); |
|
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
1829 | |
|
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
1830 | if (eqsign == NULL || eqsign == cookie || |
|
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
1831 | (semicolon != NULL && semicolon < eqsign)) { |
|
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
1832 | if (purple_debug_is_unsafe()) |
|
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
1833 | purple_debug_warning("http", |
|
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
1834 | "Invalid cookie: [%s]\n", cookie); |
|
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
1835 | else |
|
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
1836 | purple_debug_warning("http", "Invalid cookie."); |
|
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
1837 | } |
|
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
1838 | |
|
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
1839 | name = g_strndup(cookie, eqsign - cookie); |
|
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
1840 | eqsign++; |
|
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
1841 | if (semicolon != NULL) |
|
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
1842 | value = g_strndup(eqsign, semicolon - eqsign); |
|
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
1843 | else |
|
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
1844 | value = g_strdup(eqsign); |
|
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
1845 | |
|
33459
722a6d753cb2
Better cookies, better chunked transfer support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33458
diff
changeset
|
1846 | if (semicolon != NULL) { |
|
33460
c37dd51516aa
Deleting (or expiring) a cookie
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33459
diff
changeset
|
1847 | GMatchInfo *match_info; |
|
c37dd51516aa
Deleting (or expiring) a cookie
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33459
diff
changeset
|
1848 | GRegex *re_expires = g_regex_new( |
|
c37dd51516aa
Deleting (or expiring) a cookie
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33459
diff
changeset
|
1849 | "expires=([a-z0-9, :]+)", |
|
c37dd51516aa
Deleting (or expiring) a cookie
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33459
diff
changeset
|
1850 | G_REGEX_OPTIMIZE | G_REGEX_CASELESS, |
|
c37dd51516aa
Deleting (or expiring) a cookie
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33459
diff
changeset
|
1851 | G_REGEX_MATCH_NOTEMPTY, NULL); |
|
c37dd51516aa
Deleting (or expiring) a cookie
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33459
diff
changeset
|
1852 | |
|
c37dd51516aa
Deleting (or expiring) a cookie
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33459
diff
changeset
|
1853 | 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
|
1854 | if (g_match_info_matches(match_info)) { |
|
c37dd51516aa
Deleting (or expiring) a cookie
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33459
diff
changeset
|
1855 | gchar *expire_date = |
|
c37dd51516aa
Deleting (or expiring) a cookie
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33459
diff
changeset
|
1856 | g_match_info_fetch(match_info, 1); |
|
c37dd51516aa
Deleting (or expiring) a cookie
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33459
diff
changeset
|
1857 | expires = purple_http_rfc1123_to_time( |
|
c37dd51516aa
Deleting (or expiring) a cookie
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33459
diff
changeset
|
1858 | expire_date); |
|
c37dd51516aa
Deleting (or expiring) a cookie
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33459
diff
changeset
|
1859 | g_free(expire_date); |
|
c37dd51516aa
Deleting (or expiring) a cookie
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33459
diff
changeset
|
1860 | } |
|
c37dd51516aa
Deleting (or expiring) a cookie
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33459
diff
changeset
|
1861 | g_match_info_free(match_info); |
|
c37dd51516aa
Deleting (or expiring) a cookie
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33459
diff
changeset
|
1862 | |
|
c37dd51516aa
Deleting (or expiring) a cookie
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33459
diff
changeset
|
1863 | g_regex_unref(re_expires); |
|
33459
722a6d753cb2
Better cookies, better chunked transfer support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33458
diff
changeset
|
1864 | } |
|
722a6d753cb2
Better cookies, better chunked transfer support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33458
diff
changeset
|
1865 | |
|
33460
c37dd51516aa
Deleting (or expiring) a cookie
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33459
diff
changeset
|
1866 | 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
|
1867 | |
|
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
1868 | g_free(name); |
|
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
1869 | g_free(value); |
|
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 | } |
|
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
1872 | |
|
33458
59b3364f690e
Sending cookies
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33457
diff
changeset
|
1873 | static gchar * purple_http_cookie_jar_gen(PurpleHttpCookieJar *cookie_jar) |
|
59b3364f690e
Sending cookies
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33457
diff
changeset
|
1874 | { |
|
59b3364f690e
Sending cookies
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33457
diff
changeset
|
1875 | GHashTableIter it; |
|
33459
722a6d753cb2
Better cookies, better chunked transfer support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33458
diff
changeset
|
1876 | gchar *key; |
|
722a6d753cb2
Better cookies, better chunked transfer support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33458
diff
changeset
|
1877 | PurpleHttpCookie *cookie; |
|
33458
59b3364f690e
Sending cookies
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33457
diff
changeset
|
1878 | GString *str; |
|
33460
c37dd51516aa
Deleting (or expiring) a cookie
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33459
diff
changeset
|
1879 | time_t now = time(NULL); |
|
33458
59b3364f690e
Sending cookies
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33457
diff
changeset
|
1880 | |
|
59b3364f690e
Sending cookies
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33457
diff
changeset
|
1881 | g_return_val_if_fail(cookie_jar != NULL, NULL); |
|
59b3364f690e
Sending cookies
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33457
diff
changeset
|
1882 | |
|
59b3364f690e
Sending cookies
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33457
diff
changeset
|
1883 | str = g_string_new(""); |
|
59b3364f690e
Sending cookies
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33457
diff
changeset
|
1884 | |
|
59b3364f690e
Sending cookies
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33457
diff
changeset
|
1885 | 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
|
1886 | 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
|
1887 | (gpointer*)&cookie)) { |
|
c37dd51516aa
Deleting (or expiring) a cookie
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33459
diff
changeset
|
1888 | if (cookie->expires != -1 && cookie->expires <= now) |
|
c37dd51516aa
Deleting (or expiring) a cookie
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33459
diff
changeset
|
1889 | continue; |
|
33459
722a6d753cb2
Better cookies, better chunked transfer support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33458
diff
changeset
|
1890 | 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
|
1891 | } |
|
33458
59b3364f690e
Sending cookies
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33457
diff
changeset
|
1892 | |
|
59b3364f690e
Sending cookies
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33457
diff
changeset
|
1893 | if (str->len > 0) |
|
59b3364f690e
Sending cookies
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33457
diff
changeset
|
1894 | g_string_truncate(str, str->len - 2); |
|
59b3364f690e
Sending cookies
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33457
diff
changeset
|
1895 | return g_string_free(str, FALSE); |
|
59b3364f690e
Sending cookies
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33457
diff
changeset
|
1896 | } |
|
59b3364f690e
Sending cookies
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33457
diff
changeset
|
1897 | |
|
33456
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
1898 | void purple_http_cookie_jar_set(PurpleHttpCookieJar *cookie_jar, |
|
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
1899 | const gchar *name, const gchar *value) |
|
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
1900 | { |
|
33459
722a6d753cb2
Better cookies, better chunked transfer support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33458
diff
changeset
|
1901 | 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
|
1902 | } |
|
722a6d753cb2
Better cookies, better chunked transfer support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33458
diff
changeset
|
1903 | |
|
722a6d753cb2
Better cookies, better chunked transfer support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33458
diff
changeset
|
1904 | 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
|
1905 | 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
|
1906 | { |
|
33456
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
1907 | g_return_if_fail(cookie_jar != NULL); |
|
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
1908 | g_return_if_fail(name != NULL); |
|
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
1909 | |
|
33460
c37dd51516aa
Deleting (or expiring) a cookie
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33459
diff
changeset
|
1910 | if (expires != -1 && time(NULL) >= expires) |
|
33459
722a6d753cb2
Better cookies, better chunked transfer support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33458
diff
changeset
|
1911 | value = NULL; |
|
722a6d753cb2
Better cookies, better chunked transfer support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33458
diff
changeset
|
1912 | |
|
722a6d753cb2
Better cookies, better chunked transfer support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33458
diff
changeset
|
1913 | if (value != NULL) { |
|
722a6d753cb2
Better cookies, better chunked transfer support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33458
diff
changeset
|
1914 | PurpleHttpCookie *cookie = purple_http_cookie_new(value); |
|
722a6d753cb2
Better cookies, better chunked transfer support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33458
diff
changeset
|
1915 | cookie->expires = expires; |
|
722a6d753cb2
Better cookies, better chunked transfer support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33458
diff
changeset
|
1916 | 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
|
1917 | } else |
|
33456
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
1918 | g_hash_table_remove(cookie_jar->tab, name); |
|
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
1919 | } |
|
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
1920 | |
|
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
1921 | const gchar * purple_http_cookie_jar_get(PurpleHttpCookieJar *cookie_jar, |
|
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
1922 | const gchar *name) |
|
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
1923 | { |
|
33459
722a6d753cb2
Better cookies, better chunked transfer support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33458
diff
changeset
|
1924 | PurpleHttpCookie *cookie; |
|
722a6d753cb2
Better cookies, better chunked transfer support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33458
diff
changeset
|
1925 | |
|
722a6d753cb2
Better cookies, better chunked transfer support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33458
diff
changeset
|
1926 | 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
|
1927 | 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
|
1928 | |
|
722a6d753cb2
Better cookies, better chunked transfer support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33458
diff
changeset
|
1929 | 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
|
1930 | if (!cookie) |
|
722a6d753cb2
Better cookies, better chunked transfer support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33458
diff
changeset
|
1931 | return NULL; |
|
722a6d753cb2
Better cookies, better chunked transfer support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33458
diff
changeset
|
1932 | |
|
722a6d753cb2
Better cookies, better chunked transfer support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33458
diff
changeset
|
1933 | return cookie->value; |
|
33456
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
1934 | } |
|
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 | gchar * purple_http_cookie_jar_dump(PurpleHttpCookieJar *cjar) |
|
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
1937 | { |
|
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
1938 | GHashTableIter it; |
|
33459
722a6d753cb2
Better cookies, better chunked transfer support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33458
diff
changeset
|
1939 | gchar *key; |
|
722a6d753cb2
Better cookies, better chunked transfer support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33458
diff
changeset
|
1940 | PurpleHttpCookie *cookie; |
|
33456
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
1941 | GString *str = g_string_new(""); |
|
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
1942 | |
|
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
1943 | 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
|
1944 | 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
|
1945 | 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
|
1946 | ")\n", key, cookie->value, (gint64)cookie->expires); |
|
33456
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
1947 | |
|
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
1948 | if (str->len > 0) |
|
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
1949 | g_string_truncate(str, str->len - 1); |
|
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
1950 | return g_string_free(str, FALSE); |
|
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
1951 | } |
|
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
1952 | |
|
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
1953 | gboolean purple_http_cookie_jar_is_empty(PurpleHttpCookieJar *cookie_jar) |
|
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
1954 | { |
|
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
1955 | g_return_val_if_fail(cookie_jar != NULL, TRUE); |
|
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
1956 | |
|
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
1957 | return g_hash_table_size(cookie_jar->tab) == 0; |
|
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
1958 | } |
|
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
1959 | |
|
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
|
1960 | /*** 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
|
1961 | |
|
34260
7a55eaa31da6
HTTP: implement keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34257
diff
changeset
|
1962 | static void |
|
34263
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
1963 | 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
|
1964 | |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
1965 | static void |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
1966 | purple_http_keepalive_host_free(gpointer _host) |
|
34260
7a55eaa31da6
HTTP: implement keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34257
diff
changeset
|
1967 | { |
|
34263
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
1968 | PurpleHttpKeepaliveHost *host = _host; |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
1969 | |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
1970 | if (host->process_queue_timeout > 0) { |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
1971 | 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
|
1972 | host->process_queue_timeout = 0; |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
1973 | } |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
1974 | |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
1975 | g_free(host->host); |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
1976 | |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
1977 | g_slist_free_full(host->queue, |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
1978 | (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
|
1979 | g_slist_free_full(host->sockets, |
|
34260
7a55eaa31da6
HTTP: implement keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34257
diff
changeset
|
1980 | (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
|
1981 | |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
1982 | g_free(host); |
|
34260
7a55eaa31da6
HTTP: implement keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34257
diff
changeset
|
1983 | } |
|
7a55eaa31da6
HTTP: implement keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34257
diff
changeset
|
1984 | |
|
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
|
1985 | 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
|
1986 | 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
|
1987 | { |
|
935120490eb2
HTTP: isolate socket-related code in http module; initial implementation for keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34234
diff
changeset
|
1988 | 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
|
1989 | |
|
935120490eb2
HTTP: isolate socket-related code in http module; initial implementation for keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34234
diff
changeset
|
1990 | pool->ref_count = 1; |
|
34260
7a55eaa31da6
HTTP: implement keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34257
diff
changeset
|
1991 | 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
|
1992 | 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
|
1993 | |
|
935120490eb2
HTTP: isolate socket-related code in http module; initial implementation for keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34234
diff
changeset
|
1994 | 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
|
1995 | } |
|
935120490eb2
HTTP: isolate socket-related code in http module; initial implementation for keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34234
diff
changeset
|
1996 | |
|
935120490eb2
HTTP: isolate socket-related code in http module; initial implementation for keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34234
diff
changeset
|
1997 | 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
|
1998 | 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
|
1999 | { |
|
935120490eb2
HTTP: isolate socket-related code in http module; initial implementation for keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34234
diff
changeset
|
2000 | 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
|
2001 | |
|
34263
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
2002 | if (pool->is_destroying) |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
2003 | return; |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
2004 | pool->is_destroying = TRUE; |
|
34260
7a55eaa31da6
HTTP: implement keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34257
diff
changeset
|
2005 | 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
|
2006 | 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
|
2007 | } |
|
935120490eb2
HTTP: isolate socket-related code in http module; initial implementation for keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34234
diff
changeset
|
2008 | |
|
935120490eb2
HTTP: isolate socket-related code in http module; initial implementation for keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34234
diff
changeset
|
2009 | 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
|
2010 | 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
|
2011 | { |
|
935120490eb2
HTTP: isolate socket-related code in http module; initial implementation for keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34234
diff
changeset
|
2012 | 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
|
2013 | |
|
935120490eb2
HTTP: isolate socket-related code in http module; initial implementation for keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34234
diff
changeset
|
2014 | 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
|
2015 | } |
|
935120490eb2
HTTP: isolate socket-related code in http module; initial implementation for keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34234
diff
changeset
|
2016 | |
|
935120490eb2
HTTP: isolate socket-related code in http module; initial implementation for keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34234
diff
changeset
|
2017 | 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
|
2018 | 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
|
2019 | { |
|
935120490eb2
HTTP: isolate socket-related code in http module; initial implementation for keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34234
diff
changeset
|
2020 | 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
|
2021 | 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
|
2022 | |
|
935120490eb2
HTTP: isolate socket-related code in http module; initial implementation for keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34234
diff
changeset
|
2023 | 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
|
2024 | |
|
935120490eb2
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 | 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
|
2026 | 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
|
2027 | 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
|
2028 | |
|
935120490eb2
HTTP: isolate socket-related code in http module; initial implementation for keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34234
diff
changeset
|
2029 | 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
|
2030 | 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
|
2031 | } |
|
935120490eb2
HTTP: isolate socket-related code in http module; initial implementation for keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34234
diff
changeset
|
2032 | |
|
34263
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
2033 | static PurpleHttpKeepaliveRequest * |
|
34260
7a55eaa31da6
HTTP: implement keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34257
diff
changeset
|
2034 | purple_http_keepalive_pool_request(PurpleHttpKeepalivePool *pool, |
|
7a55eaa31da6
HTTP: implement keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34257
diff
changeset
|
2035 | 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
|
2036 | PurpleHttpSocketConnectCb cb, gpointer user_data) |
|
7a55eaa31da6
HTTP: implement keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34257
diff
changeset
|
2037 | { |
|
34263
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
2038 | PurpleHttpKeepaliveRequest *req; |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
2039 | PurpleHttpKeepaliveHost *kahost; |
|
34260
7a55eaa31da6
HTTP: implement keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34257
diff
changeset
|
2040 | gchar *hash; |
|
34263
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_return_val_if_fail(pool != NULL, NULL); |
|
34260
7a55eaa31da6
HTTP: implement keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34257
diff
changeset
|
2043 | g_return_val_if_fail(host != NULL, NULL); |
|
7a55eaa31da6
HTTP: implement keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34257
diff
changeset
|
2044 | |
|
34263
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
2045 | if (pool->is_destroying) { |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
2046 | 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
|
2047 | return NULL; |
|
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 | |
|
7a55eaa31da6
HTTP: implement keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34257
diff
changeset
|
2050 | 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
|
2051 | 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
|
2052 | |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
2053 | if (kahost == NULL) { |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
2054 | kahost = g_new0(PurpleHttpKeepaliveHost, 1); |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
2055 | kahost->pool = pool; |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
2056 | kahost->host = g_strdup(host); |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
2057 | kahost->port = port; |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
2058 | kahost->is_ssl = is_ssl; |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
2059 | |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
2060 | 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
|
2061 | } |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
2062 | |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
2063 | g_free(hash); |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
2064 | |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
2065 | req = g_new0(PurpleHttpKeepaliveRequest, 1); |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
2066 | req->gc = gc; |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
2067 | req->cb = cb; |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
2068 | req->user_data = user_data; |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
2069 | req->host = kahost; |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
2070 | |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
2071 | 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
|
2072 | |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
2073 | 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
|
2074 | |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
2075 | return req; |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
2076 | } |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
2077 | |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
2078 | static void |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
2079 | _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
|
2080 | const gchar *error, gpointer _req) |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
2081 | { |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
2082 | PurpleHttpKeepaliveRequest *req = _req; |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
2083 | |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
2084 | if (hs != NULL) |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
2085 | hs->use_count++; |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
2086 | |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
2087 | 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
|
2088 | g_free(req); |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
2089 | } |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
2090 | |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
2091 | static gboolean |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
2092 | _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
|
2093 | { |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
2094 | PurpleHttpKeepaliveRequest *req; |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
2095 | PurpleHttpKeepaliveHost *host = _host; |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
2096 | PurpleHttpSocket *hs = NULL; |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
2097 | GSList *it; |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
2098 | int sockets_count; |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
2099 | |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
2100 | 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
|
2101 | |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
2102 | host->process_queue_timeout = 0; |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
2103 | |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
2104 | if (host->queue == NULL) |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
2105 | return FALSE; |
|
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 | sockets_count = 0; |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
2108 | it = host->sockets; |
|
34260
7a55eaa31da6
HTTP: implement keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34257
diff
changeset
|
2109 | while (it != NULL) { |
|
7a55eaa31da6
HTTP: implement keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34257
diff
changeset
|
2110 | PurpleHttpSocket *hs_current = it->data; |
|
7a55eaa31da6
HTTP: implement keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34257
diff
changeset
|
2111 | |
|
34263
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
2112 | sockets_count++; |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
2113 | |
|
34260
7a55eaa31da6
HTTP: implement keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34257
diff
changeset
|
2114 | if (!hs_current->is_busy) { |
|
7a55eaa31da6
HTTP: implement keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34257
diff
changeset
|
2115 | hs = hs_current; |
|
7a55eaa31da6
HTTP: implement keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34257
diff
changeset
|
2116 | break; |
|
7a55eaa31da6
HTTP: implement keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34257
diff
changeset
|
2117 | } |
|
7a55eaa31da6
HTTP: implement keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34257
diff
changeset
|
2118 | |
|
7a55eaa31da6
HTTP: implement keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34257
diff
changeset
|
2119 | it = g_slist_next(it); |
|
7a55eaa31da6
HTTP: implement keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34257
diff
changeset
|
2120 | } |
|
7a55eaa31da6
HTTP: implement keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34257
diff
changeset
|
2121 | |
|
34263
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
2122 | /* 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
|
2123 | 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
|
2124 | host->pool->limit_per_host > 0) |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
2125 | { |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
2126 | return FALSE; |
|
34260
7a55eaa31da6
HTTP: implement keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34257
diff
changeset
|
2127 | } |
|
7a55eaa31da6
HTTP: implement keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34257
diff
changeset
|
2128 | |
|
34263
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
2129 | req = host->queue->data; |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
2130 | 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
|
2131 | |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
2132 | if (hs != NULL) { |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
2133 | if (purple_debug_is_verbose()) { |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
2134 | 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
|
2135 | "socket: %p\n", hs); |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
2136 | } |
|
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 | hs->is_busy = TRUE; |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
2139 | hs->use_count++; |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
2140 | |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
2141 | 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
|
2142 | g_free(req); |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
2143 | |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
2144 | return TRUE; /* run again */ |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
2145 | } |
|
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 | 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
|
2148 | 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
|
2149 | _purple_http_keepalive_socket_connected, req); |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
2150 | req->hs = hs; |
|
34260
7a55eaa31da6
HTTP: implement keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34257
diff
changeset
|
2151 | hs->is_busy = TRUE; |
|
34263
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
2152 | hs->host = host; |
|
34260
7a55eaa31da6
HTTP: implement keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34257
diff
changeset
|
2153 | |
|
34262
3b8ce83bac96
HTTP: get rid of one (of two) msn's own http implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34261
diff
changeset
|
2154 | if (purple_debug_is_verbose()) |
|
34263
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
2155 | 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
|
2156 | |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
2157 | 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
|
2158 | |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
2159 | return FALSE; |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
2160 | } |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
2161 | |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
2162 | static void |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
2163 | 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
|
2164 | { |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
2165 | g_return_if_fail(host != NULL); |
|
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 | if (host->process_queue_timeout > 0) |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
2168 | return; |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
2169 | |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
2170 | 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
|
2171 | _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
|
2172 | } |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
2173 | |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
2174 | static void |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
2175 | 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
|
2176 | { |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
2177 | if (req == NULL) |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
2178 | return; |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
2179 | |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
2180 | if (req->host != NULL) |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
2181 | 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
|
2182 | |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
2183 | if (req->hs != NULL) { |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
2184 | 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
|
2185 | req->hs); |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
2186 | 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
|
2187 | /* 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
|
2188 | } else { |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
2189 | 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
|
2190 | g_free(req); |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
2191 | } |
|
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 | |
|
7a55eaa31da6
HTTP: implement keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34257
diff
changeset
|
2194 | static void |
|
7a55eaa31da6
HTTP: implement keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34257
diff
changeset
|
2195 | 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
|
2196 | { |
|
34263
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
2197 | PurpleHttpKeepaliveHost *host; |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
2198 | |
|
34260
7a55eaa31da6
HTTP: implement keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34257
diff
changeset
|
2199 | if (hs == NULL) |
|
7a55eaa31da6
HTTP: implement keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34257
diff
changeset
|
2200 | return; |
|
7a55eaa31da6
HTTP: implement keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34257
diff
changeset
|
2201 | |
|
34262
3b8ce83bac96
HTTP: get rid of one (of two) msn's own http implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34261
diff
changeset
|
2202 | 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
|
2203 | 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
|
2204 | |
|
34260
7a55eaa31da6
HTTP: implement keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34257
diff
changeset
|
2205 | purple_http_socket_dontwatch(hs); |
|
7a55eaa31da6
HTTP: implement keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34257
diff
changeset
|
2206 | hs->is_busy = FALSE; |
|
34263
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
2207 | host = hs->host; |
|
34260
7a55eaa31da6
HTTP: implement keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34257
diff
changeset
|
2208 | |
|
7a55eaa31da6
HTTP: implement keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34257
diff
changeset
|
2209 | if (invalidate) { |
|
34263
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
2210 | 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
|
2211 | purple_http_socket_close_free(hs); |
|
7a55eaa31da6
HTTP: implement keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34257
diff
changeset
|
2212 | } |
|
34263
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
2213 | |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
2214 | if (host != NULL) |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
2215 | purple_http_keepalive_host_process_queue(host); |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
2216 | } |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
2217 | |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
2218 | void |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
2219 | 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
|
2220 | guint limit) |
|
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 | g_return_if_fail(pool != NULL); |
|
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 | pool->limit_per_host = limit; |
|
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 | guint |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
2228 | 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
|
2229 | { |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
2230 | 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
|
2231 | |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
2232 | return pool->limit_per_host; |
|
34260
7a55eaa31da6
HTTP: implement keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34257
diff
changeset
|
2233 | } |
|
7a55eaa31da6
HTTP: implement keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34257
diff
changeset
|
2234 | |
|
33427
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
2235 | /*** Request API **************************************************************/ |
|
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
2236 | |
|
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
2237 | 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
|
2238 | |
|
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
2239 | 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
|
2240 | { |
|
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
2241 | PurpleHttpRequest *request; |
|
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
2242 | |
|
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
2243 | request = g_new0(PurpleHttpRequest, 1); |
|
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
2244 | |
|
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
2245 | request->ref_count = 1; |
|
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
2246 | 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
|
2247 | request->headers = purple_http_headers_new(); |
|
33456
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
2248 | 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
|
2249 | 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
|
2250 | |
|
33450
4042907bcdf1
Timeout support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33448
diff
changeset
|
2251 | 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
|
2252 | 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
|
2253 | 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
|
2254 | 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
|
2255 | |
|
33427
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
2256 | return request; |
|
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
2257 | } |
|
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
2258 | |
|
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
2259 | 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
|
2260 | { |
|
33447
b890f231e15f
Request headers support, wrapping new API with legacy purple_util_fetch_url
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33446
diff
changeset
|
2261 | purple_http_headers_free(request->headers); |
|
33456
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
2262 | 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
|
2263 | 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
|
2264 | g_free(request->url); |
|
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
2265 | g_free(request); |
|
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
2266 | } |
|
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
2267 | |
|
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
2268 | 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
|
2269 | { |
|
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
2270 | g_return_if_fail(request != NULL); |
|
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
2271 | |
|
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
2272 | request->ref_count++; |
|
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
2273 | } |
|
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
2274 | |
|
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
2275 | 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
|
2276 | { |
|
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
2277 | if (request == NULL) |
|
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
2278 | return NULL; |
|
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
2279 | |
|
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
2280 | 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
|
2281 | |
|
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
2282 | request->ref_count--; |
|
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
2283 | if (request->ref_count > 0) |
|
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
2284 | return request; |
|
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
2285 | |
|
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
2286 | purple_http_request_free(request); |
|
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
2287 | return NULL; |
|
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
2288 | } |
|
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
2289 | |
|
33451
27d0e5dbc2a1
Implement missing getters/setters and corresponding features
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33450
diff
changeset
|
2290 | 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
|
2291 | { |
|
27d0e5dbc2a1
Implement missing getters/setters and corresponding features
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33450
diff
changeset
|
2292 | g_return_if_fail(request != NULL); |
|
27d0e5dbc2a1
Implement missing getters/setters and corresponding features
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33450
diff
changeset
|
2293 | g_return_if_fail(url != NULL); |
|
27d0e5dbc2a1
Implement missing getters/setters and corresponding features
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33450
diff
changeset
|
2294 | |
|
27d0e5dbc2a1
Implement missing getters/setters and corresponding features
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33450
diff
changeset
|
2295 | g_free(request->url); |
|
27d0e5dbc2a1
Implement missing getters/setters and corresponding features
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33450
diff
changeset
|
2296 | request->url = g_strdup(url); |
|
27d0e5dbc2a1
Implement missing getters/setters and corresponding features
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33450
diff
changeset
|
2297 | } |
|
27d0e5dbc2a1
Implement missing getters/setters and corresponding features
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33450
diff
changeset
|
2298 | |
|
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
|
2299 | 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
|
2300 | 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
|
2301 | { |
|
a5517f235e0f
HTTP: migrate purple_util_fetch_url_request to new API for GG prpl
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34225
diff
changeset
|
2302 | 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
|
2303 | 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
|
2304 | |
|
a5517f235e0f
HTTP: migrate purple_util_fetch_url_request to new API for GG prpl
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34225
diff
changeset
|
2305 | 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
|
2306 | 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
|
2307 | |
|
a5517f235e0f
HTTP: migrate purple_util_fetch_url_request to new API for GG prpl
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34225
diff
changeset
|
2308 | 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
|
2309 | 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
|
2310 | 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
|
2311 | |
|
a5517f235e0f
HTTP: migrate purple_util_fetch_url_request to new API for GG prpl
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34225
diff
changeset
|
2312 | 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
|
2313 | 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
|
2314 | } |
|
a5517f235e0f
HTTP: migrate purple_util_fetch_url_request to new API for GG prpl
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34225
diff
changeset
|
2315 | |
|
33451
27d0e5dbc2a1
Implement missing getters/setters and corresponding features
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33450
diff
changeset
|
2316 | 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
|
2317 | { |
|
27d0e5dbc2a1
Implement missing getters/setters and corresponding features
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33450
diff
changeset
|
2318 | 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
|
2319 | |
|
27d0e5dbc2a1
Implement missing getters/setters and corresponding features
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33450
diff
changeset
|
2320 | return request->url; |
|
27d0e5dbc2a1
Implement missing getters/setters and corresponding features
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33450
diff
changeset
|
2321 | } |
|
27d0e5dbc2a1
Implement missing getters/setters and corresponding features
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33450
diff
changeset
|
2322 | |
|
27d0e5dbc2a1
Implement missing getters/setters and corresponding features
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33450
diff
changeset
|
2323 | 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
|
2324 | { |
|
27d0e5dbc2a1
Implement missing getters/setters and corresponding features
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33450
diff
changeset
|
2325 | g_return_if_fail(request != NULL); |
|
27d0e5dbc2a1
Implement missing getters/setters and corresponding features
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33450
diff
changeset
|
2326 | |
|
27d0e5dbc2a1
Implement missing getters/setters and corresponding features
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33450
diff
changeset
|
2327 | g_free(request->method); |
|
27d0e5dbc2a1
Implement missing getters/setters and corresponding features
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33450
diff
changeset
|
2328 | request->method = g_strdup(method); |
|
27d0e5dbc2a1
Implement missing getters/setters and corresponding features
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33450
diff
changeset
|
2329 | } |
|
27d0e5dbc2a1
Implement missing getters/setters and corresponding features
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33450
diff
changeset
|
2330 | |
|
27d0e5dbc2a1
Implement missing getters/setters and corresponding features
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33450
diff
changeset
|
2331 | 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
|
2332 | { |
|
27d0e5dbc2a1
Implement missing getters/setters and corresponding features
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33450
diff
changeset
|
2333 | 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
|
2334 | |
|
27d0e5dbc2a1
Implement missing getters/setters and corresponding features
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33450
diff
changeset
|
2335 | return request->method; |
|
27d0e5dbc2a1
Implement missing getters/setters and corresponding features
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33450
diff
changeset
|
2336 | } |
|
27d0e5dbc2a1
Implement missing getters/setters and corresponding features
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33450
diff
changeset
|
2337 | |
|
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
|
2338 | 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
|
2339 | 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
|
2340 | { |
|
a5517f235e0f
HTTP: migrate purple_util_fetch_url_request to new API for GG prpl
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34225
diff
changeset
|
2341 | 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
|
2342 | |
|
a5517f235e0f
HTTP: migrate purple_util_fetch_url_request to new API for GG prpl
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34225
diff
changeset
|
2343 | 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
|
2344 | 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
|
2345 | |
|
a5517f235e0f
HTTP: migrate purple_util_fetch_url_request to new API for GG prpl
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34225
diff
changeset
|
2346 | 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
|
2347 | 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
|
2348 | 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
|
2349 | 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
|
2350 | } |
|
a5517f235e0f
HTTP: migrate purple_util_fetch_url_request to new API for GG prpl
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34225
diff
changeset
|
2351 | |
|
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
|
2352 | 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
|
2353 | 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
|
2354 | 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
|
2355 | { |
|
935120490eb2
HTTP: isolate socket-related code in http module; initial implementation for keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34234
diff
changeset
|
2356 | 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
|
2357 | |
|
34260
7a55eaa31da6
HTTP: implement keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34257
diff
changeset
|
2358 | if (pool != NULL) |
|
7a55eaa31da6
HTTP: implement keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34257
diff
changeset
|
2359 | purple_http_keepalive_pool_ref(pool); |
|
7a55eaa31da6
HTTP: implement keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34257
diff
changeset
|
2360 | |
|
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
|
2361 | 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
|
2362 | 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
|
2363 | 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
|
2364 | } |
|
935120490eb2
HTTP: isolate socket-related code in http module; initial implementation for keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34234
diff
changeset
|
2365 | |
|
34260
7a55eaa31da6
HTTP: implement keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34257
diff
changeset
|
2366 | 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
|
2367 | 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
|
2368 | } |
|
935120490eb2
HTTP: isolate socket-related code in http module; initial implementation for keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34234
diff
changeset
|
2369 | |
|
935120490eb2
HTTP: isolate socket-related code in http module; initial implementation for keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34234
diff
changeset
|
2370 | 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
|
2371 | 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
|
2372 | { |
|
935120490eb2
HTTP: isolate socket-related code in http module; initial implementation for keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34234
diff
changeset
|
2373 | 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
|
2374 | |
|
935120490eb2
HTTP: isolate socket-related code in http module; initial implementation for keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34234
diff
changeset
|
2375 | 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
|
2376 | } |
|
935120490eb2
HTTP: isolate socket-related code in http module; initial implementation for keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34234
diff
changeset
|
2377 | |
|
33457
81f92a310aff
Writing request contents
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33456
diff
changeset
|
2378 | void purple_http_request_set_contents(PurpleHttpRequest *request, |
|
81f92a310aff
Writing request contents
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33456
diff
changeset
|
2379 | const gchar *contents, int length) |
|
81f92a310aff
Writing request contents
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33456
diff
changeset
|
2380 | { |
|
81f92a310aff
Writing request contents
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33456
diff
changeset
|
2381 | g_return_if_fail(request != NULL); |
|
81f92a310aff
Writing request contents
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33456
diff
changeset
|
2382 | g_return_if_fail(length >= -1); |
|
81f92a310aff
Writing request contents
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33456
diff
changeset
|
2383 | |
|
33466
918507303f45
HTTP API: PurpleHttpContentReader support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33464
diff
changeset
|
2384 | request->contents_reader = NULL; |
|
918507303f45
HTTP API: PurpleHttpContentReader support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33464
diff
changeset
|
2385 | request->contents_reader_data = NULL; |
|
918507303f45
HTTP API: PurpleHttpContentReader support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33464
diff
changeset
|
2386 | |
|
33457
81f92a310aff
Writing request contents
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33456
diff
changeset
|
2387 | g_free(request->contents); |
|
81f92a310aff
Writing request contents
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33456
diff
changeset
|
2388 | if (contents == NULL || length == 0) { |
|
81f92a310aff
Writing request contents
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33456
diff
changeset
|
2389 | request->contents = NULL; |
|
81f92a310aff
Writing request contents
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33456
diff
changeset
|
2390 | request->contents_length = 0; |
|
81f92a310aff
Writing request contents
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33456
diff
changeset
|
2391 | return; |
|
81f92a310aff
Writing request contents
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33456
diff
changeset
|
2392 | } |
|
81f92a310aff
Writing request contents
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33456
diff
changeset
|
2393 | |
|
81f92a310aff
Writing request contents
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33456
diff
changeset
|
2394 | if (length == -1) |
|
81f92a310aff
Writing request contents
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33456
diff
changeset
|
2395 | length = strlen(contents); |
|
81f92a310aff
Writing request contents
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33456
diff
changeset
|
2396 | request->contents = g_memdup(contents, length); |
|
81f92a310aff
Writing request contents
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33456
diff
changeset
|
2397 | request->contents_length = length; |
|
81f92a310aff
Writing request contents
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33456
diff
changeset
|
2398 | } |
|
81f92a310aff
Writing request contents
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33456
diff
changeset
|
2399 | |
|
33466
918507303f45
HTTP API: PurpleHttpContentReader support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33464
diff
changeset
|
2400 | void purple_http_request_set_contents_reader(PurpleHttpRequest *request, |
|
918507303f45
HTTP API: PurpleHttpContentReader support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33464
diff
changeset
|
2401 | PurpleHttpContentReader reader, int contents_length, gpointer user_data) |
|
918507303f45
HTTP API: PurpleHttpContentReader support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33464
diff
changeset
|
2402 | { |
|
918507303f45
HTTP API: PurpleHttpContentReader support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33464
diff
changeset
|
2403 | g_return_if_fail(request != NULL); |
|
918507303f45
HTTP API: PurpleHttpContentReader support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33464
diff
changeset
|
2404 | g_return_if_fail(reader != NULL); |
|
918507303f45
HTTP API: PurpleHttpContentReader support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33464
diff
changeset
|
2405 | g_return_if_fail(contents_length >= -1); |
|
918507303f45
HTTP API: PurpleHttpContentReader support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33464
diff
changeset
|
2406 | |
|
918507303f45
HTTP API: PurpleHttpContentReader support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33464
diff
changeset
|
2407 | g_free(request->contents); |
|
918507303f45
HTTP API: PurpleHttpContentReader support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33464
diff
changeset
|
2408 | request->contents = NULL; |
|
918507303f45
HTTP API: PurpleHttpContentReader support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33464
diff
changeset
|
2409 | request->contents_length = contents_length; |
|
918507303f45
HTTP API: PurpleHttpContentReader support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33464
diff
changeset
|
2410 | request->contents_reader = reader; |
|
918507303f45
HTTP API: PurpleHttpContentReader support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33464
diff
changeset
|
2411 | request->contents_reader_data = user_data; |
|
918507303f45
HTTP API: PurpleHttpContentReader support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33464
diff
changeset
|
2412 | } |
|
918507303f45
HTTP API: PurpleHttpContentReader support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33464
diff
changeset
|
2413 | |
|
33517
ddd9e37c4b07
HTTP: PurpleHttpContentWriter support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33469
diff
changeset
|
2414 | void purple_http_request_set_response_writer(PurpleHttpRequest *request, |
|
ddd9e37c4b07
HTTP: PurpleHttpContentWriter support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33469
diff
changeset
|
2415 | PurpleHttpContentWriter writer, gpointer user_data) |
|
ddd9e37c4b07
HTTP: PurpleHttpContentWriter support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33469
diff
changeset
|
2416 | { |
|
ddd9e37c4b07
HTTP: PurpleHttpContentWriter support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33469
diff
changeset
|
2417 | g_return_if_fail(request != NULL); |
|
ddd9e37c4b07
HTTP: PurpleHttpContentWriter support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33469
diff
changeset
|
2418 | |
|
ddd9e37c4b07
HTTP: PurpleHttpContentWriter support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33469
diff
changeset
|
2419 | if (writer == NULL) |
|
ddd9e37c4b07
HTTP: PurpleHttpContentWriter support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33469
diff
changeset
|
2420 | user_data = NULL; |
|
ddd9e37c4b07
HTTP: PurpleHttpContentWriter support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33469
diff
changeset
|
2421 | request->response_writer = writer; |
|
ddd9e37c4b07
HTTP: PurpleHttpContentWriter support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33469
diff
changeset
|
2422 | request->response_writer_data = user_data; |
|
ddd9e37c4b07
HTTP: PurpleHttpContentWriter support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33469
diff
changeset
|
2423 | } |
|
ddd9e37c4b07
HTTP: PurpleHttpContentWriter support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33469
diff
changeset
|
2424 | |
|
33450
4042907bcdf1
Timeout support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33448
diff
changeset
|
2425 | void purple_http_request_set_timeout(PurpleHttpRequest *request, int timeout) |
|
4042907bcdf1
Timeout support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33448
diff
changeset
|
2426 | { |
|
4042907bcdf1
Timeout support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33448
diff
changeset
|
2427 | g_return_if_fail(request != NULL); |
|
4042907bcdf1
Timeout support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33448
diff
changeset
|
2428 | |
|
4042907bcdf1
Timeout support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33448
diff
changeset
|
2429 | if (timeout < -1) |
|
4042907bcdf1
Timeout support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33448
diff
changeset
|
2430 | timeout = -1; |
|
4042907bcdf1
Timeout support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33448
diff
changeset
|
2431 | |
|
4042907bcdf1
Timeout support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33448
diff
changeset
|
2432 | request->timeout = timeout; |
|
4042907bcdf1
Timeout support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33448
diff
changeset
|
2433 | } |
|
4042907bcdf1
Timeout support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33448
diff
changeset
|
2434 | |
|
4042907bcdf1
Timeout support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33448
diff
changeset
|
2435 | int purple_http_request_get_timeout(PurpleHttpRequest *request) |
|
4042907bcdf1
Timeout support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33448
diff
changeset
|
2436 | { |
|
4042907bcdf1
Timeout support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33448
diff
changeset
|
2437 | g_return_val_if_fail(request != NULL, -1); |
|
4042907bcdf1
Timeout support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33448
diff
changeset
|
2438 | |
|
4042907bcdf1
Timeout support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33448
diff
changeset
|
2439 | return request->timeout; |
|
4042907bcdf1
Timeout support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33448
diff
changeset
|
2440 | } |
|
4042907bcdf1
Timeout support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33448
diff
changeset
|
2441 | |
|
33444
b3afec292014
New features: http version switching and limits for redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33443
diff
changeset
|
2442 | 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
|
2443 | int max_redirects) |
|
b3afec292014
New features: http version switching and limits for redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33443
diff
changeset
|
2444 | { |
|
b3afec292014
New features: http version switching and limits for redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33443
diff
changeset
|
2445 | 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
|
2446 | |
|
b3afec292014
New features: http version switching and limits for redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33443
diff
changeset
|
2447 | if (max_redirects < -1) |
|
b3afec292014
New features: http version switching and limits for redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33443
diff
changeset
|
2448 | max_redirects = -1; |
|
b3afec292014
New features: http version switching and limits for redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33443
diff
changeset
|
2449 | |
|
b3afec292014
New features: http version switching and limits for redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33443
diff
changeset
|
2450 | 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
|
2451 | } |
|
b3afec292014
New features: http version switching and limits for redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33443
diff
changeset
|
2452 | |
|
b3afec292014
New features: http version switching and limits for redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33443
diff
changeset
|
2453 | 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
|
2454 | { |
|
b3afec292014
New features: http version switching and limits for redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33443
diff
changeset
|
2455 | 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
|
2456 | |
|
b3afec292014
New features: http version switching and limits for redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33443
diff
changeset
|
2457 | return request->max_redirects; |
|
b3afec292014
New features: http version switching and limits for redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33443
diff
changeset
|
2458 | } |
|
b3afec292014
New features: http version switching and limits for redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33443
diff
changeset
|
2459 | |
|
33456
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
2460 | void purple_http_request_set_cookie_jar(PurpleHttpRequest *request, |
|
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
2461 | PurpleHttpCookieJar *cookie_jar) |
|
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
2462 | { |
|
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
2463 | g_return_if_fail(request != NULL); |
|
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
2464 | g_return_if_fail(cookie_jar != NULL); |
|
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
2465 | |
|
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
2466 | purple_http_cookie_jar_ref(cookie_jar); |
|
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
2467 | purple_http_cookie_jar_unref(request->cookie_jar); |
|
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
2468 | request->cookie_jar = cookie_jar; |
|
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
2469 | } |
|
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
2470 | |
|
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
2471 | PurpleHttpCookieJar * purple_http_request_get_cookie_jar( |
|
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
2472 | PurpleHttpRequest *request) |
|
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
2473 | { |
|
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
2474 | g_return_val_if_fail(request != NULL, NULL); |
|
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
2475 | |
|
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
2476 | return request->cookie_jar; |
|
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
2477 | } |
|
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
2478 | |
|
33444
b3afec292014
New features: http version switching and limits for redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33443
diff
changeset
|
2479 | 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
|
2480 | { |
|
b3afec292014
New features: http version switching and limits for redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33443
diff
changeset
|
2481 | 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
|
2482 | |
|
b3afec292014
New features: http version switching and limits for redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33443
diff
changeset
|
2483 | request->http11 = http11; |
|
b3afec292014
New features: http version switching and limits for redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33443
diff
changeset
|
2484 | } |
|
b3afec292014
New features: http version switching and limits for redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33443
diff
changeset
|
2485 | |
|
b3afec292014
New features: http version switching and limits for redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33443
diff
changeset
|
2486 | 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
|
2487 | { |
|
b3afec292014
New features: http version switching and limits for redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33443
diff
changeset
|
2488 | 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
|
2489 | |
|
b3afec292014
New features: http version switching and limits for redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33443
diff
changeset
|
2490 | return request->http11; |
|
b3afec292014
New features: http version switching and limits for redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33443
diff
changeset
|
2491 | } |
|
b3afec292014
New features: http version switching and limits for redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33443
diff
changeset
|
2492 | |
|
33446
95fda782966c
New feature: setting maximum length of response
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33445
diff
changeset
|
2493 | 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
|
2494 | { |
|
95fda782966c
New feature: setting maximum length of response
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33445
diff
changeset
|
2495 | g_return_if_fail(request != NULL); |
|
95fda782966c
New feature: setting maximum length of response
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33445
diff
changeset
|
2496 | |
|
95fda782966c
New feature: setting maximum length of response
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33445
diff
changeset
|
2497 | if (max_len < -1) |
|
95fda782966c
New feature: setting maximum length of response
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33445
diff
changeset
|
2498 | max_len = -1; |
|
95fda782966c
New feature: setting maximum length of response
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33445
diff
changeset
|
2499 | |
|
95fda782966c
New feature: setting maximum length of response
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33445
diff
changeset
|
2500 | request->max_length = max_len; |
|
95fda782966c
New feature: setting maximum length of response
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33445
diff
changeset
|
2501 | } |
|
95fda782966c
New feature: setting maximum length of response
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33445
diff
changeset
|
2502 | |
|
95fda782966c
New feature: setting maximum length of response
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33445
diff
changeset
|
2503 | 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
|
2504 | { |
|
95fda782966c
New feature: setting maximum length of response
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33445
diff
changeset
|
2505 | 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
|
2506 | |
|
95fda782966c
New feature: setting maximum length of response
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33445
diff
changeset
|
2507 | return request->max_length; |
|
95fda782966c
New feature: setting maximum length of response
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33445
diff
changeset
|
2508 | } |
|
95fda782966c
New feature: setting maximum length of response
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33445
diff
changeset
|
2509 | |
|
33447
b890f231e15f
Request headers support, wrapping new API with legacy purple_util_fetch_url
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33446
diff
changeset
|
2510 | 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
|
2511 | 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
|
2512 | { |
|
b890f231e15f
Request headers support, wrapping new API with legacy purple_util_fetch_url
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33446
diff
changeset
|
2513 | 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
|
2514 | 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
|
2515 | |
|
b890f231e15f
Request headers support, wrapping new API with legacy purple_util_fetch_url
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33446
diff
changeset
|
2516 | 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
|
2517 | 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
|
2518 | 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
|
2519 | } |
|
b890f231e15f
Request headers support, wrapping new API with legacy purple_util_fetch_url
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33446
diff
changeset
|
2520 | |
|
33455
2de654702970
Print-like setting headers, vestigal keepalive support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33454
diff
changeset
|
2521 | 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
|
2522 | const gchar *key, const gchar *format, ...) |
|
2de654702970
Print-like setting headers, vestigal keepalive support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33454
diff
changeset
|
2523 | { |
|
2de654702970
Print-like setting headers, vestigal keepalive support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33454
diff
changeset
|
2524 | va_list args; |
|
2de654702970
Print-like setting headers, vestigal keepalive support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33454
diff
changeset
|
2525 | gchar *value; |
|
2de654702970
Print-like setting headers, vestigal keepalive support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33454
diff
changeset
|
2526 | |
|
2de654702970
Print-like setting headers, vestigal keepalive support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33454
diff
changeset
|
2527 | g_return_if_fail(request != NULL); |
|
2de654702970
Print-like setting headers, vestigal keepalive support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33454
diff
changeset
|
2528 | g_return_if_fail(key != NULL); |
|
2de654702970
Print-like setting headers, vestigal keepalive support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33454
diff
changeset
|
2529 | g_return_if_fail(format != NULL); |
|
2de654702970
Print-like setting headers, vestigal keepalive support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33454
diff
changeset
|
2530 | |
|
2de654702970
Print-like setting headers, vestigal keepalive support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33454
diff
changeset
|
2531 | va_start(args, format); |
|
2de654702970
Print-like setting headers, vestigal keepalive support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33454
diff
changeset
|
2532 | value = g_strdup_vprintf(format, args); |
|
2de654702970
Print-like setting headers, vestigal keepalive support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33454
diff
changeset
|
2533 | va_end(args); |
|
2de654702970
Print-like setting headers, vestigal keepalive support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33454
diff
changeset
|
2534 | |
|
2de654702970
Print-like setting headers, vestigal keepalive support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33454
diff
changeset
|
2535 | 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
|
2536 | g_free(value); |
|
2de654702970
Print-like setting headers, vestigal keepalive support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33454
diff
changeset
|
2537 | } |
|
2de654702970
Print-like setting headers, vestigal keepalive support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33454
diff
changeset
|
2538 | |
|
33447
b890f231e15f
Request headers support, wrapping new API with legacy purple_util_fetch_url
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33446
diff
changeset
|
2539 | 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
|
2540 | 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
|
2541 | { |
|
b890f231e15f
Request headers support, wrapping new API with legacy purple_util_fetch_url
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33446
diff
changeset
|
2542 | 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
|
2543 | 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
|
2544 | |
|
b890f231e15f
Request headers support, wrapping new API with legacy purple_util_fetch_url
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33446
diff
changeset
|
2545 | 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
|
2546 | } |
|
b890f231e15f
Request headers support, wrapping new API with legacy purple_util_fetch_url
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33446
diff
changeset
|
2547 | |
|
33427
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
2548 | /*** HTTP response API ********************************************************/ |
|
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
2549 | |
|
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
2550 | 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
|
2551 | { |
|
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
2552 | PurpleHttpResponse *response = g_new0(PurpleHttpResponse, 1); |
|
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
2553 | |
|
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
2554 | return response; |
|
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
2555 | } |
|
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
2556 | |
|
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
2557 | 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
|
2558 | { |
|
33433
fb7ac52ed7df
Let's get response contents
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33432
diff
changeset
|
2559 | if (response->contents != NULL) |
|
fb7ac52ed7df
Let's get response contents
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33432
diff
changeset
|
2560 | g_string_free(response->contents, TRUE); |
|
33430
013c5aebb665
Let's connect
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33429
diff
changeset
|
2561 | g_free(response->error); |
|
33432
9c4acb75b2e6
Let's parse response headers
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33431
diff
changeset
|
2562 | 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
|
2563 | g_free(response); |
|
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
2564 | } |
|
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
2565 | |
|
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
2566 | gboolean purple_http_response_is_successfull(PurpleHttpResponse *response) |
|
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
2567 | { |
|
33432
9c4acb75b2e6
Let's parse response headers
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33431
diff
changeset
|
2568 | int code; |
|
9c4acb75b2e6
Let's parse response headers
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33431
diff
changeset
|
2569 | |
|
33427
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
2570 | 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
|
2571 | |
|
33432
9c4acb75b2e6
Let's parse response headers
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33431
diff
changeset
|
2572 | code = response->code; |
|
9c4acb75b2e6
Let's parse response headers
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33431
diff
changeset
|
2573 | |
|
9c4acb75b2e6
Let's parse response headers
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33431
diff
changeset
|
2574 | if (code <= 0) |
|
9c4acb75b2e6
Let's parse response headers
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33431
diff
changeset
|
2575 | return FALSE; |
|
9c4acb75b2e6
Let's parse response headers
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33431
diff
changeset
|
2576 | |
|
34262
3b8ce83bac96
HTTP: get rid of one (of two) msn's own http implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34261
diff
changeset
|
2577 | /* 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
|
2578 | |
|
33458
59b3364f690e
Sending cookies
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33457
diff
changeset
|
2579 | if (code / 100 == 2) |
|
33432
9c4acb75b2e6
Let's parse response headers
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33431
diff
changeset
|
2580 | return TRUE; |
|
9c4acb75b2e6
Let's parse response headers
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33431
diff
changeset
|
2581 | |
|
9c4acb75b2e6
Let's parse response headers
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33431
diff
changeset
|
2582 | return FALSE; |
|
33427
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
2583 | } |
|
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
2584 | |
|
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
2585 | 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
|
2586 | { |
|
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
2587 | 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
|
2588 | |
|
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
2589 | return response->code; |
|
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
2590 | } |
|
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
2591 | |
|
33430
013c5aebb665
Let's connect
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33429
diff
changeset
|
2592 | const gchar * purple_http_response_get_error(PurpleHttpResponse *response) |
|
013c5aebb665
Let's connect
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33429
diff
changeset
|
2593 | { |
|
013c5aebb665
Let's connect
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33429
diff
changeset
|
2594 | g_return_val_if_fail(response != NULL, NULL); |
|
013c5aebb665
Let's connect
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33429
diff
changeset
|
2595 | |
|
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
|
2596 | 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
|
2597 | 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
|
2598 | |
|
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
|
2599 | if (!purple_http_response_is_successfull(response)) { |
|
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
|
2600 | 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
|
2601 | 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
|
2602 | 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
|
2603 | _("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
|
2604 | } 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
|
2605 | 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
|
2606 | _("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
|
2607 | 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
|
2608 | } |
|
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
|
2609 | 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
|
2610 | } |
|
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
|
2611 | |
|
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
|
2612 | return NULL; |
|
33430
013c5aebb665
Let's connect
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33429
diff
changeset
|
2613 | } |
|
013c5aebb665
Let's connect
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33429
diff
changeset
|
2614 | |
|
33427
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
2615 | 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
|
2616 | { |
|
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
2617 | 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
|
2618 | |
|
33433
fb7ac52ed7df
Let's get response contents
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33432
diff
changeset
|
2619 | if (response->contents == NULL) |
|
fb7ac52ed7df
Let's get response contents
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33432
diff
changeset
|
2620 | return 0; |
|
fb7ac52ed7df
Let's get response contents
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33432
diff
changeset
|
2621 | |
|
fb7ac52ed7df
Let's get response contents
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33432
diff
changeset
|
2622 | return response->contents->len; |
|
33427
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
2623 | } |
|
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
2624 | |
|
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
|
2625 | 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
|
2626 | { |
|
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
|
2627 | 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
|
2628 | |
|
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
|
2629 | 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
|
2630 | |
|
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
|
2631 | 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
|
2632 | 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
|
2633 | 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
|
2634 | *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
|
2635 | } 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
|
2636 | 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
|
2637 | *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
|
2638 | } |
|
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
|
2639 | |
|
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
|
2640 | return ret; |
|
33427
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
2641 | } |
|
33429
1ce1faf4e675
Extend URL parsing
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33427
diff
changeset
|
2642 | |
|
33451
27d0e5dbc2a1
Implement missing getters/setters and corresponding features
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33450
diff
changeset
|
2643 | 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
|
2644 | { |
|
27d0e5dbc2a1
Implement missing getters/setters and corresponding features
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33450
diff
changeset
|
2645 | 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
|
2646 | |
|
27d0e5dbc2a1
Implement missing getters/setters and corresponding features
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33450
diff
changeset
|
2647 | 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
|
2648 | } |
|
27d0e5dbc2a1
Implement missing getters/setters and corresponding features
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33450
diff
changeset
|
2649 | |
|
27d0e5dbc2a1
Implement missing getters/setters and corresponding features
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33450
diff
changeset
|
2650 | 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
|
2651 | PurpleHttpResponse *response, const gchar *name) |
|
27d0e5dbc2a1
Implement missing getters/setters and corresponding features
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33450
diff
changeset
|
2652 | { |
|
27d0e5dbc2a1
Implement missing getters/setters and corresponding features
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33450
diff
changeset
|
2653 | 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
|
2654 | 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
|
2655 | |
|
27d0e5dbc2a1
Implement missing getters/setters and corresponding features
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33450
diff
changeset
|
2656 | 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
|
2657 | } |
|
27d0e5dbc2a1
Implement missing getters/setters and corresponding features
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33450
diff
changeset
|
2658 | |
|
27d0e5dbc2a1
Implement missing getters/setters and corresponding features
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33450
diff
changeset
|
2659 | 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
|
2660 | const gchar *name) |
|
27d0e5dbc2a1
Implement missing getters/setters and corresponding features
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33450
diff
changeset
|
2661 | { |
|
27d0e5dbc2a1
Implement missing getters/setters and corresponding features
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33450
diff
changeset
|
2662 | 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
|
2663 | 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
|
2664 | |
|
27d0e5dbc2a1
Implement missing getters/setters and corresponding features
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33450
diff
changeset
|
2665 | 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
|
2666 | } |
|
27d0e5dbc2a1
Implement missing getters/setters and corresponding features
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33450
diff
changeset
|
2667 | |
|
33429
1ce1faf4e675
Extend URL parsing
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33427
diff
changeset
|
2668 | /*** URL functions ************************************************************/ |
|
1ce1faf4e675
Extend URL parsing
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33427
diff
changeset
|
2669 | |
|
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
|
2670 | 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
|
2671 | purple_http_url_parse(const char *raw_url) |
|
33429
1ce1faf4e675
Extend URL parsing
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33427
diff
changeset
|
2672 | { |
|
33439
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
2673 | PurpleHttpURL *url; |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
2674 | GMatchInfo *match_info; |
|
33429
1ce1faf4e675
Extend URL parsing
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33427
diff
changeset
|
2675 | |
|
33439
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
2676 | gchar *host_full, *tmp; |
|
33429
1ce1faf4e675
Extend URL parsing
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33427
diff
changeset
|
2677 | |
|
33439
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
2678 | g_return_val_if_fail(raw_url != NULL, NULL); |
|
33429
1ce1faf4e675
Extend URL parsing
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33427
diff
changeset
|
2679 | |
|
33439
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
2680 | url = g_new0(PurpleHttpURL, 1); |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
2681 | |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
2682 | 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
|
2683 | if (purple_debug_is_verbose() && purple_debug_is_unsafe()) { |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
2684 | purple_debug_warning("http", |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
2685 | "Invalid URL provided: %s\n", |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
2686 | raw_url); |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
2687 | } |
|
33429
1ce1faf4e675
Extend URL parsing
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33427
diff
changeset
|
2688 | return NULL; |
|
1ce1faf4e675
Extend URL parsing
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33427
diff
changeset
|
2689 | } |
|
1ce1faf4e675
Extend URL parsing
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33427
diff
changeset
|
2690 | |
|
33439
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
2691 | url->protocol = g_match_info_fetch(match_info, 1); |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
2692 | host_full = g_match_info_fetch(match_info, 2); |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
2693 | url->path = g_match_info_fetch(match_info, 3); |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
2694 | url->fragment = g_match_info_fetch(match_info, 4); |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
2695 | g_match_info_free(match_info); |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
2696 | |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
2697 | if (url->protocol[0] == '\0') { |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
2698 | g_free(url->protocol); |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
2699 | url->protocol = NULL; |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
2700 | } else if (url->protocol != NULL) { |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
2701 | tmp = url->protocol; |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
2702 | url->protocol = g_ascii_strdown(url->protocol, -1); |
|
33431
704de181d1d2
Let's request
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33430
diff
changeset
|
2703 | g_free(tmp); |
|
704de181d1d2
Let's request
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33430
diff
changeset
|
2704 | } |
|
33439
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
2705 | if (host_full[0] == '\0') { |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
2706 | g_free(host_full); |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
2707 | host_full = NULL; |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
2708 | } |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
2709 | if (url->path[0] == '\0') { |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
2710 | g_free(url->path); |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
2711 | url->path = NULL; |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
2712 | } |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
2713 | if ((url->protocol == NULL) != (host_full == NULL)) |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
2714 | purple_debug_warning("http", "Protocol or host not present " |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
2715 | "(unlikely case)\n"); |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
2716 | |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
2717 | if (host_full) { |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
2718 | gchar *port_str; |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
2719 | |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
2720 | 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
|
2721 | &match_info)) { |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
2722 | if (purple_debug_is_verbose() && |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
2723 | purple_debug_is_unsafe()) { |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
2724 | purple_debug_warning("http", |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
2725 | "Invalid host provided for URL: %s\n", |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
2726 | raw_url); |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
2727 | } |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
2728 | |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
2729 | g_free(host_full); |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
2730 | purple_http_url_free(url); |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
2731 | return NULL; |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
2732 | } |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
2733 | |
|
34219
eee308def583
HTTP: get rid of purple_url_parse
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34218
diff
changeset
|
2734 | url->username = g_match_info_fetch(match_info, 1); |
|
33439
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
2735 | url->password = g_match_info_fetch(match_info, 2); |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
2736 | url->host = g_match_info_fetch(match_info, 3); |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
2737 | port_str = g_match_info_fetch(match_info, 4); |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
2738 | |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
2739 | if (port_str && port_str[0]) |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
2740 | url->port = atoi(port_str); |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
2741 | |
|
34219
eee308def583
HTTP: get rid of purple_url_parse
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34218
diff
changeset
|
2742 | if (url->username[0] == '\0') { |
|
eee308def583
HTTP: get rid of purple_url_parse
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34218
diff
changeset
|
2743 | g_free(url->username); |
|
eee308def583
HTTP: get rid of purple_url_parse
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34218
diff
changeset
|
2744 | url->username = NULL; |
|
33439
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
2745 | } |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
2746 | if (url->password[0] == '\0') { |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
2747 | g_free(url->password); |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
2748 | url->password = NULL; |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
2749 | } |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
2750 | if (url->host[0] == '\0') { |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
2751 | g_free(url->host); |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
2752 | url->host = NULL; |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
2753 | } else if (url->host != NULL) { |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
2754 | tmp = url->host; |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
2755 | url->host = g_ascii_strdown(url->host, -1); |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
2756 | g_free(tmp); |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
2757 | } |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
2758 | |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
2759 | g_free(port_str); |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
2760 | g_match_info_free(match_info); |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
2761 | |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
2762 | g_free(host_full); |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
2763 | host_full = NULL; |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
2764 | } |
|
33431
704de181d1d2
Let's request
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33430
diff
changeset
|
2765 | |
|
33439
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
2766 | if (url->host != NULL) { |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
2767 | if (url->protocol == NULL) |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
2768 | url->protocol = g_strdup("http"); |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
2769 | if (url->port == 0 && 0 == strcmp(url->protocol, "http")) |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
2770 | url->port = 80; |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
2771 | if (url->port == 0 && 0 == strcmp(url->protocol, "https")) |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
2772 | url->port = 443; |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
2773 | if (url->path == NULL) |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
2774 | url->path = g_strdup("/"); |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
2775 | if (url->path[0] != '/') |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
2776 | purple_debug_warning("http", |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
2777 | "URL path doesn't start with slash\n"); |
|
33431
704de181d1d2
Let's request
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33430
diff
changeset
|
2778 | } |
|
704de181d1d2
Let's request
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33430
diff
changeset
|
2779 | |
|
33439
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
2780 | return url; |
|
33429
1ce1faf4e675
Extend URL parsing
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33427
diff
changeset
|
2781 | } |
|
1ce1faf4e675
Extend URL parsing
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33427
diff
changeset
|
2782 | |
|
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
|
2783 | 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
|
2784 | purple_http_url_free(PurpleHttpURL *parsed_url) |
|
33429
1ce1faf4e675
Extend URL parsing
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33427
diff
changeset
|
2785 | { |
|
1ce1faf4e675
Extend URL parsing
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33427
diff
changeset
|
2786 | if (parsed_url == NULL) |
|
1ce1faf4e675
Extend URL parsing
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33427
diff
changeset
|
2787 | return; |
|
1ce1faf4e675
Extend URL parsing
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33427
diff
changeset
|
2788 | |
|
1ce1faf4e675
Extend URL parsing
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33427
diff
changeset
|
2789 | g_free(parsed_url->protocol); |
|
34219
eee308def583
HTTP: get rid of purple_url_parse
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34218
diff
changeset
|
2790 | g_free(parsed_url->username); |
|
33439
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
2791 | g_free(parsed_url->password); |
|
33429
1ce1faf4e675
Extend URL parsing
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33427
diff
changeset
|
2792 | g_free(parsed_url->host); |
|
1ce1faf4e675
Extend URL parsing
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33427
diff
changeset
|
2793 | g_free(parsed_url->path); |
|
33439
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
2794 | g_free(parsed_url->fragment); |
|
33429
1ce1faf4e675
Extend URL parsing
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33427
diff
changeset
|
2795 | g_free(parsed_url); |
|
1ce1faf4e675
Extend URL parsing
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33427
diff
changeset
|
2796 | } |
|
1ce1faf4e675
Extend URL parsing
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33427
diff
changeset
|
2797 | |
|
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
|
2798 | 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
|
2799 | purple_http_url_relative(PurpleHttpURL *base_url, PurpleHttpURL *relative_url) |
|
33439
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
2800 | { |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
2801 | g_return_if_fail(base_url != NULL); |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
2802 | g_return_if_fail(relative_url != NULL); |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
2803 | |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
2804 | if (relative_url->host) { |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
2805 | g_free(base_url->protocol); |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
2806 | 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
|
2807 | g_free(base_url->username); |
|
eee308def583
HTTP: get rid of purple_url_parse
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34218
diff
changeset
|
2808 | base_url->username = g_strdup(relative_url->username); |
|
33439
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
2809 | g_free(base_url->password); |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
2810 | base_url->password = g_strdup(relative_url->password); |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
2811 | g_free(base_url->host); |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
2812 | base_url->host = g_strdup(relative_url->host); |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
2813 | base_url->port = relative_url->port; |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
2814 | |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
2815 | g_free(base_url->path); |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
2816 | base_url->path = NULL; |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
2817 | } |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
2818 | |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
2819 | if (relative_url->path) { |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
2820 | if (relative_url->path[0] == '/' || |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
2821 | base_url->path == NULL) { |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
2822 | g_free(base_url->path); |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
2823 | base_url->path = g_strdup(relative_url->path); |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
2824 | } else { |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
2825 | gchar *last_slash = strrchr(base_url->path, '/'); |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
2826 | gchar *tmp; |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
2827 | if (last_slash == NULL) |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
2828 | base_url->path[0] = '\0'; |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
2829 | else |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
2830 | last_slash[1] = '\0'; |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
2831 | tmp = base_url->path; |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
2832 | base_url->path = g_strconcat(base_url->path, |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
2833 | relative_url->path, NULL); |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
2834 | g_free(tmp); |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
2835 | } |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
2836 | } |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
2837 | |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
2838 | g_free(base_url->fragment); |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
2839 | base_url->fragment = g_strdup(relative_url->fragment); |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
2840 | } |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
2841 | |
|
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
|
2842 | 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
|
2843 | purple_http_url_print(PurpleHttpURL *parsed_url) |
|
33429
1ce1faf4e675
Extend URL parsing
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33427
diff
changeset
|
2844 | { |
|
33438
66c4b90ff08a
More debug prints
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33437
diff
changeset
|
2845 | GString *url = g_string_new(""); |
|
66c4b90ff08a
More debug prints
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33437
diff
changeset
|
2846 | gboolean before_host_printed = FALSE, host_printed = FALSE; |
|
33439
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
2847 | gboolean port_is_default = FALSE; |
|
33430
013c5aebb665
Let's connect
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33429
diff
changeset
|
2848 | |
|
33439
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
2849 | if (parsed_url->protocol) { |
|
33438
66c4b90ff08a
More debug prints
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33437
diff
changeset
|
2850 | g_string_append_printf(url, "%s://", parsed_url->protocol); |
|
66c4b90ff08a
More debug prints
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33437
diff
changeset
|
2851 | before_host_printed = TRUE; |
|
33439
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
2852 | if (parsed_url->port == 80 && 0 == strcmp(parsed_url->protocol, |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
2853 | "http")) |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
2854 | port_is_default = TRUE; |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
2855 | if (parsed_url->port == 443 && 0 == strcmp(parsed_url->protocol, |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
2856 | "https")) |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
2857 | port_is_default = TRUE; |
|
33438
66c4b90ff08a
More debug prints
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33437
diff
changeset
|
2858 | } |
|
34219
eee308def583
HTTP: get rid of purple_url_parse
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34218
diff
changeset
|
2859 | 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
|
2860 | if (parsed_url->username) |
|
eee308def583
HTTP: get rid of purple_url_parse
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34218
diff
changeset
|
2861 | g_string_append(url, parsed_url->username); |
|
33438
66c4b90ff08a
More debug prints
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33437
diff
changeset
|
2862 | g_string_append_printf(url, ":%s", parsed_url->password); |
|
66c4b90ff08a
More debug prints
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33437
diff
changeset
|
2863 | g_string_append(url, "@"); |
|
66c4b90ff08a
More debug prints
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33437
diff
changeset
|
2864 | before_host_printed = TRUE; |
|
66c4b90ff08a
More debug prints
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33437
diff
changeset
|
2865 | } |
|
33439
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
2866 | if (parsed_url->host || parsed_url->port) { |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
2867 | if (!parsed_url->host) |
|
33438
66c4b90ff08a
More debug prints
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33437
diff
changeset
|
2868 | g_string_append_printf(url, "{???}:%d", |
|
66c4b90ff08a
More debug prints
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33437
diff
changeset
|
2869 | parsed_url->port); |
|
66c4b90ff08a
More debug prints
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33437
diff
changeset
|
2870 | else { |
|
66c4b90ff08a
More debug prints
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33437
diff
changeset
|
2871 | g_string_append(url, parsed_url->host); |
|
33439
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
2872 | if (!port_is_default) |
|
33438
66c4b90ff08a
More debug prints
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33437
diff
changeset
|
2873 | g_string_append_printf(url, ":%d", |
|
66c4b90ff08a
More debug prints
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33437
diff
changeset
|
2874 | parsed_url->port); |
|
66c4b90ff08a
More debug prints
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33437
diff
changeset
|
2875 | } |
|
66c4b90ff08a
More debug prints
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33437
diff
changeset
|
2876 | host_printed = TRUE; |
|
66c4b90ff08a
More debug prints
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33437
diff
changeset
|
2877 | } |
|
33439
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
2878 | if (parsed_url->path) { |
|
33438
66c4b90ff08a
More debug prints
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33437
diff
changeset
|
2879 | if (!host_printed && before_host_printed) |
|
66c4b90ff08a
More debug prints
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33437
diff
changeset
|
2880 | g_string_append(url, "{???}"); |
|
66c4b90ff08a
More debug prints
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33437
diff
changeset
|
2881 | g_string_append(url, parsed_url->path); |
|
66c4b90ff08a
More debug prints
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33437
diff
changeset
|
2882 | } |
|
33439
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
2883 | if (parsed_url->fragment) |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
2884 | g_string_append_printf(url, "#%s", parsed_url->fragment); |
|
33429
1ce1faf4e675
Extend URL parsing
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33427
diff
changeset
|
2885 | |
|
33438
66c4b90ff08a
More debug prints
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33437
diff
changeset
|
2886 | return g_string_free(url, FALSE); |
|
33429
1ce1faf4e675
Extend URL parsing
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33427
diff
changeset
|
2887 | } |
|
33439
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
2888 | |
|
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
|
2889 | 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
|
2890 | 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
|
2891 | { |
|
de45cb0670a5
HTTP: make purple_url_parse deprecated in favor of purple_http_url_parse
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33868
diff
changeset
|
2892 | 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
|
2893 | |
|
de45cb0670a5
HTTP: make purple_url_parse deprecated in favor of purple_http_url_parse
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33868
diff
changeset
|
2894 | 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
|
2895 | } |
|
de45cb0670a5
HTTP: make purple_url_parse deprecated in favor of purple_http_url_parse
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33868
diff
changeset
|
2896 | |
|
de45cb0670a5
HTTP: make purple_url_parse deprecated in favor of purple_http_url_parse
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33868
diff
changeset
|
2897 | const gchar * |
|
34219
eee308def583
HTTP: get rid of purple_url_parse
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34218
diff
changeset
|
2898 | 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
|
2899 | { |
|
de45cb0670a5
HTTP: make purple_url_parse deprecated in favor of purple_http_url_parse
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33868
diff
changeset
|
2900 | 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
|
2901 | |
|
34219
eee308def583
HTTP: get rid of purple_url_parse
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34218
diff
changeset
|
2902 | 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
|
2903 | } |
|
de45cb0670a5
HTTP: make purple_url_parse deprecated in favor of purple_http_url_parse
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33868
diff
changeset
|
2904 | |
|
de45cb0670a5
HTTP: make purple_url_parse deprecated in favor of purple_http_url_parse
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33868
diff
changeset
|
2905 | 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
|
2906 | 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
|
2907 | { |
|
de45cb0670a5
HTTP: make purple_url_parse deprecated in favor of purple_http_url_parse
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33868
diff
changeset
|
2908 | 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
|
2909 | |
|
de45cb0670a5
HTTP: make purple_url_parse deprecated in favor of purple_http_url_parse
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33868
diff
changeset
|
2910 | 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
|
2911 | } |
|
de45cb0670a5
HTTP: make purple_url_parse deprecated in favor of purple_http_url_parse
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33868
diff
changeset
|
2912 | |
|
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 | 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
|
2914 | 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
|
2915 | { |
|
de45cb0670a5
HTTP: make purple_url_parse deprecated in favor of purple_http_url_parse
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33868
diff
changeset
|
2916 | 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
|
2917 | |
|
de45cb0670a5
HTTP: make purple_url_parse deprecated in favor of purple_http_url_parse
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33868
diff
changeset
|
2918 | 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
|
2919 | } |
|
de45cb0670a5
HTTP: make purple_url_parse deprecated in favor of purple_http_url_parse
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33868
diff
changeset
|
2920 | |
|
de45cb0670a5
HTTP: make purple_url_parse deprecated in favor of purple_http_url_parse
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33868
diff
changeset
|
2921 | 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
|
2922 | 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
|
2923 | { |
|
de45cb0670a5
HTTP: make purple_url_parse deprecated in favor of purple_http_url_parse
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33868
diff
changeset
|
2924 | 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
|
2925 | |
|
de45cb0670a5
HTTP: make purple_url_parse deprecated in favor of purple_http_url_parse
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33868
diff
changeset
|
2926 | 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
|
2927 | } |
|
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 | |
|
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 | 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
|
2930 | 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
|
2931 | { |
|
de45cb0670a5
HTTP: make purple_url_parse deprecated in favor of purple_http_url_parse
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33868
diff
changeset
|
2932 | 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
|
2933 | |
|
de45cb0670a5
HTTP: make purple_url_parse deprecated in favor of purple_http_url_parse
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33868
diff
changeset
|
2934 | 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
|
2935 | } |
|
de45cb0670a5
HTTP: make purple_url_parse deprecated in favor of purple_http_url_parse
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33868
diff
changeset
|
2936 | |
|
de45cb0670a5
HTTP: make purple_url_parse deprecated in favor of purple_http_url_parse
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33868
diff
changeset
|
2937 | 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
|
2938 | 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
|
2939 | { |
|
de45cb0670a5
HTTP: make purple_url_parse deprecated in favor of purple_http_url_parse
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33868
diff
changeset
|
2940 | 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
|
2941 | |
|
de45cb0670a5
HTTP: make purple_url_parse deprecated in favor of purple_http_url_parse
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33868
diff
changeset
|
2942 | 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
|
2943 | } |
|
de45cb0670a5
HTTP: make purple_url_parse deprecated in favor of purple_http_url_parse
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33868
diff
changeset
|
2944 | |
|
33439
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
2945 | /*** HTTP Subsystem ***********************************************************/ |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
2946 | |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
2947 | void purple_http_init(void) |
|
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 | purple_http_re_url = g_regex_new("^" |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
2950 | |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
2951 | "(?:" /* host part beginning */ |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
2952 | "([a-z]+)\\:/*" /* protocol */ |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
2953 | "([^/]+)" /* username, password, host, port */ |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
2954 | ")?" /* host part ending */ |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
2955 | |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
2956 | "([^#]*)" /* path */ |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
2957 | |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
2958 | "(?:#" "(.*)" ")?" /* fragment */ |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
2959 | |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
2960 | "$", G_REGEX_OPTIMIZE | G_REGEX_CASELESS, |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
2961 | G_REGEX_MATCH_NOTEMPTY, NULL); |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
2962 | |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
2963 | purple_http_re_url_host = g_regex_new("^" |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
2964 | |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
2965 | "(?:" /* user credentials part beginning */ |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
2966 | "([" PURPLE_HTTP_URL_CREDENTIALS_CHARS "]+)" /* username */ |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
2967 | "(?::([" PURPLE_HTTP_URL_CREDENTIALS_CHARS "]+))" /* password */ |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
2968 | "@)?" /* user credentials part ending */ |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
2969 | |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
2970 | "([a-z0-9.-]+)" /* host */ |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
2971 | "(?::([0-9]+))?" /* port*/ |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
2972 | |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
2973 | "$", G_REGEX_OPTIMIZE | G_REGEX_CASELESS, |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
2974 | 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
|
2975 | |
|
33460
c37dd51516aa
Deleting (or expiring) a cookie
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33459
diff
changeset
|
2976 | purple_http_re_rfc1123 = g_regex_new( |
|
c37dd51516aa
Deleting (or expiring) a cookie
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33459
diff
changeset
|
2977 | "^[a-z]+, " /* weekday */ |
|
c37dd51516aa
Deleting (or expiring) a cookie
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33459
diff
changeset
|
2978 | "([0-9]+) " /* date */ |
|
c37dd51516aa
Deleting (or expiring) a cookie
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33459
diff
changeset
|
2979 | "([a-z]+) " /* month */ |
|
c37dd51516aa
Deleting (or expiring) a cookie
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33459
diff
changeset
|
2980 | "([0-9]+) " /* year */ |
|
c37dd51516aa
Deleting (or expiring) a cookie
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33459
diff
changeset
|
2981 | "([0-9]+:[0-9]+:[0-9]+) " /* time */ |
|
c37dd51516aa
Deleting (or expiring) a cookie
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33459
diff
changeset
|
2982 | "(?:GMT|UTC)$", |
|
c37dd51516aa
Deleting (or expiring) a cookie
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33459
diff
changeset
|
2983 | G_REGEX_OPTIMIZE | G_REGEX_CASELESS, |
|
c37dd51516aa
Deleting (or expiring) a cookie
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33459
diff
changeset
|
2984 | G_REGEX_MATCH_NOTEMPTY, NULL); |
|
c37dd51516aa
Deleting (or expiring) a cookie
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33459
diff
changeset
|
2985 | |
|
33448
4d41b1f7b95f
Cancelling all HTTP connections on account disconnect or app shutdown
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33447
diff
changeset
|
2986 | 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
|
2987 | 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
|
2988 | 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
|
2989 | 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
|
2990 | 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
|
2991 | } |
|
4d41b1f7b95f
Cancelling all HTTP connections on account disconnect or app shutdown
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33447
diff
changeset
|
2992 | |
|
4d41b1f7b95f
Cancelling all HTTP connections on account disconnect or app shutdown
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33447
diff
changeset
|
2993 | 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
|
2994 | { |
|
4d41b1f7b95f
Cancelling all HTTP connections on account disconnect or app shutdown
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33447
diff
changeset
|
2995 | PurpleHttpConnection *hc = _hc; |
|
4d41b1f7b95f
Cancelling all HTTP connections on account disconnect or app shutdown
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33447
diff
changeset
|
2996 | purple_http_conn_cancel(hc); |
|
33439
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
2997 | } |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
2998 | |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
2999 | void purple_http_uninit(void) |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
3000 | { |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
3001 | g_regex_unref(purple_http_re_url); |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
3002 | purple_http_re_url = NULL; |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
3003 | g_regex_unref(purple_http_re_url_host); |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
3004 | purple_http_re_url_host = NULL; |
|
33460
c37dd51516aa
Deleting (or expiring) a cookie
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33459
diff
changeset
|
3005 | g_regex_unref(purple_http_re_rfc1123); |
|
c37dd51516aa
Deleting (or expiring) a cookie
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33459
diff
changeset
|
3006 | 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
|
3007 | |
|
4d41b1f7b95f
Cancelling all HTTP connections on account disconnect or app shutdown
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33447
diff
changeset
|
3008 | 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
|
3009 | NULL); |
|
4d41b1f7b95f
Cancelling all HTTP connections on account disconnect or app shutdown
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33447
diff
changeset
|
3010 | |
|
4d41b1f7b95f
Cancelling all HTTP connections on account disconnect or app shutdown
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33447
diff
changeset
|
3011 | 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
|
3012 | 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
|
3013 | 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
|
3014 | 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
|
3015 | "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
|
3016 | |
|
4d41b1f7b95f
Cancelling all HTTP connections on account disconnect or app shutdown
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33447
diff
changeset
|
3017 | 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
|
3018 | 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
|
3019 | 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
|
3020 | 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
|
3021 | 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
|
3022 | 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
|
3023 | 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
|
3024 | purple_http_cancelling_gc = NULL; |
|
33439
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
3025 | } |