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