Sat, 17 Oct 2015 20:41:26 -0400
Merge default into facebook
|
33425
379bf9ad6973
Initial HTTP API definitions
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
1 | /* purple |
|
379bf9ad6973
Initial HTTP API definitions
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
2 | * |
|
379bf9ad6973
Initial HTTP API definitions
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
3 | * 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
|
4 | * 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
|
5 | * source distribution. |
|
379bf9ad6973
Initial HTTP API definitions
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
6 | * |
|
379bf9ad6973
Initial HTTP API definitions
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
7 | * 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
|
8 | * 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
|
9 | * 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
|
10 | * (at your option) any later version. |
|
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 distributed in the hope that it will be useful, |
|
379bf9ad6973
Initial HTTP API definitions
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
379bf9ad6973
Initial HTTP API definitions
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
379bf9ad6973
Initial HTTP API definitions
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
15 | * GNU General Public License for more details. |
|
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 | * 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
|
18 | * 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
|
19 | * 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
|
20 | */ |
|
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 | #include "http.h" |
|
379bf9ad6973
Initial HTTP API definitions
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
diff
changeset
|
23 | |
|
33427
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
24 | #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
|
25 | #include "glibcompat.h" |
|
33453
3cb58ea9667c
HTTP Proxy support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33452
diff
changeset
|
26 | |
|
33427
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
27 | #include "debug.h" |
|
33453
3cb58ea9667c
HTTP Proxy support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33452
diff
changeset
|
28 | #include "ntlm.h" |
|
34316
2a3a587f5403
HTTP: make use of PurpleSocket
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
34314
diff
changeset
|
29 | #include "purple-socket.h" |
|
33427
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
30 | |
|
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
|
31 | #include <zlib.h> |
|
34323
d4c01e0b2737
Fix compilation for older zlib
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
34316
diff
changeset
|
32 | #ifndef z_const |
|
d4c01e0b2737
Fix compilation for older zlib
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
34316
diff
changeset
|
33 | #define z_const |
|
d4c01e0b2737
Fix compilation for older zlib
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
34316
diff
changeset
|
34 | #endif |
|
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
|
35 | |
|
33439
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
36 | #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
|
37 | #define PURPLE_HTTP_MAX_RECV_BUFFER_LEN 10240 |
|
33466
918507303f45
HTTP API: PurpleHttpContentReader support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33464
diff
changeset
|
38 | #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
|
39 | #define PURPLE_HTTP_GZ_BUFF_LEN 1024 |
|
33439
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
40 | |
|
33444
b3afec292014
New features: http version switching and limits for redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33443
diff
changeset
|
41 | #define PURPLE_HTTP_REQUEST_DEFAULT_MAX_REDIRECTS 20 |
|
33450
4042907bcdf1
Timeout support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33448
diff
changeset
|
42 | #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
|
43 | #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
|
44 | #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
|
45 | |
|
34272
8df870b218ca
HTTP: chop off another HTTP implementation (for xmpp oob file transfers)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34268
diff
changeset
|
46 | #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
|
47 | |
|
33430
013c5aebb665
Let's connect
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33429
diff
changeset
|
48 | typedef struct _PurpleHttpSocket PurpleHttpSocket; |
|
013c5aebb665
Let's connect
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33429
diff
changeset
|
49 | |
|
33432
9c4acb75b2e6
Let's parse response headers
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33431
diff
changeset
|
50 | typedef struct _PurpleHttpHeaders PurpleHttpHeaders; |
|
9c4acb75b2e6
Let's parse response headers
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33431
diff
changeset
|
51 | |
|
34263
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
52 | typedef struct _PurpleHttpKeepaliveHost PurpleHttpKeepaliveHost; |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
53 | |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
54 | typedef struct _PurpleHttpKeepaliveRequest PurpleHttpKeepaliveRequest; |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
55 | |
|
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
|
56 | 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
|
57 | |
|
33430
013c5aebb665
Let's connect
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33429
diff
changeset
|
58 | struct _PurpleHttpSocket |
|
013c5aebb665
Let's connect
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33429
diff
changeset
|
59 | { |
|
34316
2a3a587f5403
HTTP: make use of PurpleSocket
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
34314
diff
changeset
|
60 | PurpleSocket *ps; |
|
2a3a587f5403
HTTP: make use of PurpleSocket
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
34314
diff
changeset
|
61 | |
|
34260
7a55eaa31da6
HTTP: implement keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34257
diff
changeset
|
62 | gboolean is_busy; |
|
34267
7eef0ddc8ab2
Fix win32 build
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34266
diff
changeset
|
63 | guint use_count; |
|
34263
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
64 | PurpleHttpKeepaliveHost *host; |
|
33430
013c5aebb665
Let's connect
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33429
diff
changeset
|
65 | }; |
|
013c5aebb665
Let's connect
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33429
diff
changeset
|
66 | |
|
33427
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
67 | struct _PurpleHttpRequest |
|
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
68 | { |
|
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
69 | int ref_count; |
|
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 | gchar *url; |
|
33451
27d0e5dbc2a1
Implement missing getters/setters and corresponding features
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33450
diff
changeset
|
72 | 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
|
73 | PurpleHttpHeaders *headers; |
|
33456
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
74 | 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
|
75 | PurpleHttpKeepalivePool *keepalive_pool; |
|
33444
b3afec292014
New features: http version switching and limits for redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33443
diff
changeset
|
76 | |
|
33457
81f92a310aff
Writing request contents
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33456
diff
changeset
|
77 | gchar *contents; |
|
81f92a310aff
Writing request contents
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33456
diff
changeset
|
78 | int contents_length; |
|
33466
918507303f45
HTTP API: PurpleHttpContentReader support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33464
diff
changeset
|
79 | PurpleHttpContentReader contents_reader; |
|
918507303f45
HTTP API: PurpleHttpContentReader support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33464
diff
changeset
|
80 | gpointer contents_reader_data; |
|
33517
ddd9e37c4b07
HTTP: PurpleHttpContentWriter support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33469
diff
changeset
|
81 | PurpleHttpContentWriter response_writer; |
|
ddd9e37c4b07
HTTP: PurpleHttpContentWriter support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33469
diff
changeset
|
82 | gpointer response_writer_data; |
|
33457
81f92a310aff
Writing request contents
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33456
diff
changeset
|
83 | |
|
33450
4042907bcdf1
Timeout support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33448
diff
changeset
|
84 | int timeout; |
|
33444
b3afec292014
New features: http version switching and limits for redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33443
diff
changeset
|
85 | int max_redirects; |
|
b3afec292014
New features: http version switching and limits for redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33443
diff
changeset
|
86 | 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
|
87 | guint max_length; |
|
33427
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
88 | }; |
|
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
89 | |
|
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
90 | struct _PurpleHttpConnection |
|
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 | PurpleConnection *gc; |
|
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
93 | PurpleHttpCallback callback; |
|
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
94 | gpointer user_data; |
|
33468
b057fee9d11a
HTTP progress watcher support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33466
diff
changeset
|
95 | 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
|
96 | gboolean is_keepalive; |
|
34263
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
97 | gboolean is_cancelling; |
|
33427
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
98 | |
|
33429
1ce1faf4e675
Extend URL parsing
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33427
diff
changeset
|
99 | PurpleHttpURL *url; |
|
1ce1faf4e675
Extend URL parsing
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33427
diff
changeset
|
100 | PurpleHttpRequest *request; |
|
33427
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
101 | PurpleHttpResponse *response; |
|
33430
013c5aebb665
Let's connect
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33429
diff
changeset
|
102 | |
|
34263
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
103 | 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
|
104 | 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
|
105 | PurpleHttpSocket *socket; |
|
33431
704de181d1d2
Let's request
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33430
diff
changeset
|
106 | GString *request_header; |
|
34305
5804117fb298
Fix the rest of libpurple warnings about -Wsign-compare
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34295
diff
changeset
|
107 | guint request_header_written, request_contents_written; |
|
33432
9c4acb75b2e6
Let's parse response headers
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33431
diff
changeset
|
108 | gboolean main_header_got, headers_got; |
|
9c4acb75b2e6
Let's parse response headers
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33431
diff
changeset
|
109 | 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
|
110 | PurpleHttpGzStream *gz_stream; |
|
33433
fb7ac52ed7df
Let's get response contents
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33432
diff
changeset
|
111 | |
|
33466
918507303f45
HTTP API: PurpleHttpContentReader support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33464
diff
changeset
|
112 | GString *contents_reader_buffer; |
|
918507303f45
HTTP API: PurpleHttpContentReader support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33464
diff
changeset
|
113 | gboolean contents_reader_requested; |
|
918507303f45
HTTP API: PurpleHttpContentReader support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33464
diff
changeset
|
114 | |
|
33444
b3afec292014
New features: http version switching and limits for redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33443
diff
changeset
|
115 | int redirects_count; |
|
b3afec292014
New features: http version switching and limits for redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33443
diff
changeset
|
116 | |
|
34305
5804117fb298
Fix the rest of libpurple warnings about -Wsign-compare
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34295
diff
changeset
|
117 | int length_expected; |
|
5804117fb298
Fix the rest of libpurple warnings about -Wsign-compare
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34295
diff
changeset
|
118 | guint length_got, length_got_decompressed; |
|
33434
ec4f343af107
Chunked file transfers support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33433
diff
changeset
|
119 | |
|
ec4f343af107
Chunked file transfers support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33433
diff
changeset
|
120 | gboolean is_chunked, in_chunk, chunks_done; |
|
ec4f343af107
Chunked file transfers support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33433
diff
changeset
|
121 | 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
|
122 | |
|
4d41b1f7b95f
Cancelling all HTTP connections on account disconnect or app shutdown
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33447
diff
changeset
|
123 | GList *link_global, *link_gc; |
|
33450
4042907bcdf1
Timeout support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33448
diff
changeset
|
124 | |
|
4042907bcdf1
Timeout support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33448
diff
changeset
|
125 | guint timeout_handle; |
|
33468
b057fee9d11a
HTTP progress watcher support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33466
diff
changeset
|
126 | |
|
b057fee9d11a
HTTP progress watcher support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33466
diff
changeset
|
127 | PurpleHttpProgressWatcher watcher; |
|
b057fee9d11a
HTTP progress watcher support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33466
diff
changeset
|
128 | gpointer watcher_user_data; |
|
b057fee9d11a
HTTP progress watcher support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33466
diff
changeset
|
129 | guint watcher_interval_threshold; |
|
b057fee9d11a
HTTP progress watcher support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33466
diff
changeset
|
130 | 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
|
131 | guint watcher_delayed_handle; |
|
33427
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
132 | }; |
|
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
133 | |
|
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
134 | struct _PurpleHttpResponse |
|
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 | int code; |
|
33430
013c5aebb665
Let's connect
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33429
diff
changeset
|
137 | gchar *error; |
|
33427
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
138 | |
|
33433
fb7ac52ed7df
Let's get response contents
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33432
diff
changeset
|
139 | GString *contents; |
|
33432
9c4acb75b2e6
Let's parse response headers
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33431
diff
changeset
|
140 | PurpleHttpHeaders *headers; |
|
33427
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
141 | }; |
|
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
142 | |
|
33429
1ce1faf4e675
Extend URL parsing
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33427
diff
changeset
|
143 | struct _PurpleHttpURL |
|
1ce1faf4e675
Extend URL parsing
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33427
diff
changeset
|
144 | { |
|
1ce1faf4e675
Extend URL parsing
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33427
diff
changeset
|
145 | gchar *protocol; |
|
34219
eee308def583
HTTP: get rid of purple_url_parse
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34218
diff
changeset
|
146 | gchar *username; |
|
33439
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
147 | gchar *password; |
|
33429
1ce1faf4e675
Extend URL parsing
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33427
diff
changeset
|
148 | gchar *host; |
|
1ce1faf4e675
Extend URL parsing
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33427
diff
changeset
|
149 | int port; |
|
1ce1faf4e675
Extend URL parsing
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33427
diff
changeset
|
150 | gchar *path; |
|
33439
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
151 | gchar *fragment; |
|
33429
1ce1faf4e675
Extend URL parsing
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33427
diff
changeset
|
152 | }; |
|
1ce1faf4e675
Extend URL parsing
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33427
diff
changeset
|
153 | |
|
33432
9c4acb75b2e6
Let's parse response headers
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33431
diff
changeset
|
154 | struct _PurpleHttpHeaders |
|
9c4acb75b2e6
Let's parse response headers
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33431
diff
changeset
|
155 | { |
|
9c4acb75b2e6
Let's parse response headers
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33431
diff
changeset
|
156 | GList *list; |
|
9c4acb75b2e6
Let's parse response headers
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33431
diff
changeset
|
157 | GHashTable *by_name; |
|
9c4acb75b2e6
Let's parse response headers
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33431
diff
changeset
|
158 | }; |
|
9c4acb75b2e6
Let's parse response headers
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33431
diff
changeset
|
159 | |
|
33459
722a6d753cb2
Better cookies, better chunked transfer support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33458
diff
changeset
|
160 | typedef struct |
|
722a6d753cb2
Better cookies, better chunked transfer support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33458
diff
changeset
|
161 | { |
|
722a6d753cb2
Better cookies, better chunked transfer support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33458
diff
changeset
|
162 | time_t expires; |
|
722a6d753cb2
Better cookies, better chunked transfer support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33458
diff
changeset
|
163 | gchar *value; |
|
722a6d753cb2
Better cookies, better chunked transfer support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33458
diff
changeset
|
164 | } PurpleHttpCookie; |
|
722a6d753cb2
Better cookies, better chunked transfer support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33458
diff
changeset
|
165 | |
|
33456
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
166 | struct _PurpleHttpCookieJar |
|
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
167 | { |
|
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
168 | int ref_count; |
|
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 | GHashTable *tab; |
|
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 | |
|
34263
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
173 | struct _PurpleHttpKeepaliveRequest |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
174 | { |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
175 | PurpleConnection *gc; |
|
34316
2a3a587f5403
HTTP: make use of PurpleSocket
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
34314
diff
changeset
|
176 | PurpleSocketConnectCb cb; |
|
34263
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
177 | gpointer user_data; |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
178 | |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
179 | PurpleHttpKeepaliveHost *host; |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
180 | PurpleHttpSocket *hs; |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
181 | }; |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
182 | |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
183 | struct _PurpleHttpKeepaliveHost |
|
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 | PurpleHttpKeepalivePool *pool; |
|
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 | gchar *host; |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
188 | int port; |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
189 | gboolean is_ssl; |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
190 | |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
191 | GSList *sockets; /* list of PurpleHttpSocket */ |
|
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 *queue; /* list of PurpleHttpKeepaliveRequest */ |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
194 | guint process_queue_timeout; |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
195 | }; |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
196 | |
|
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
|
197 | 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
|
198 | { |
|
34263
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
199 | gboolean is_destroying; |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
200 | |
|
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
|
201 | int ref_count; |
|
34260
7a55eaa31da6
HTTP: implement keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34257
diff
changeset
|
202 | |
|
34263
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
203 | guint limit_per_host; |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
204 | |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
205 | /* key: purple_http_socket_hash, value: PurpleHttpKeepaliveHost */ |
|
34260
7a55eaa31da6
HTTP: implement keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34257
diff
changeset
|
206 | 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
|
207 | }; |
|
935120490eb2
HTTP: isolate socket-related code in http module; initial implementation for keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34234
diff
changeset
|
208 | |
|
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
|
209 | 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
|
210 | { |
|
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 | 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
|
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 | 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
|
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 | |
|
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
|
216 | 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
|
217 | { |
|
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 | 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
|
219 | 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
|
220 | 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
|
221 | 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
|
222 | 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
|
223 | }; |
|
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 | |
| 33462 | 225 | static time_t purple_http_rfc1123_to_time(const gchar *str); |
| 226 | ||
|
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
|
227 | 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
|
228 | 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
|
229 | |
|
33429
1ce1faf4e675
Extend URL parsing
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33427
diff
changeset
|
230 | 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
|
231 | PurpleHttpRequest *request, PurpleConnection *gc); |
|
33427
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
232 | static void purple_http_connection_terminate(PurpleHttpConnection *hc); |
|
33468
b057fee9d11a
HTTP progress watcher support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33466
diff
changeset
|
233 | 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
|
234 | static void |
|
7a55eaa31da6
HTTP: implement keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34257
diff
changeset
|
235 | 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
|
236 | |
|
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
237 | 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
|
238 | 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
|
239 | |
|
33456
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
240 | static void purple_http_cookie_jar_parse(PurpleHttpCookieJar *cookie_jar, |
|
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
241 | GList *values); |
|
33458
59b3364f690e
Sending cookies
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33457
diff
changeset
|
242 | 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
|
243 | gchar * purple_http_cookie_jar_dump(PurpleHttpCookieJar *cjar); |
|
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
244 | |
|
34263
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
245 | static PurpleHttpKeepaliveRequest * |
|
34260
7a55eaa31da6
HTTP: implement keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34257
diff
changeset
|
246 | purple_http_keepalive_pool_request(PurpleHttpKeepalivePool *pool, |
|
7a55eaa31da6
HTTP: implement keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34257
diff
changeset
|
247 | 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
|
248 | PurpleSocketConnectCb cb, gpointer user_data); |
|
34260
7a55eaa31da6
HTTP: implement keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34257
diff
changeset
|
249 | static void |
|
34263
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
250 | 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
|
251 | static void |
|
34260
7a55eaa31da6
HTTP: implement keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34257
diff
changeset
|
252 | 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
|
253 | |
|
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
|
254 | 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
|
255 | 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
|
256 | 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
|
257 | |
|
33460
c37dd51516aa
Deleting (or expiring) a cookie
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33459
diff
changeset
|
258 | 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
|
259 | *purple_http_re_rfc1123; |
|
33432
9c4acb75b2e6
Let's parse response headers
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33431
diff
changeset
|
260 | |
|
35462
901dfa763f15
Fix some gtk-doc warnings till proxy.c
Ankit Vani <a@nevitus.org>
parents:
35454
diff
changeset
|
261 | /* |
|
33448
4d41b1f7b95f
Cancelling all HTTP connections on account disconnect or app shutdown
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33447
diff
changeset
|
262 | * 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
|
263 | */ |
|
4d41b1f7b95f
Cancelling all HTTP connections on account disconnect or app shutdown
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33447
diff
changeset
|
264 | 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
|
265 | |
|
35462
901dfa763f15
Fix some gtk-doc warnings till proxy.c
Ankit Vani <a@nevitus.org>
parents:
35454
diff
changeset
|
266 | /* |
|
33448
4d41b1f7b95f
Cancelling all HTTP connections on account disconnect or app shutdown
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33447
diff
changeset
|
267 | * 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
|
268 | * 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
|
269 | */ |
|
4d41b1f7b95f
Cancelling all HTTP connections on account disconnect or app shutdown
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33447
diff
changeset
|
270 | 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
|
271 | |
|
35462
901dfa763f15
Fix some gtk-doc warnings till proxy.c
Ankit Vani <a@nevitus.org>
parents:
35454
diff
changeset
|
272 | /* |
|
34262
3b8ce83bac96
HTTP: get rid of one (of two) msn's own http implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34261
diff
changeset
|
273 | * 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
|
274 | * 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
|
275 | */ |
|
3b8ce83bac96
HTTP: get rid of one (of two) msn's own http implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34261
diff
changeset
|
276 | 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
|
277 | |
|
35462
901dfa763f15
Fix some gtk-doc warnings till proxy.c
Ankit Vani <a@nevitus.org>
parents:
35454
diff
changeset
|
278 | /* |
|
33448
4d41b1f7b95f
Cancelling all HTTP connections on account disconnect or app shutdown
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33447
diff
changeset
|
279 | * 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
|
280 | * 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
|
281 | */ |
|
4d41b1f7b95f
Cancelling all HTTP connections on account disconnect or app shutdown
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33447
diff
changeset
|
282 | 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
|
283 | |
|
33460
c37dd51516aa
Deleting (or expiring) a cookie
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33459
diff
changeset
|
284 | /*** Helper functions *********************************************************/ |
|
c37dd51516aa
Deleting (or expiring) a cookie
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33459
diff
changeset
|
285 | |
|
c37dd51516aa
Deleting (or expiring) a cookie
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33459
diff
changeset
|
286 | 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
|
287 | { |
|
35362
a6223370667b
Style: fix braces for http, keyring
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35352
diff
changeset
|
288 | static const gchar *months[13] = { |
|
a6223370667b
Style: fix braces for http, keyring
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35352
diff
changeset
|
289 | "jan", "feb", "mar", "apr", "may", "jun", |
|
a6223370667b
Style: fix braces for http, keyring
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35352
diff
changeset
|
290 | "jul", "aug", "sep", "oct", "nov", "dec", NULL |
|
a6223370667b
Style: fix braces for http, keyring
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35352
diff
changeset
|
291 | }; |
|
33460
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 | |
|
c37dd51516aa
Deleting (or expiring) a cookie
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33459
diff
changeset
|
306 | 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
|
307 | 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
|
308 | 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
|
309 | 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
|
310 | |
|
35319
aa0328600eb6
HTTP: fix use-after-free. Fixes #15905
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35156
diff
changeset
|
311 | g_match_info_free(match_info); |
|
aa0328600eb6
HTTP: fix use-after-free. Fixes #15905
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35156
diff
changeset
|
312 | |
|
33460
c37dd51516aa
Deleting (or expiring) a cookie
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33459
diff
changeset
|
313 | month = 0; |
|
35362
a6223370667b
Style: fix braces for http, keyring
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35352
diff
changeset
|
314 | while (months[month] != NULL) { |
|
33460
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 | |
|
35349
e41c41659c26
HTTP: fix some code style errors
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35319
diff
changeset
|
321 | iso_date = g_strdup_printf("%s-%02d-%sT%s+00:00", |
|
33460
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); |
|
35362
a6223370667b
Style: fix braces for http, keyring
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35352
diff
changeset
|
583 | while (it) { |
|
33447
b890f231e15f
Request headers support, wrapping new API with legacy purple_util_fetch_url
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33446
diff
changeset
|
584 | 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
|
585 | 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
|
586 | 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
|
587 | 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
|
588 | continue; |
|
b890f231e15f
Request headers support, wrapping new API with legacy purple_util_fetch_url
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33446
diff
changeset
|
589 | |
|
b890f231e15f
Request headers support, wrapping new API with legacy purple_util_fetch_url
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33446
diff
changeset
|
590 | 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
|
591 | 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
|
592 | } |
|
33432
9c4acb75b2e6
Let's parse response headers
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33431
diff
changeset
|
593 | } |
|
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 | 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
|
596 | { |
|
35156
1bc10c44beef
HTTP: fix some clang warnings
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
34516
diff
changeset
|
597 | g_return_val_if_fail(hdrs != NULL, NULL); |
|
1bc10c44beef
HTTP: fix some clang warnings
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
34516
diff
changeset
|
598 | |
|
33432
9c4acb75b2e6
Let's parse response headers
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33431
diff
changeset
|
599 | return hdrs->list; |
|
9c4acb75b2e6
Let's parse response headers
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33431
diff
changeset
|
600 | } |
|
9c4acb75b2e6
Let's parse response headers
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33431
diff
changeset
|
601 | |
|
33456
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
602 | /* return const */ |
|
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
603 | 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
|
604 | PurpleHttpHeaders *hdrs, const gchar *key) |
|
33433
fb7ac52ed7df
Let's get response contents
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33432
diff
changeset
|
605 | { |
|
fb7ac52ed7df
Let's get response contents
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33432
diff
changeset
|
606 | GList *values; |
|
33434
ec4f343af107
Chunked file transfers support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33433
diff
changeset
|
607 | gchar *key_low; |
|
33433
fb7ac52ed7df
Let's get response contents
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33432
diff
changeset
|
608 | |
|
fb7ac52ed7df
Let's get response contents
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33432
diff
changeset
|
609 | g_return_val_if_fail(hdrs != NULL, NULL); |
|
fb7ac52ed7df
Let's get response contents
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33432
diff
changeset
|
610 | g_return_val_if_fail(key != NULL, NULL); |
|
fb7ac52ed7df
Let's get response contents
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33432
diff
changeset
|
611 | |
|
33434
ec4f343af107
Chunked file transfers support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33433
diff
changeset
|
612 | key_low = g_ascii_strdown(key, -1); |
|
ec4f343af107
Chunked file transfers support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33433
diff
changeset
|
613 | 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
|
614 | g_free(key_low); |
|
33451
27d0e5dbc2a1
Implement missing getters/setters and corresponding features
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33450
diff
changeset
|
615 | |
|
27d0e5dbc2a1
Implement missing getters/setters and corresponding features
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33450
diff
changeset
|
616 | return values; |
|
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 | |
|
27d0e5dbc2a1
Implement missing getters/setters and corresponding features
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33450
diff
changeset
|
619 | 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
|
620 | const gchar *key) |
|
27d0e5dbc2a1
Implement missing getters/setters and corresponding features
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33450
diff
changeset
|
621 | { |
|
27d0e5dbc2a1
Implement missing getters/setters and corresponding features
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33450
diff
changeset
|
622 | 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
|
623 | |
|
33433
fb7ac52ed7df
Let's get response contents
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33432
diff
changeset
|
624 | if (!values) |
|
fb7ac52ed7df
Let's get response contents
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33432
diff
changeset
|
625 | return NULL; |
|
fb7ac52ed7df
Let's get response contents
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33432
diff
changeset
|
626 | |
|
fb7ac52ed7df
Let's get response contents
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33432
diff
changeset
|
627 | return values->data; |
|
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 | |
|
fb7ac52ed7df
Let's get response contents
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33432
diff
changeset
|
630 | 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
|
631 | const gchar *key, int *dst) |
|
fb7ac52ed7df
Let's get response contents
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33432
diff
changeset
|
632 | { |
|
fb7ac52ed7df
Let's get response contents
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33432
diff
changeset
|
633 | int val; |
|
fb7ac52ed7df
Let's get response contents
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33432
diff
changeset
|
634 | const gchar *str; |
|
fb7ac52ed7df
Let's get response contents
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33432
diff
changeset
|
635 | |
|
fb7ac52ed7df
Let's get response contents
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33432
diff
changeset
|
636 | str = purple_http_headers_get(hdrs, key); |
|
fb7ac52ed7df
Let's get response contents
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33432
diff
changeset
|
637 | if (!str) |
|
fb7ac52ed7df
Let's get response contents
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33432
diff
changeset
|
638 | return FALSE; |
|
fb7ac52ed7df
Let's get response contents
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33432
diff
changeset
|
639 | |
|
fb7ac52ed7df
Let's get response contents
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33432
diff
changeset
|
640 | if (1 != sscanf(str, "%d", &val)) |
|
fb7ac52ed7df
Let's get response contents
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33432
diff
changeset
|
641 | return FALSE; |
|
fb7ac52ed7df
Let's get response contents
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33432
diff
changeset
|
642 | |
|
fb7ac52ed7df
Let's get response contents
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33432
diff
changeset
|
643 | *dst = val; |
|
fb7ac52ed7df
Let's get response contents
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33432
diff
changeset
|
644 | return TRUE; |
|
fb7ac52ed7df
Let's get response contents
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33432
diff
changeset
|
645 | } |
|
fb7ac52ed7df
Let's get response contents
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33432
diff
changeset
|
646 | |
|
33434
ec4f343af107
Chunked file transfers support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33433
diff
changeset
|
647 | static gboolean purple_http_headers_match(PurpleHttpHeaders *hdrs, |
|
ec4f343af107
Chunked file transfers support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33433
diff
changeset
|
648 | const gchar *key, const gchar *value) |
|
ec4f343af107
Chunked file transfers support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33433
diff
changeset
|
649 | { |
|
ec4f343af107
Chunked file transfers support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33433
diff
changeset
|
650 | const gchar *str; |
|
ec4f343af107
Chunked file transfers support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33433
diff
changeset
|
651 | |
|
ec4f343af107
Chunked file transfers support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33433
diff
changeset
|
652 | str = purple_http_headers_get(hdrs, key); |
|
ec4f343af107
Chunked file transfers support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33433
diff
changeset
|
653 | if (str == NULL || value == NULL) |
|
ec4f343af107
Chunked file transfers support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33433
diff
changeset
|
654 | return str == value; |
|
ec4f343af107
Chunked file transfers support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33433
diff
changeset
|
655 | |
|
ec4f343af107
Chunked file transfers support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33433
diff
changeset
|
656 | return (g_ascii_strcasecmp(str, value) == 0); |
|
ec4f343af107
Chunked file transfers support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33433
diff
changeset
|
657 | } |
|
ec4f343af107
Chunked file transfers support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33433
diff
changeset
|
658 | |
|
33432
9c4acb75b2e6
Let's parse response headers
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33431
diff
changeset
|
659 | static gchar * purple_http_headers_dump(PurpleHttpHeaders *hdrs) |
|
9c4acb75b2e6
Let's parse response headers
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33431
diff
changeset
|
660 | { |
|
9c4acb75b2e6
Let's parse response headers
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33431
diff
changeset
|
661 | const GList *hdr; |
|
9c4acb75b2e6
Let's parse response headers
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33431
diff
changeset
|
662 | |
|
9c4acb75b2e6
Let's parse response headers
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33431
diff
changeset
|
663 | GString *s = g_string_new(""); |
| 35352 | 664 | |
|
33432
9c4acb75b2e6
Let's parse response headers
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33431
diff
changeset
|
665 | hdr = purple_http_headers_get_all(hdrs); |
|
9c4acb75b2e6
Let's parse response headers
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33431
diff
changeset
|
666 | while (hdr) { |
|
9c4acb75b2e6
Let's parse response headers
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33431
diff
changeset
|
667 | PurpleKeyValuePair *kvp = hdr->data; |
|
9c4acb75b2e6
Let's parse response headers
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33431
diff
changeset
|
668 | hdr = g_list_next(hdr); |
|
9c4acb75b2e6
Let's parse response headers
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33431
diff
changeset
|
669 | |
|
9c4acb75b2e6
Let's parse response headers
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33431
diff
changeset
|
670 | 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
|
671 | (gchar*)kvp->value, hdr ? "\n" : ""); |
|
9c4acb75b2e6
Let's parse response headers
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33431
diff
changeset
|
672 | } |
| 35352 | 673 | |
|
33432
9c4acb75b2e6
Let's parse response headers
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33431
diff
changeset
|
674 | return g_string_free(s, FALSE); |
|
9c4acb75b2e6
Let's parse response headers
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33431
diff
changeset
|
675 | } |
|
33429
1ce1faf4e675
Extend URL parsing
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33427
diff
changeset
|
676 | |
|
33430
013c5aebb665
Let's connect
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33429
diff
changeset
|
677 | /*** HTTP protocol backend ****************************************************/ |
|
013c5aebb665
Let's connect
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33429
diff
changeset
|
678 | |
|
34260
7a55eaa31da6
HTTP: implement keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34257
diff
changeset
|
679 | static void _purple_http_disconnect(PurpleHttpConnection *hc, |
|
7a55eaa31da6
HTTP: implement keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34257
diff
changeset
|
680 | gboolean is_graceful); |
|
33430
013c5aebb665
Let's connect
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33429
diff
changeset
|
681 | |
|
33431
704de181d1d2
Let's request
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33430
diff
changeset
|
682 | 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
|
683 | 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
|
684 | 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
|
685 | PurpleInputCondition cond); |
|
33430
013c5aebb665
Let's connect
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33429
diff
changeset
|
686 | 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
|
687 | |
|
013c5aebb665
Let's connect
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33429
diff
changeset
|
688 | /* closes current connection (if exists), estabilishes one and proceeds with |
|
013c5aebb665
Let's connect
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33429
diff
changeset
|
689 | * request */ |
|
013c5aebb665
Let's connect
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33429
diff
changeset
|
690 | static gboolean _purple_http_reconnect(PurpleHttpConnection *hc); |
|
013c5aebb665
Let's connect
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33429
diff
changeset
|
691 | |
|
013c5aebb665
Let's connect
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33429
diff
changeset
|
692 | static void _purple_http_error(PurpleHttpConnection *hc, const char *format, |
|
013c5aebb665
Let's connect
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33429
diff
changeset
|
693 | ...) G_GNUC_PRINTF(2, 3); |
|
013c5aebb665
Let's connect
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33429
diff
changeset
|
694 | |
|
013c5aebb665
Let's connect
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33429
diff
changeset
|
695 | static void _purple_http_error(PurpleHttpConnection *hc, const char *format, |
|
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 | { |
|
013c5aebb665
Let's connect
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33429
diff
changeset
|
698 | va_list args; |
|
013c5aebb665
Let's connect
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33429
diff
changeset
|
699 | |
|
013c5aebb665
Let's connect
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33429
diff
changeset
|
700 | va_start(args, format); |
|
013c5aebb665
Let's connect
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33429
diff
changeset
|
701 | hc->response->error = g_strdup_vprintf(format, args); |
|
013c5aebb665
Let's connect
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33429
diff
changeset
|
702 | va_end(args); |
|
013c5aebb665
Let's connect
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33429
diff
changeset
|
703 | |
|
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
|
704 | 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
|
705 | 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
|
706 | |
|
33430
013c5aebb665
Let's connect
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33429
diff
changeset
|
707 | purple_http_conn_cancel(hc); |
|
013c5aebb665
Let's connect
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33429
diff
changeset
|
708 | } |
|
013c5aebb665
Let's connect
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33429
diff
changeset
|
709 | |
|
33431
704de181d1d2
Let's request
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33430
diff
changeset
|
710 | static void _purple_http_gen_headers(PurpleHttpConnection *hc) |
|
704de181d1d2
Let's request
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33430
diff
changeset
|
711 | { |
|
704de181d1d2
Let's request
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33430
diff
changeset
|
712 | GString *h; |
|
704de181d1d2
Let's request
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33430
diff
changeset
|
713 | 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
|
714 | const GList *hdr; |
|
33451
27d0e5dbc2a1
Implement missing getters/setters and corresponding features
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33450
diff
changeset
|
715 | PurpleHttpRequest *req; |
|
27d0e5dbc2a1
Implement missing getters/setters and corresponding features
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33450
diff
changeset
|
716 | PurpleHttpHeaders *hdrs; |
|
33453
3cb58ea9667c
HTTP Proxy support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33452
diff
changeset
|
717 | gchar *request_url, *tmp_url = NULL; |
|
3cb58ea9667c
HTTP Proxy support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33452
diff
changeset
|
718 | |
|
3cb58ea9667c
HTTP Proxy support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33452
diff
changeset
|
719 | PurpleProxyInfo *proxy; |
|
3cb58ea9667c
HTTP Proxy support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33452
diff
changeset
|
720 | gboolean proxy_http = FALSE; |
|
3cb58ea9667c
HTTP Proxy support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33452
diff
changeset
|
721 | const gchar *proxy_username, *proxy_password; |
|
33431
704de181d1d2
Let's request
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33430
diff
changeset
|
722 | |
|
704de181d1d2
Let's request
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33430
diff
changeset
|
723 | g_return_if_fail(hc != NULL); |
|
704de181d1d2
Let's request
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33430
diff
changeset
|
724 | |
|
704de181d1d2
Let's request
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33430
diff
changeset
|
725 | if (hc->request_header != NULL) |
|
704de181d1d2
Let's request
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33430
diff
changeset
|
726 | return; |
|
704de181d1d2
Let's request
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33430
diff
changeset
|
727 | |
|
33451
27d0e5dbc2a1
Implement missing getters/setters and corresponding features
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33450
diff
changeset
|
728 | req = hc->request; |
|
33431
704de181d1d2
Let's request
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33430
diff
changeset
|
729 | url = hc->url; |
|
33451
27d0e5dbc2a1
Implement missing getters/setters and corresponding features
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33450
diff
changeset
|
730 | hdrs = req->headers; |
|
33431
704de181d1d2
Let's request
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33430
diff
changeset
|
731 | proxy = purple_proxy_get_setup(hc->gc ? |
|
704de181d1d2
Let's request
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33430
diff
changeset
|
732 | purple_connection_get_account(hc->gc) : NULL); |
|
704de181d1d2
Let's request
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33430
diff
changeset
|
733 | |
|
35378
5d9e2581005b
gtk-doc prep: *_get_type() functions are hidden as standard GType-returning funcs, so rename them.
Ankit Vani <a@nevitus.org>
parents:
35362
diff
changeset
|
734 | proxy_http = (purple_proxy_info_get_proxy_type(proxy) == PURPLE_PROXY_HTTP || |
|
5d9e2581005b
gtk-doc prep: *_get_type() functions are hidden as standard GType-returning funcs, so rename them.
Ankit Vani <a@nevitus.org>
parents:
35362
diff
changeset
|
735 | purple_proxy_info_get_proxy_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
|
736 | /* 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
|
737 | 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
|
738 | proxy_http = FALSE; |
|
33453
3cb58ea9667c
HTTP Proxy support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33452
diff
changeset
|
739 | |
|
33431
704de181d1d2
Let's request
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33430
diff
changeset
|
740 | hc->request_header = h = g_string_new(""); |
|
704de181d1d2
Let's request
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33430
diff
changeset
|
741 | hc->request_header_written = 0; |
|
33457
81f92a310aff
Writing request contents
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33456
diff
changeset
|
742 | hc->request_contents_written = 0; |
|
33431
704de181d1d2
Let's request
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33430
diff
changeset
|
743 | |
|
33453
3cb58ea9667c
HTTP Proxy support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33452
diff
changeset
|
744 | if (proxy_http) |
|
3cb58ea9667c
HTTP Proxy support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33452
diff
changeset
|
745 | request_url = tmp_url = purple_http_url_print(url); |
|
3cb58ea9667c
HTTP Proxy support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33452
diff
changeset
|
746 | else |
|
3cb58ea9667c
HTTP Proxy support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33452
diff
changeset
|
747 | request_url = url->path; |
|
3cb58ea9667c
HTTP Proxy support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33452
diff
changeset
|
748 | |
|
33451
27d0e5dbc2a1
Implement missing getters/setters and corresponding features
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33450
diff
changeset
|
749 | 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
|
750 | req->method ? req->method : "GET", |
|
33453
3cb58ea9667c
HTTP Proxy support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33452
diff
changeset
|
751 | request_url, |
|
33451
27d0e5dbc2a1
Implement missing getters/setters and corresponding features
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33450
diff
changeset
|
752 | 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
|
753 | |
|
33453
3cb58ea9667c
HTTP Proxy support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33452
diff
changeset
|
754 | if (tmp_url) |
|
3cb58ea9667c
HTTP Proxy support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33452
diff
changeset
|
755 | g_free(tmp_url); |
|
3cb58ea9667c
HTTP Proxy support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33452
diff
changeset
|
756 | |
|
33451
27d0e5dbc2a1
Implement missing getters/setters and corresponding features
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33450
diff
changeset
|
757 | 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
|
758 | 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
|
759 | 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
|
760 | 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
|
761 | 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
|
762 | "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
|
763 | } |
|
33451
27d0e5dbc2a1
Implement missing getters/setters and corresponding features
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33450
diff
changeset
|
764 | if (!purple_http_headers_get(hdrs, "accept")) |
|
33453
3cb58ea9667c
HTTP Proxy support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33452
diff
changeset
|
765 | 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
|
766 | 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
|
767 | 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
|
768 | |
|
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
|
769 | 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
|
770 | 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
|
771 | 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
|
772 | { |
|
33457
81f92a310aff
Writing request contents
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33456
diff
changeset
|
773 | g_string_append_printf(h, "Content-Length: %u\r\n", |
|
81f92a310aff
Writing request contents
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33456
diff
changeset
|
774 | 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
|
775 | } |
|
33457
81f92a310aff
Writing request contents
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33456
diff
changeset
|
776 | |
|
33453
3cb58ea9667c
HTTP Proxy support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33452
diff
changeset
|
777 | 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
|
778 | 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
|
779 | |
|
3cb58ea9667c
HTTP Proxy support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33452
diff
changeset
|
780 | proxy_username = purple_proxy_info_get_username(proxy); |
|
3cb58ea9667c
HTTP Proxy support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33452
diff
changeset
|
781 | if (proxy_http && proxy_username != NULL && proxy_username[0] != '\0') { |
|
3cb58ea9667c
HTTP Proxy support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33452
diff
changeset
|
782 | gchar *proxy_auth, *ntlm_type1, *tmp; |
|
3cb58ea9667c
HTTP Proxy support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33452
diff
changeset
|
783 | int len; |
|
3cb58ea9667c
HTTP Proxy support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33452
diff
changeset
|
784 | |
|
3cb58ea9667c
HTTP Proxy support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33452
diff
changeset
|
785 | proxy_password = purple_proxy_info_get_password(proxy); |
|
3cb58ea9667c
HTTP Proxy support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33452
diff
changeset
|
786 | if (proxy_password == NULL) |
|
3cb58ea9667c
HTTP Proxy support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33452
diff
changeset
|
787 | proxy_password = ""; |
|
3cb58ea9667c
HTTP Proxy support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33452
diff
changeset
|
788 | |
|
3cb58ea9667c
HTTP Proxy support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33452
diff
changeset
|
789 | tmp = g_strdup_printf("%s:%s", proxy_username, proxy_password); |
|
3cb58ea9667c
HTTP Proxy support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33452
diff
changeset
|
790 | len = strlen(tmp); |
|
3cb58ea9667c
HTTP Proxy support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33452
diff
changeset
|
791 | proxy_auth = purple_base64_encode((const guchar *)tmp, len); |
|
3cb58ea9667c
HTTP Proxy support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33452
diff
changeset
|
792 | memset(tmp, 0, len); |
|
3cb58ea9667c
HTTP Proxy support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33452
diff
changeset
|
793 | g_free(tmp); |
|
3cb58ea9667c
HTTP Proxy support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33452
diff
changeset
|
794 | |
|
33469
6c2fa6d8037d
HTTP: simplify hostname getting
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33468
diff
changeset
|
795 | 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
|
796 | |
|
3cb58ea9667c
HTTP Proxy support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33452
diff
changeset
|
797 | 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
|
798 | proxy_auth); |
|
3cb58ea9667c
HTTP Proxy support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33452
diff
changeset
|
799 | 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
|
800 | 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
|
801 | 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
|
802 | |
|
3cb58ea9667c
HTTP Proxy support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33452
diff
changeset
|
803 | memset(proxy_auth, 0, strlen(proxy_auth)); |
|
3cb58ea9667c
HTTP Proxy support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33452
diff
changeset
|
804 | g_free(proxy_auth); |
|
3cb58ea9667c
HTTP Proxy support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33452
diff
changeset
|
805 | g_free(ntlm_type1); |
|
3cb58ea9667c
HTTP Proxy support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33452
diff
changeset
|
806 | } |
|
33431
704de181d1d2
Let's request
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33430
diff
changeset
|
807 | |
|
33451
27d0e5dbc2a1
Implement missing getters/setters and corresponding features
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33450
diff
changeset
|
808 | 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
|
809 | 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
|
810 | 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
|
811 | hdr = g_list_next(hdr); |
|
33431
704de181d1d2
Let's request
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33430
diff
changeset
|
812 | |
|
33447
b890f231e15f
Request headers support, wrapping new API with legacy purple_util_fetch_url
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33446
diff
changeset
|
813 | 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
|
814 | 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
|
815 | } |
|
33431
704de181d1d2
Let's request
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33430
diff
changeset
|
816 | |
|
33458
59b3364f690e
Sending cookies
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33457
diff
changeset
|
817 | if (!purple_http_cookie_jar_is_empty(req->cookie_jar)) { |
|
59b3364f690e
Sending cookies
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33457
diff
changeset
|
818 | gchar * cookies = purple_http_cookie_jar_gen(req->cookie_jar); |
|
59b3364f690e
Sending cookies
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33457
diff
changeset
|
819 | g_string_append_printf(h, "Cookie: %s\r\n", cookies); |
|
59b3364f690e
Sending cookies
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33457
diff
changeset
|
820 | g_free(cookies); |
|
59b3364f690e
Sending cookies
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33457
diff
changeset
|
821 | } |
|
33456
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
822 | |
|
33431
704de181d1d2
Let's request
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33430
diff
changeset
|
823 | g_string_append_printf(h, "\r\n"); |
|
704de181d1d2
Let's request
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33430
diff
changeset
|
824 | |
|
704de181d1d2
Let's request
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33430
diff
changeset
|
825 | if (purple_debug_is_unsafe() && purple_debug_is_verbose()) { |
|
704de181d1d2
Let's request
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33430
diff
changeset
|
826 | purple_debug_misc("http", "Generated request headers:\n%s", |
|
704de181d1d2
Let's request
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33430
diff
changeset
|
827 | h->str); |
|
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 | } |
|
704de181d1d2
Let's request
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33430
diff
changeset
|
830 | |
|
33433
fb7ac52ed7df
Let's get response contents
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33432
diff
changeset
|
831 | 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
|
832 | const gchar *buf, int len) |
|
9c4acb75b2e6
Let's parse response headers
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33431
diff
changeset
|
833 | { |
|
9c4acb75b2e6
Let's parse response headers
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33431
diff
changeset
|
834 | gchar *eol, *delim; |
|
9c4acb75b2e6
Let's parse response headers
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33431
diff
changeset
|
835 | |
|
33435
ab0560aa8ca4
Segfault shotgun debugging
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33434
diff
changeset
|
836 | if (hc->headers_got) { |
|
ab0560aa8ca4
Segfault shotgun debugging
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33434
diff
changeset
|
837 | purple_debug_error("http", "Headers already got\n"); |
|
ab0560aa8ca4
Segfault shotgun debugging
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33434
diff
changeset
|
838 | _purple_http_error(hc, _("Error parsing HTTP")); |
|
ab0560aa8ca4
Segfault shotgun debugging
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33434
diff
changeset
|
839 | return FALSE; |
|
ab0560aa8ca4
Segfault shotgun debugging
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33434
diff
changeset
|
840 | } |
|
ab0560aa8ca4
Segfault shotgun debugging
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33434
diff
changeset
|
841 | |
|
33443
ab563d4c927a
Don't eat resources with malicious http server
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33439
diff
changeset
|
842 | 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
|
843 | 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
|
844 | purple_debug_error("http", |
|
ab563d4c927a
Don't eat resources with malicious http server
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33439
diff
changeset
|
845 | "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
|
846 | _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
|
847 | return FALSE; |
|
ab563d4c927a
Don't eat resources with malicious http server
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33439
diff
changeset
|
848 | } |
|
ab563d4c927a
Don't eat resources with malicious http server
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33439
diff
changeset
|
849 | |
|
33432
9c4acb75b2e6
Let's parse response headers
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33431
diff
changeset
|
850 | while ((eol = strstr(hc->response_buffer->str, "\r\n")) |
|
35362
a6223370667b
Style: fix braces for http, keyring
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35352
diff
changeset
|
851 | != NULL) |
|
a6223370667b
Style: fix braces for http, keyring
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35352
diff
changeset
|
852 | { |
|
33432
9c4acb75b2e6
Let's parse response headers
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33431
diff
changeset
|
853 | gchar *hdrline = hc->response_buffer->str; |
|
9c4acb75b2e6
Let's parse response headers
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33431
diff
changeset
|
854 | int hdrline_len = eol - hdrline; |
|
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 | hdrline[hdrline_len] = '\0'; |
|
9c4acb75b2e6
Let's parse response headers
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33431
diff
changeset
|
857 | |
|
9c4acb75b2e6
Let's parse response headers
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33431
diff
changeset
|
858 | 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
|
859 | 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
|
860 | 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
|
861 | 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
|
862 | { |
|
34260
7a55eaa31da6
HTTP: implement keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34257
diff
changeset
|
863 | purple_debug_misc("http", "Got keep-" |
|
7a55eaa31da6
HTTP: implement keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34257
diff
changeset
|
864 | "alive terminator from previous" |
|
7a55eaa31da6
HTTP: implement keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34257
diff
changeset
|
865 | " 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
|
866 | } 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
|
867 | 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
|
868 | " 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
|
869 | "may be a HTTP server quirk\n"); |
|
34260
7a55eaa31da6
HTTP: implement keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34257
diff
changeset
|
870 | } |
|
7a55eaa31da6
HTTP: implement keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34257
diff
changeset
|
871 | } else /* hc->main_header_got */ { |
|
7a55eaa31da6
HTTP: implement keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34257
diff
changeset
|
872 | hc->headers_got = TRUE; |
|
7a55eaa31da6
HTTP: implement keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34257
diff
changeset
|
873 | if (purple_debug_is_verbose()) { |
|
7a55eaa31da6
HTTP: implement keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34257
diff
changeset
|
874 | purple_debug_misc("http", "Got headers " |
|
7a55eaa31da6
HTTP: implement keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34257
diff
changeset
|
875 | "end\n"); |
|
7a55eaa31da6
HTTP: implement keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34257
diff
changeset
|
876 | } |
|
33432
9c4acb75b2e6
Let's parse response headers
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33431
diff
changeset
|
877 | } |
|
9c4acb75b2e6
Let's parse response headers
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33431
diff
changeset
|
878 | } else if (!hc->main_header_got) { |
|
9c4acb75b2e6
Let's parse response headers
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33431
diff
changeset
|
879 | hc->main_header_got = TRUE; |
|
9c4acb75b2e6
Let's parse response headers
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33431
diff
changeset
|
880 | delim = strchr(hdrline, ' '); |
|
9c4acb75b2e6
Let's parse response headers
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33431
diff
changeset
|
881 | if (delim == NULL || 1 != sscanf(delim + 1, "%d", |
|
35362
a6223370667b
Style: fix braces for http, keyring
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35352
diff
changeset
|
882 | &hc->response->code)) |
|
a6223370667b
Style: fix braces for http, keyring
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35352
diff
changeset
|
883 | { |
|
33433
fb7ac52ed7df
Let's get response contents
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33432
diff
changeset
|
884 | purple_debug_warning("http", |
|
fb7ac52ed7df
Let's get response contents
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33432
diff
changeset
|
885 | "Invalid response code\n"); |
|
33432
9c4acb75b2e6
Let's parse response headers
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33431
diff
changeset
|
886 | _purple_http_error(hc, _("Error parsing HTTP")); |
|
33433
fb7ac52ed7df
Let's get response contents
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33432
diff
changeset
|
887 | return FALSE; |
|
33432
9c4acb75b2e6
Let's parse response headers
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33431
diff
changeset
|
888 | } |
|
33433
fb7ac52ed7df
Let's get response contents
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33432
diff
changeset
|
889 | if (purple_debug_is_verbose()) |
|
33453
3cb58ea9667c
HTTP Proxy support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33452
diff
changeset
|
890 | purple_debug_misc("http", |
|
3cb58ea9667c
HTTP Proxy support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33452
diff
changeset
|
891 | "Got main header with code %d\n", |
|
3cb58ea9667c
HTTP Proxy support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33452
diff
changeset
|
892 | hc->response->code); |
|
33432
9c4acb75b2e6
Let's parse response headers
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33431
diff
changeset
|
893 | } else { |
|
33433
fb7ac52ed7df
Let's get response contents
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33432
diff
changeset
|
894 | if (purple_debug_is_verbose() && |
|
fb7ac52ed7df
Let's get response contents
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33432
diff
changeset
|
895 | purple_debug_is_unsafe()) |
|
fb7ac52ed7df
Let's get response contents
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33432
diff
changeset
|
896 | purple_debug_misc("http", "Got header: %s\n", |
|
fb7ac52ed7df
Let's get response contents
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33432
diff
changeset
|
897 | hdrline); |
|
33432
9c4acb75b2e6
Let's parse response headers
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33431
diff
changeset
|
898 | delim = strchr(hdrline, ':'); |
|
9c4acb75b2e6
Let's parse response headers
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33431
diff
changeset
|
899 | if (delim == NULL || delim == hdrline) { |
|
33433
fb7ac52ed7df
Let's get response contents
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33432
diff
changeset
|
900 | purple_debug_warning("http", |
|
fb7ac52ed7df
Let's get response contents
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33432
diff
changeset
|
901 | "Bad header delimiter\n"); |
|
33432
9c4acb75b2e6
Let's parse response headers
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33431
diff
changeset
|
902 | _purple_http_error(hc, _("Error parsing HTTP")); |
|
33433
fb7ac52ed7df
Let's get response contents
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33432
diff
changeset
|
903 | return FALSE; |
|
33432
9c4acb75b2e6
Let's parse response headers
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33431
diff
changeset
|
904 | } |
|
9c4acb75b2e6
Let's parse response headers
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33431
diff
changeset
|
905 | *delim++ = '\0'; |
|
9c4acb75b2e6
Let's parse response headers
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33431
diff
changeset
|
906 | while (*delim == ' ') |
|
9c4acb75b2e6
Let's parse response headers
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33431
diff
changeset
|
907 | delim++; |
|
35349
e41c41659c26
HTTP: fix some code style errors
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35319
diff
changeset
|
908 | |
|
33432
9c4acb75b2e6
Let's parse response headers
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33431
diff
changeset
|
909 | 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
|
910 | } |
|
9c4acb75b2e6
Let's parse response headers
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33431
diff
changeset
|
911 | |
|
9c4acb75b2e6
Let's parse response headers
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33431
diff
changeset
|
912 | 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
|
913 | if (hc->headers_got) |
|
fb7ac52ed7df
Let's get response contents
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33432
diff
changeset
|
914 | break; |
|
33432
9c4acb75b2e6
Let's parse response headers
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33431
diff
changeset
|
915 | } |
|
33433
fb7ac52ed7df
Let's get response contents
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33432
diff
changeset
|
916 | return TRUE; |
|
fb7ac52ed7df
Let's get response contents
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33432
diff
changeset
|
917 | } |
|
fb7ac52ed7df
Let's get response contents
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33432
diff
changeset
|
918 | |
|
33517
ddd9e37c4b07
HTTP: PurpleHttpContentWriter support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33469
diff
changeset
|
919 | 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
|
920 | const gchar *buf, int len) |
|
ec4f343af107
Chunked file transfers support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33433
diff
changeset
|
921 | { |
|
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
|
922 | GString *decompressed = NULL; |
|
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 | 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
|
925 | 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
|
926 | { |
|
0cb189ba00f2
HTTP: refine content length calculation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34265
diff
changeset
|
927 | len = hc->length_expected - hc->length_got; |
|
0cb189ba00f2
HTTP: refine content length calculation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34265
diff
changeset
|
928 | } |
|
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
|
929 | |
|
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 | 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
|
931 | |
|
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 | 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
|
933 | 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
|
934 | 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
|
935 | _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
|
936 | _("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
|
937 | return FALSE; |
|
33446
95fda782966c
New feature: setting maximum length of response
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33445
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 | 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
|
940 | len = decompressed->len; |
|
33517
ddd9e37c4b07
HTTP: PurpleHttpContentWriter support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33469
diff
changeset
|
941 | } |
|
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
|
942 | |
|
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 | 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
|
944 | 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
|
945 | 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
|
946 | 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
|
947 | "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
|
948 | 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
|
949 | 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
|
950 | } |
|
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 | 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
|
952 | |
|
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
|
953 | 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
|
954 | 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
|
955 | g_string_free(decompressed, TRUE); |
|
33517
ddd9e37c4b07
HTTP: PurpleHttpContentWriter support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33469
diff
changeset
|
956 | 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
|
957 | } |
|
33517
ddd9e37c4b07
HTTP: PurpleHttpContentWriter support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33469
diff
changeset
|
958 | |
|
ddd9e37c4b07
HTTP: PurpleHttpContentWriter support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33469
diff
changeset
|
959 | if (hc->request->response_writer != NULL) { |
|
ddd9e37c4b07
HTTP: PurpleHttpContentWriter support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33469
diff
changeset
|
960 | gboolean succ; |
|
ddd9e37c4b07
HTTP: PurpleHttpContentWriter support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33469
diff
changeset
|
961 | 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
|
962 | 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
|
963 | hc->request->response_writer_data); |
|
33517
ddd9e37c4b07
HTTP: PurpleHttpContentWriter support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33469
diff
changeset
|
964 | 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
|
965 | 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
|
966 | g_string_free(decompressed, TRUE); |
|
33517
ddd9e37c4b07
HTTP: PurpleHttpContentWriter support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33469
diff
changeset
|
967 | purple_debug_error("http", |
|
ddd9e37c4b07
HTTP: PurpleHttpContentWriter support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33469
diff
changeset
|
968 | "Cannot write using callback\n"); |
|
ddd9e37c4b07
HTTP: PurpleHttpContentWriter support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33469
diff
changeset
|
969 | _purple_http_error(hc, |
|
ddd9e37c4b07
HTTP: PurpleHttpContentWriter support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33469
diff
changeset
|
970 | _("Error handling retrieved data")); |
|
ddd9e37c4b07
HTTP: PurpleHttpContentWriter support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33469
diff
changeset
|
971 | return FALSE; |
|
ddd9e37c4b07
HTTP: PurpleHttpContentWriter support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33469
diff
changeset
|
972 | } |
|
ddd9e37c4b07
HTTP: PurpleHttpContentWriter support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33469
diff
changeset
|
973 | } else { |
|
ddd9e37c4b07
HTTP: PurpleHttpContentWriter support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33469
diff
changeset
|
974 | if (hc->response->contents == NULL) |
|
ddd9e37c4b07
HTTP: PurpleHttpContentWriter support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33469
diff
changeset
|
975 | hc->response->contents = g_string_new(""); |
|
ddd9e37c4b07
HTTP: PurpleHttpContentWriter support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33469
diff
changeset
|
976 | 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
|
977 | } |
|
95fda782966c
New feature: setting maximum length of response
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33445
diff
changeset
|
978 | |
|
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
|
979 | 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
|
980 | 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
|
981 | |
|
33468
b057fee9d11a
HTTP progress watcher support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33466
diff
changeset
|
982 | purple_http_conn_notify_progress_watcher(hc); |
|
33517
ddd9e37c4b07
HTTP: PurpleHttpContentWriter support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33469
diff
changeset
|
983 | return TRUE; |
|
33434
ec4f343af107
Chunked file transfers support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33433
diff
changeset
|
984 | } |
|
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 | static gboolean _purple_http_recv_body_chunked(PurpleHttpConnection *hc, |
|
ec4f343af107
Chunked file transfers support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33433
diff
changeset
|
987 | const gchar *buf, int 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 | gchar *eol, *line; |
|
ec4f343af107
Chunked file transfers support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33433
diff
changeset
|
990 | int line_len; |
|
ec4f343af107
Chunked file transfers support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33433
diff
changeset
|
991 | |
|
ec4f343af107
Chunked file transfers support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33433
diff
changeset
|
992 | if (hc->chunks_done) |
|
ec4f343af107
Chunked file transfers support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33433
diff
changeset
|
993 | return FALSE; |
|
ec4f343af107
Chunked file transfers support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33433
diff
changeset
|
994 | if (!hc->response_buffer) |
|
ec4f343af107
Chunked file transfers support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33433
diff
changeset
|
995 | hc->response_buffer = g_string_new(""); |
|
33436
abec627c3a47
Segfault found, temporarily fixed
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33435
diff
changeset
|
996 | |
|
33443
ab563d4c927a
Don't eat resources with malicious http server
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33439
diff
changeset
|
997 | 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
|
998 | 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
|
999 | purple_debug_error("http", |
|
ab563d4c927a
Don't eat resources with malicious http server
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33439
diff
changeset
|
1000 | "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
|
1001 | _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
|
1002 | return FALSE; |
|
ab563d4c927a
Don't eat resources with malicious http server
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33439
diff
changeset
|
1003 | } |
|
ab563d4c927a
Don't eat resources with malicious http server
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33439
diff
changeset
|
1004 | |
|
33434
ec4f343af107
Chunked file transfers support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33433
diff
changeset
|
1005 | while (hc->response_buffer->len > 0) { |
|
ec4f343af107
Chunked file transfers support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33433
diff
changeset
|
1006 | if (hc->in_chunk) { |
|
ec4f343af107
Chunked file transfers support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33433
diff
changeset
|
1007 | int got_now = hc->response_buffer->len; |
|
ec4f343af107
Chunked file transfers support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33433
diff
changeset
|
1008 | if (hc->chunk_got + got_now > hc->chunk_length) |
|
ec4f343af107
Chunked file transfers support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33433
diff
changeset
|
1009 | got_now = hc->chunk_length - hc->chunk_got; |
|
ec4f343af107
Chunked file transfers support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33433
diff
changeset
|
1010 | hc->chunk_got += got_now; |
| 35352 | 1011 | |
|
33517
ddd9e37c4b07
HTTP: PurpleHttpContentWriter support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33469
diff
changeset
|
1012 | if (!_purple_http_recv_body_data(hc, |
|
ddd9e37c4b07
HTTP: PurpleHttpContentWriter support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33469
diff
changeset
|
1013 | hc->response_buffer->str, got_now)) |
|
ddd9e37c4b07
HTTP: PurpleHttpContentWriter support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33469
diff
changeset
|
1014 | return FALSE; |
|
33459
722a6d753cb2
Better cookies, better chunked transfer support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33458
diff
changeset
|
1015 | |
|
33434
ec4f343af107
Chunked file transfers support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33433
diff
changeset
|
1016 | g_string_erase(hc->response_buffer, 0, got_now); |
|
ec4f343af107
Chunked file transfers support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33433
diff
changeset
|
1017 | hc->in_chunk = (hc->chunk_got < hc->chunk_length); |
|
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 | continue; |
|
ec4f343af107
Chunked file transfers support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33433
diff
changeset
|
1020 | } |
|
ec4f343af107
Chunked file transfers support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33433
diff
changeset
|
1021 | |
|
ec4f343af107
Chunked file transfers support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33433
diff
changeset
|
1022 | line = hc->response_buffer->str; |
|
ec4f343af107
Chunked file transfers support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33433
diff
changeset
|
1023 | eol = strstr(line, "\r\n"); |
|
33459
722a6d753cb2
Better cookies, better chunked transfer support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33458
diff
changeset
|
1024 | if (eol == line) { |
|
722a6d753cb2
Better cookies, better chunked transfer support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33458
diff
changeset
|
1025 | 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
|
1026 | line = hc->response_buffer->str; |
|
722a6d753cb2
Better cookies, better chunked transfer support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33458
diff
changeset
|
1027 | eol = strstr(line, "\r\n"); |
|
722a6d753cb2
Better cookies, better chunked transfer support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33458
diff
changeset
|
1028 | } |
|
33434
ec4f343af107
Chunked file transfers support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33433
diff
changeset
|
1029 | if (eol == NULL) { |
|
ec4f343af107
Chunked file transfers support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33433
diff
changeset
|
1030 | /* waiting for more data (unlikely, but possible) */ |
|
ec4f343af107
Chunked file transfers support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33433
diff
changeset
|
1031 | if (hc->response_buffer->len > 20) { |
|
ec4f343af107
Chunked file transfers support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33433
diff
changeset
|
1032 | purple_debug_warning("http", "Chunk length not " |
|
ec4f343af107
Chunked file transfers support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33433
diff
changeset
|
1033 | "found (buffer too large)\n"); |
|
ec4f343af107
Chunked file transfers support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33433
diff
changeset
|
1034 | _purple_http_error(hc, _("Error parsing HTTP")); |
|
ec4f343af107
Chunked file transfers support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33433
diff
changeset
|
1035 | return FALSE; |
|
ec4f343af107
Chunked file transfers support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33433
diff
changeset
|
1036 | } |
|
ec4f343af107
Chunked file transfers support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33433
diff
changeset
|
1037 | return TRUE; |
|
ec4f343af107
Chunked file transfers support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33433
diff
changeset
|
1038 | } |
|
ec4f343af107
Chunked file transfers support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33433
diff
changeset
|
1039 | line_len = eol - line; |
|
ec4f343af107
Chunked file transfers support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33433
diff
changeset
|
1040 | |
|
ec4f343af107
Chunked file transfers support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33433
diff
changeset
|
1041 | if (1 != sscanf(line, "%x", &hc->chunk_length)) { |
|
33450
4042907bcdf1
Timeout support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33448
diff
changeset
|
1042 | if (purple_debug_is_unsafe()) |
|
4042907bcdf1
Timeout support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33448
diff
changeset
|
1043 | purple_debug_warning("http", |
|
4042907bcdf1
Timeout support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33448
diff
changeset
|
1044 | "Chunk length not found in [%s]\n", |
|
4042907bcdf1
Timeout support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33448
diff
changeset
|
1045 | line); |
|
4042907bcdf1
Timeout support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33448
diff
changeset
|
1046 | else |
|
4042907bcdf1
Timeout support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33448
diff
changeset
|
1047 | purple_debug_warning("http", |
|
4042907bcdf1
Timeout support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33448
diff
changeset
|
1048 | "Chunk length not found\n"); |
|
33434
ec4f343af107
Chunked file transfers support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33433
diff
changeset
|
1049 | _purple_http_error(hc, _("Error parsing HTTP")); |
|
ec4f343af107
Chunked file transfers support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33433
diff
changeset
|
1050 | return FALSE; |
|
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 | hc->chunk_got = 0; |
|
ec4f343af107
Chunked file transfers support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33433
diff
changeset
|
1053 | hc->in_chunk = TRUE; |
|
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 | if (purple_debug_is_verbose()) |
|
ec4f343af107
Chunked file transfers support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33433
diff
changeset
|
1056 | 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
|
1057 | |
|
ec4f343af107
Chunked file transfers support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33433
diff
changeset
|
1058 | 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
|
1059 | |
|
ec4f343af107
Chunked file transfers support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33433
diff
changeset
|
1060 | if (hc->chunk_length == 0) { |
|
ec4f343af107
Chunked file transfers support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33433
diff
changeset
|
1061 | hc->chunks_done = TRUE; |
|
ec4f343af107
Chunked file transfers support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33433
diff
changeset
|
1062 | hc->in_chunk = FALSE; |
|
ec4f343af107
Chunked file transfers support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33433
diff
changeset
|
1063 | return TRUE; |
|
ec4f343af107
Chunked file transfers support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33433
diff
changeset
|
1064 | } |
|
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 | return TRUE; |
|
ec4f343af107
Chunked file transfers support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33433
diff
changeset
|
1068 | } |
|
ec4f343af107
Chunked file transfers support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33433
diff
changeset
|
1069 | |
|
ec4f343af107
Chunked file transfers support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33433
diff
changeset
|
1070 | 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
|
1071 | const gchar *buf, int len) |
|
fb7ac52ed7df
Let's get response contents
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33432
diff
changeset
|
1072 | { |
|
33434
ec4f343af107
Chunked file transfers support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33433
diff
changeset
|
1073 | if (hc->is_chunked) |
|
ec4f343af107
Chunked file transfers support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33433
diff
changeset
|
1074 | 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
|
1075 | |
|
33517
ddd9e37c4b07
HTTP: PurpleHttpContentWriter support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33469
diff
changeset
|
1076 | 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
|
1077 | } |
|
9c4acb75b2e6
Let's parse response headers
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33431
diff
changeset
|
1078 | |
|
33522
7a3d131c3086
HTTP: don't freeze download on files larger than buffer size
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33521
diff
changeset
|
1079 | 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
|
1080 | { |
|
704de181d1d2
Let's request
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33430
diff
changeset
|
1081 | int len; |
|
33432
9c4acb75b2e6
Let's parse response headers
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33431
diff
changeset
|
1082 | 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
|
1083 | gboolean got_anything; |
|
33431
704de181d1d2
Let's request
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33430
diff
changeset
|
1084 | |
|
34316
2a3a587f5403
HTTP: make use of PurpleSocket
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
34314
diff
changeset
|
1085 | 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
|
1086 | got_anything = (len > 0); |
|
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 && 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
|
1089 | return FALSE; |
|
33431
704de181d1d2
Let's request
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33430
diff
changeset
|
1090 | |
|
704de181d1d2
Let's request
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33430
diff
changeset
|
1091 | if (len < 0) { |
|
704de181d1d2
Let's request
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33430
diff
changeset
|
1092 | _purple_http_error(hc, _("Error reading from %s: %s"), |
|
704de181d1d2
Let's request
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33430
diff
changeset
|
1093 | 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
|
1094 | return FALSE; |
|
33431
704de181d1d2
Let's request
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33430
diff
changeset
|
1095 | } |
|
704de181d1d2
Let's request
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33430
diff
changeset
|
1096 | |
|
33439
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
1097 | /* EOF */ |
|
33435
ab0560aa8ca4
Segfault shotgun debugging
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33434
diff
changeset
|
1098 | 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
|
1099 | 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
|
1100 | /* 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
|
1101 | 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
|
1102 | "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
|
1103 | 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
|
1104 | } |
|
33435
ab0560aa8ca4
Segfault shotgun debugging
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33434
diff
changeset
|
1105 | if (hc->length_expected >= 0 && |
|
35362
a6223370667b
Style: fix braces for http, keyring
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35352
diff
changeset
|
1106 | hc->length_got < (guint)hc->length_expected) |
|
a6223370667b
Style: fix braces for http, keyring
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35352
diff
changeset
|
1107 | { |
|
33435
ab0560aa8ca4
Segfault shotgun debugging
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33434
diff
changeset
|
1108 | purple_debug_warning("http", "No more data while reading" |
|
ab0560aa8ca4
Segfault shotgun debugging
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33434
diff
changeset
|
1109 | " contents\n"); |
|
ab0560aa8ca4
Segfault shotgun debugging
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33434
diff
changeset
|
1110 | _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
|
1111 | return FALSE; |
|
33435
ab0560aa8ca4
Segfault shotgun debugging
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33434
diff
changeset
|
1112 | } |
|
ab0560aa8ca4
Segfault shotgun debugging
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33434
diff
changeset
|
1113 | if (hc->headers_got) |
|
ab0560aa8ca4
Segfault shotgun debugging
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33434
diff
changeset
|
1114 | hc->length_expected = hc->length_got; |
|
34260
7a55eaa31da6
HTTP: implement keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34257
diff
changeset
|
1115 | 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
|
1116 | 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
|
1117 | "expired (when reading), retrying...\n"); |
|
34260
7a55eaa31da6
HTTP: implement keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34257
diff
changeset
|
1118 | purple_http_conn_retry(hc); |
|
7a55eaa31da6
HTTP: implement keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34257
diff
changeset
|
1119 | return FALSE; |
|
7a55eaa31da6
HTTP: implement keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34257
diff
changeset
|
1120 | } else { |
|
34516
cefaf531281e
HTTP: Fix a glib warning for improper HTTP response
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
34323
diff
changeset
|
1121 | const gchar *server = purple_http_headers_get( |
|
cefaf531281e
HTTP: Fix a glib warning for improper HTTP response
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
34323
diff
changeset
|
1122 | hc->response->headers, "Server"); |
|
cefaf531281e
HTTP: Fix a glib warning for improper HTTP response
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
34323
diff
changeset
|
1123 | if (server && |
|
cefaf531281e
HTTP: Fix a glib warning for improper HTTP response
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
34323
diff
changeset
|
1124 | g_ascii_strcasecmp(server, "YHttpServer") == 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
|
1125 | { |
|
8d0979967d05
HTTP: removing extra yahoo HTTP implementations - file transfer (and small improvements to libpurple http and ft code)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34272
diff
changeset
|
1126 | 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
|
1127 | "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
|
1128 | "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
|
1129 | 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
|
1130 | 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
|
1131 | 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
|
1132 | } 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
|
1133 | 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
|
1134 | "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
|
1135 | _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
|
1136 | 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
|
1137 | } |
|
33435
ab0560aa8ca4
Segfault shotgun debugging
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33434
diff
changeset
|
1138 | } |
|
ab0560aa8ca4
Segfault shotgun debugging
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33434
diff
changeset
|
1139 | } |
|
33433
fb7ac52ed7df
Let's get response contents
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33432
diff
changeset
|
1140 | |
|
fb7ac52ed7df
Let's get response contents
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33432
diff
changeset
|
1141 | if (!hc->headers_got && len > 0) { |
|
fb7ac52ed7df
Let's get response contents
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33432
diff
changeset
|
1142 | 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
|
1143 | return FALSE; |
|
33459
722a6d753cb2
Better cookies, better chunked transfer support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33458
diff
changeset
|
1144 | len = 0; |
|
33433
fb7ac52ed7df
Let's get response contents
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33432
diff
changeset
|
1145 | 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
|
1146 | gboolean is_gzip, is_deflate; |
|
33433
fb7ac52ed7df
Let's get response contents
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33432
diff
changeset
|
1147 | 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
|
1148 | "Content-Length", &hc->length_expected)) |
|
fb7ac52ed7df
Let's get response contents
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33432
diff
changeset
|
1149 | hc->length_expected = -1; |
|
33434
ec4f343af107
Chunked file transfers support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33433
diff
changeset
|
1150 | hc->is_chunked = (purple_http_headers_match( |
|
ec4f343af107
Chunked file transfers support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33433
diff
changeset
|
1151 | hc->response->headers, |
|
ec4f343af107
Chunked file transfers support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33433
diff
changeset
|
1152 | "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
|
1153 | 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
|
1154 | 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
|
1155 | "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
|
1156 | 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
|
1157 | 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
|
1158 | "deflate"); |
|
35362
a6223370667b
Style: fix braces for http, keyring
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35352
diff
changeset
|
1159 | if (is_gzip || is_deflate) { |
|
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
|
1160 | 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
|
1161 | 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
|
1162 | 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
|
1163 | } |
|
33434
ec4f343af107
Chunked file transfers support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33433
diff
changeset
|
1164 | } |
|
ec4f343af107
Chunked file transfers support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33433
diff
changeset
|
1165 | if (hc->headers_got && hc->response_buffer && |
|
35362
a6223370667b
Style: fix braces for http, keyring
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35352
diff
changeset
|
1166 | hc->response_buffer->len > 0) |
|
a6223370667b
Style: fix braces for http, keyring
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35352
diff
changeset
|
1167 | { |
|
33434
ec4f343af107
Chunked file transfers support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33433
diff
changeset
|
1168 | int buffer_len = hc->response_buffer->len; |
|
ec4f343af107
Chunked file transfers support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33433
diff
changeset
|
1169 | gchar *buffer = g_string_free(hc->response_buffer, FALSE); |
|
ec4f343af107
Chunked file transfers support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33433
diff
changeset
|
1170 | hc->response_buffer = NULL; |
|
ec4f343af107
Chunked file transfers support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33433
diff
changeset
|
1171 | _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
|
1172 | } |
|
33455
2de654702970
Print-like setting headers, vestigal keepalive support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33454
diff
changeset
|
1173 | 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
|
1174 | return got_anything; |
|
33433
fb7ac52ed7df
Let's get response contents
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33432
diff
changeset
|
1175 | } |
|
fb7ac52ed7df
Let's get response contents
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33432
diff
changeset
|
1176 | |
|
33434
ec4f343af107
Chunked file transfers support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33433
diff
changeset
|
1177 | if (len > 0) { |
|
ec4f343af107
Chunked file transfers support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33433
diff
changeset
|
1178 | 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
|
1179 | return FALSE; |
|
33434
ec4f343af107
Chunked file transfers support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33433
diff
changeset
|
1180 | } |
|
33433
fb7ac52ed7df
Let's get response contents
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33432
diff
changeset
|
1181 | |
|
34266
0cb189ba00f2
HTTP: refine content length calculation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34265
diff
changeset
|
1182 | 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
|
1183 | hc->length_expected = hc->length_got; |
|
ec4f343af107
Chunked file transfers support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33433
diff
changeset
|
1184 | |
|
34305
5804117fb298
Fix the rest of libpurple warnings about -Wsign-compare
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34295
diff
changeset
|
1185 | 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
|
1186 | 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
|
1187 | { |
|
33439
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
1188 | const gchar *redirect; |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
1189 | |
|
34266
0cb189ba00f2
HTTP: refine content length calculation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34265
diff
changeset
|
1190 | if (hc->is_chunked && !hc->chunks_done) { |
|
0cb189ba00f2
HTTP: refine content length calculation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34265
diff
changeset
|
1191 | if (purple_debug_is_verbose()) { |
|
0cb189ba00f2
HTTP: refine content length calculation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34265
diff
changeset
|
1192 | purple_debug_misc("http", |
|
0cb189ba00f2
HTTP: refine content length calculation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34265
diff
changeset
|
1193 | "I need the terminating empty chunk\n"); |
|
0cb189ba00f2
HTTP: refine content length calculation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34265
diff
changeset
|
1194 | } |
|
0cb189ba00f2
HTTP: refine content length calculation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34265
diff
changeset
|
1195 | return TRUE; |
|
0cb189ba00f2
HTTP: refine content length calculation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34265
diff
changeset
|
1196 | } |
|
0cb189ba00f2
HTTP: refine content length calculation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34265
diff
changeset
|
1197 | |
|
33432
9c4acb75b2e6
Let's parse response headers
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33431
diff
changeset
|
1198 | if (!hc->headers_got) { |
|
9c4acb75b2e6
Let's parse response headers
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33431
diff
changeset
|
1199 | hc->response->code = 0; |
|
33433
fb7ac52ed7df
Let's get response contents
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33432
diff
changeset
|
1200 | 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
|
1201 | _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
|
1202 | return FALSE; |
|
33432
9c4acb75b2e6
Let's parse response headers
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33431
diff
changeset
|
1203 | } |
|
9c4acb75b2e6
Let's parse response headers
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33431
diff
changeset
|
1204 | |
|
9c4acb75b2e6
Let's parse response headers
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33431
diff
changeset
|
1205 | 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
|
1206 | gchar *hdrs = purple_http_headers_dump( |
|
9c4acb75b2e6
Let's parse response headers
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33431
diff
changeset
|
1207 | hc->response->headers); |
|
9c4acb75b2e6
Let's parse response headers
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33431
diff
changeset
|
1208 | 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
|
1209 | hdrs); |
|
9c4acb75b2e6
Let's parse response headers
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33431
diff
changeset
|
1210 | g_free(hdrs); |
|
9c4acb75b2e6
Let's parse response headers
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33431
diff
changeset
|
1211 | } |
|
9c4acb75b2e6
Let's parse response headers
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33431
diff
changeset
|
1212 | |
|
33456
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
1213 | purple_http_cookie_jar_parse(hc->request->cookie_jar, |
|
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
1214 | purple_http_headers_get_all_by_name( |
|
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
1215 | hc->response->headers, "Set-Cookie")); |
|
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
1216 | |
|
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
1217 | if (purple_debug_is_unsafe() && purple_debug_is_verbose() && |
|
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
1218 | !purple_http_cookie_jar_is_empty( |
|
35362
a6223370667b
Style: fix braces for http, keyring
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35352
diff
changeset
|
1219 | hc->request->cookie_jar)) |
|
a6223370667b
Style: fix braces for http, keyring
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35352
diff
changeset
|
1220 | { |
|
33456
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
1221 | gchar *cookies = purple_http_cookie_jar_dump( |
|
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
1222 | hc->request->cookie_jar); |
|
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
1223 | purple_debug_misc("http", "Cookies: %s\n", cookies); |
|
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
1224 | g_free(cookies); |
|
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
1225 | } |
|
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
1226 | |
|
33453
3cb58ea9667c
HTTP Proxy support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33452
diff
changeset
|
1227 | if (hc->response->code == 407) { |
|
3cb58ea9667c
HTTP Proxy support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33452
diff
changeset
|
1228 | _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
|
1229 | return FALSE; |
|
33453
3cb58ea9667c
HTTP Proxy support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33452
diff
changeset
|
1230 | } |
|
3cb58ea9667c
HTTP Proxy support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33452
diff
changeset
|
1231 | |
|
33439
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
1232 | redirect = purple_http_headers_get(hc->response->headers, |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
1233 | "location"); |
|
33445
1bcbdca07787
Allow infinite amount of redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33444
diff
changeset
|
1234 | if (redirect && (hc->request->max_redirects == -1 || |
|
35362
a6223370667b
Style: fix braces for http, keyring
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35352
diff
changeset
|
1235 | hc->request->max_redirects > hc->redirects_count)) |
|
a6223370667b
Style: fix braces for http, keyring
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35352
diff
changeset
|
1236 | { |
|
33439
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
1237 | PurpleHttpURL *url = purple_http_url_parse(redirect); |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
1238 | |
|
33444
b3afec292014
New features: http version switching and limits for redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33443
diff
changeset
|
1239 | hc->redirects_count++; |
|
b3afec292014
New features: http version switching and limits for redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33443
diff
changeset
|
1240 | |
|
33439
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
1241 | if (!url) { |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
1242 | if (purple_debug_is_unsafe()) |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
1243 | purple_debug_warning("http", |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
1244 | "Invalid redirect to %s\n", |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
1245 | redirect); |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
1246 | else |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
1247 | purple_debug_warning("http", |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
1248 | "Invalid redirect\n"); |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
1249 | _purple_http_error(hc, _("Error parsing HTTP")); |
|
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 | |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
1252 | purple_http_url_relative(hc->url, url); |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
1253 | purple_http_url_free(url); |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
1254 | |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
1255 | _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
|
1256 | return FALSE; |
|
33439
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
1257 | } |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
1258 | |
|
34260
7a55eaa31da6
HTTP: implement keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34257
diff
changeset
|
1259 | _purple_http_disconnect(hc, TRUE); |
|
33432
9c4acb75b2e6
Let's parse response headers
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33431
diff
changeset
|
1260 | 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
|
1261 | return FALSE; |
|
33432
9c4acb75b2e6
Let's parse response headers
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33431
diff
changeset
|
1262 | } |
|
33522
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 | 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
|
1265 | } |
|
7a3d131c3086
HTTP: don't freeze download on files larger than buffer size
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33521
diff
changeset
|
1266 | |
|
7a3d131c3086
HTTP: don't freeze download on files larger than buffer size
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33521
diff
changeset
|
1267 | 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
|
1268 | { |
|
7a3d131c3086
HTTP: don't freeze download on files larger than buffer size
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33521
diff
changeset
|
1269 | 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
|
1270 | |
|
7a3d131c3086
HTTP: don't freeze download on files larger than buffer size
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33521
diff
changeset
|
1271 | while (_purple_http_recv_loopbody(hc, fd)); |
|
33431
704de181d1d2
Let's request
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33430
diff
changeset
|
1272 | } |
|
704de181d1d2
Let's request
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33430
diff
changeset
|
1273 | |
|
33466
918507303f45
HTTP API: PurpleHttpContentReader support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33464
diff
changeset
|
1274 | static void _purple_http_send_got_data(PurpleHttpConnection *hc, |
|
918507303f45
HTTP API: PurpleHttpContentReader support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33464
diff
changeset
|
1275 | gboolean success, gboolean eof, size_t stored) |
|
918507303f45
HTTP API: PurpleHttpContentReader support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33464
diff
changeset
|
1276 | { |
|
918507303f45
HTTP API: PurpleHttpContentReader support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33464
diff
changeset
|
1277 | int estimated_length; |
|
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 | g_return_if_fail(hc != NULL); |
|
918507303f45
HTTP API: PurpleHttpContentReader support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33464
diff
changeset
|
1280 | |
|
918507303f45
HTTP API: PurpleHttpContentReader support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33464
diff
changeset
|
1281 | if (!success) { |
|
918507303f45
HTTP API: PurpleHttpContentReader support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33464
diff
changeset
|
1282 | _purple_http_error(hc, _("Error requesting data to write")); |
|
918507303f45
HTTP API: PurpleHttpContentReader support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33464
diff
changeset
|
1283 | return; |
|
918507303f45
HTTP API: PurpleHttpContentReader support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33464
diff
changeset
|
1284 | } |
|
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 | hc->contents_reader_requested = FALSE; |
|
918507303f45
HTTP API: PurpleHttpContentReader support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33464
diff
changeset
|
1287 | g_string_set_size(hc->contents_reader_buffer, stored); |
|
918507303f45
HTTP API: PurpleHttpContentReader support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33464
diff
changeset
|
1288 | if (!eof) |
|
918507303f45
HTTP API: PurpleHttpContentReader support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33464
diff
changeset
|
1289 | return; |
|
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 | estimated_length = hc->request_contents_written + stored; |
|
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 | if (hc->request->contents_length != -1 && |
|
35362
a6223370667b
Style: fix braces for http, keyring
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35352
diff
changeset
|
1294 | hc->request->contents_length != estimated_length) |
|
a6223370667b
Style: fix braces for http, keyring
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35352
diff
changeset
|
1295 | { |
|
33466
918507303f45
HTTP API: PurpleHttpContentReader support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33464
diff
changeset
|
1296 | purple_debug_warning("http", |
|
918507303f45
HTTP API: PurpleHttpContentReader support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33464
diff
changeset
|
1297 | "Invalid amount of data has been written\n"); |
|
918507303f45
HTTP API: PurpleHttpContentReader support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33464
diff
changeset
|
1298 | } |
|
918507303f45
HTTP API: PurpleHttpContentReader support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33464
diff
changeset
|
1299 | hc->request->contents_length = estimated_length; |
|
918507303f45
HTTP API: PurpleHttpContentReader support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33464
diff
changeset
|
1300 | } |
|
918507303f45
HTTP API: PurpleHttpContentReader support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33464
diff
changeset
|
1301 | |
|
33430
013c5aebb665
Let's connect
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33429
diff
changeset
|
1302 | 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
|
1303 | { |
|
33430
013c5aebb665
Let's connect
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33429
diff
changeset
|
1304 | PurpleHttpConnection *hc = _hc; |
|
33431
704de181d1d2
Let's request
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33430
diff
changeset
|
1305 | int written, write_len; |
|
704de181d1d2
Let's request
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33430
diff
changeset
|
1306 | const gchar *write_from; |
|
33457
81f92a310aff
Writing request contents
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33456
diff
changeset
|
1307 | gboolean writing_headers; |
|
33431
704de181d1d2
Let's request
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33430
diff
changeset
|
1308 | |
|
33466
918507303f45
HTTP API: PurpleHttpContentReader support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33464
diff
changeset
|
1309 | /* 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
|
1310 | * (and later, adding) hs->inpa. */ |
|
918507303f45
HTTP API: PurpleHttpContentReader support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33464
diff
changeset
|
1311 | if (hc->contents_reader_requested) |
|
918507303f45
HTTP API: PurpleHttpContentReader support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33464
diff
changeset
|
1312 | return; |
|
918507303f45
HTTP API: PurpleHttpContentReader support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33464
diff
changeset
|
1313 | |
|
33431
704de181d1d2
Let's request
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33430
diff
changeset
|
1314 | _purple_http_gen_headers(hc); |
|
33430
013c5aebb665
Let's connect
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33429
diff
changeset
|
1315 | |
|
33457
81f92a310aff
Writing request contents
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33456
diff
changeset
|
1316 | writing_headers = |
|
81f92a310aff
Writing request contents
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33456
diff
changeset
|
1317 | (hc->request_header_written < hc->request_header->len); |
|
81f92a310aff
Writing request contents
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33456
diff
changeset
|
1318 | if (writing_headers) { |
|
81f92a310aff
Writing request contents
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33456
diff
changeset
|
1319 | write_from = hc->request_header->str + |
|
81f92a310aff
Writing request contents
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33456
diff
changeset
|
1320 | hc->request_header_written; |
|
81f92a310aff
Writing request contents
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33456
diff
changeset
|
1321 | write_len = hc->request_header->len - |
|
81f92a310aff
Writing request contents
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33456
diff
changeset
|
1322 | hc->request_header_written; |
|
33466
918507303f45
HTTP API: PurpleHttpContentReader support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33464
diff
changeset
|
1323 | } else if (hc->request->contents_reader) { |
|
918507303f45
HTTP API: PurpleHttpContentReader support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33464
diff
changeset
|
1324 | if (hc->contents_reader_requested) |
|
918507303f45
HTTP API: PurpleHttpContentReader support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33464
diff
changeset
|
1325 | return; /* waiting for data */ |
|
918507303f45
HTTP API: PurpleHttpContentReader support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33464
diff
changeset
|
1326 | if (!hc->contents_reader_buffer) |
|
918507303f45
HTTP API: PurpleHttpContentReader support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33464
diff
changeset
|
1327 | hc->contents_reader_buffer = g_string_new(""); |
|
918507303f45
HTTP API: PurpleHttpContentReader support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33464
diff
changeset
|
1328 | if (hc->contents_reader_buffer->len == 0) { |
|
918507303f45
HTTP API: PurpleHttpContentReader support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33464
diff
changeset
|
1329 | hc->contents_reader_requested = TRUE; |
|
918507303f45
HTTP API: PurpleHttpContentReader support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33464
diff
changeset
|
1330 | g_string_set_size(hc->contents_reader_buffer, |
|
918507303f45
HTTP API: PurpleHttpContentReader support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33464
diff
changeset
|
1331 | PURPLE_HTTP_MAX_READ_BUFFER_LEN); |
|
918507303f45
HTTP API: PurpleHttpContentReader support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33464
diff
changeset
|
1332 | hc->request->contents_reader(hc, |
|
918507303f45
HTTP API: PurpleHttpContentReader support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33464
diff
changeset
|
1333 | hc->contents_reader_buffer->str, |
|
918507303f45
HTTP API: PurpleHttpContentReader support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33464
diff
changeset
|
1334 | hc->request_contents_written, |
|
918507303f45
HTTP API: PurpleHttpContentReader support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33464
diff
changeset
|
1335 | PURPLE_HTTP_MAX_READ_BUFFER_LEN, |
|
918507303f45
HTTP API: PurpleHttpContentReader support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33464
diff
changeset
|
1336 | hc->request->contents_reader_data, |
|
918507303f45
HTTP API: PurpleHttpContentReader support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33464
diff
changeset
|
1337 | _purple_http_send_got_data); |
|
918507303f45
HTTP API: PurpleHttpContentReader support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33464
diff
changeset
|
1338 | return; |
|
918507303f45
HTTP API: PurpleHttpContentReader support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33464
diff
changeset
|
1339 | } |
|
918507303f45
HTTP API: PurpleHttpContentReader support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33464
diff
changeset
|
1340 | write_from = hc->contents_reader_buffer->str; |
|
918507303f45
HTTP API: PurpleHttpContentReader support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33464
diff
changeset
|
1341 | write_len = hc->contents_reader_buffer->len; |
|
33457
81f92a310aff
Writing request contents
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33456
diff
changeset
|
1342 | } else { |
|
81f92a310aff
Writing request contents
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33456
diff
changeset
|
1343 | write_from = hc->request->contents + |
|
81f92a310aff
Writing request contents
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33456
diff
changeset
|
1344 | hc->request_contents_written; |
|
81f92a310aff
Writing request contents
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33456
diff
changeset
|
1345 | write_len = hc->request->contents_length - |
|
81f92a310aff
Writing request contents
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33456
diff
changeset
|
1346 | hc->request_contents_written; |
|
81f92a310aff
Writing request contents
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33456
diff
changeset
|
1347 | } |
|
33431
704de181d1d2
Let's request
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33430
diff
changeset
|
1348 | |
|
33457
81f92a310aff
Writing request contents
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33456
diff
changeset
|
1349 | if (write_len == 0) { |
|
81f92a310aff
Writing request contents
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33456
diff
changeset
|
1350 | purple_debug_warning("http", "Nothing to write\n"); |
|
81f92a310aff
Writing request contents
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33456
diff
changeset
|
1351 | 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
|
1352 | } else { |
|
34316
2a3a587f5403
HTTP: make use of PurpleSocket
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
34314
diff
changeset
|
1353 | written = purple_socket_write(hc->socket->ps, |
|
2a3a587f5403
HTTP: make use of PurpleSocket
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
34314
diff
changeset
|
1354 | (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
|
1355 | } |
|
33431
704de181d1d2
Let's request
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33430
diff
changeset
|
1356 | |
|
704de181d1d2
Let's request
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33430
diff
changeset
|
1357 | if (written < 0 && errno == EAGAIN) |
|
704de181d1d2
Let's request
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33430
diff
changeset
|
1358 | return; |
|
704de181d1d2
Let's request
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33430
diff
changeset
|
1359 | |
|
704de181d1d2
Let's request
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33430
diff
changeset
|
1360 | 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
|
1361 | 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
|
1362 | 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
|
1363 | { |
|
e6de87604147
HTTP: get rid of the second msn's own HTTP implementation (for soap)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34263
diff
changeset
|
1364 | 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
|
1365 | "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
|
1366 | 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
|
1367 | 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
|
1368 | } |
|
e6de87604147
HTTP: get rid of the second msn's own HTTP implementation (for soap)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34263
diff
changeset
|
1369 | |
|
33431
704de181d1d2
Let's request
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33430
diff
changeset
|
1370 | _purple_http_error(hc, _("Error writing to %s: %s"), |
|
704de181d1d2
Let's request
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33430
diff
changeset
|
1371 | hc->url->host, g_strerror(errno)); |
|
704de181d1d2
Let's request
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33430
diff
changeset
|
1372 | return; |
|
704de181d1d2
Let's request
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33430
diff
changeset
|
1373 | } |
|
704de181d1d2
Let's request
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33430
diff
changeset
|
1374 | |
|
33457
81f92a310aff
Writing request contents
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33456
diff
changeset
|
1375 | if (writing_headers) { |
|
81f92a310aff
Writing request contents
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33456
diff
changeset
|
1376 | hc->request_header_written += written; |
|
33468
b057fee9d11a
HTTP progress watcher support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33466
diff
changeset
|
1377 | purple_http_conn_notify_progress_watcher(hc); |
|
33457
81f92a310aff
Writing request contents
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33456
diff
changeset
|
1378 | if (hc->request_header_written < hc->request_header->len) |
|
81f92a310aff
Writing request contents
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33456
diff
changeset
|
1379 | return; |
|
81f92a310aff
Writing request contents
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33456
diff
changeset
|
1380 | if (hc->request->contents_length > 0) |
|
81f92a310aff
Writing request contents
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33456
diff
changeset
|
1381 | return; |
|
81f92a310aff
Writing request contents
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33456
diff
changeset
|
1382 | } else { |
|
81f92a310aff
Writing request contents
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33456
diff
changeset
|
1383 | hc->request_contents_written += written; |
|
33468
b057fee9d11a
HTTP progress watcher support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33466
diff
changeset
|
1384 | purple_http_conn_notify_progress_watcher(hc); |
|
33466
918507303f45
HTTP API: PurpleHttpContentReader support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33464
diff
changeset
|
1385 | if (hc->contents_reader_buffer) |
|
918507303f45
HTTP API: PurpleHttpContentReader support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33464
diff
changeset
|
1386 | 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
|
1387 | 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
|
1388 | hc->request_contents_written < |
|
5804117fb298
Fix the rest of libpurple warnings about -Wsign-compare
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34295
diff
changeset
|
1389 | (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
|
1390 | { |
|
33457
81f92a310aff
Writing request contents
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33456
diff
changeset
|
1391 | return; |
|
34305
5804117fb298
Fix the rest of libpurple warnings about -Wsign-compare
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34295
diff
changeset
|
1392 | } |
|
33457
81f92a310aff
Writing request contents
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33456
diff
changeset
|
1393 | } |
|
33431
704de181d1d2
Let's request
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33430
diff
changeset
|
1394 | |
|
704de181d1d2
Let's request
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33430
diff
changeset
|
1395 | /* 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
|
1396 | hc->is_reading = TRUE; |
|
34316
2a3a587f5403
HTTP: make use of PurpleSocket
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
34314
diff
changeset
|
1397 | 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
|
1398 | _purple_http_recv, hc); |
|
33430
013c5aebb665
Let's connect
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33429
diff
changeset
|
1399 | } |
|
013c5aebb665
Let's connect
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33429
diff
changeset
|
1400 | |
|
34260
7a55eaa31da6
HTTP: implement keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34257
diff
changeset
|
1401 | static void _purple_http_disconnect(PurpleHttpConnection *hc, |
|
7a55eaa31da6
HTTP: implement keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34257
diff
changeset
|
1402 | gboolean is_graceful) |
|
33430
013c5aebb665
Let's connect
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33429
diff
changeset
|
1403 | { |
|
013c5aebb665
Let's connect
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33429
diff
changeset
|
1404 | g_return_if_fail(hc != NULL); |
|
013c5aebb665
Let's connect
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33429
diff
changeset
|
1405 | |
|
33431
704de181d1d2
Let's request
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33430
diff
changeset
|
1406 | if (hc->request_header) |
|
704de181d1d2
Let's request
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33430
diff
changeset
|
1407 | g_string_free(hc->request_header, TRUE); |
|
704de181d1d2
Let's request
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33430
diff
changeset
|
1408 | hc->request_header = NULL; |
|
34260
7a55eaa31da6
HTTP: implement keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34257
diff
changeset
|
1409 | |
|
33432
9c4acb75b2e6
Let's parse response headers
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33431
diff
changeset
|
1410 | if (hc->response_buffer) |
|
9c4acb75b2e6
Let's parse response headers
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33431
diff
changeset
|
1411 | g_string_free(hc->response_buffer, TRUE); |
|
9c4acb75b2e6
Let's parse response headers
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33431
diff
changeset
|
1412 | hc->response_buffer = NULL; |
|
33430
013c5aebb665
Let's connect
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33429
diff
changeset
|
1413 | |
|
34263
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
1414 | if (hc->socket_request) |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
1415 | 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
|
1416 | else { |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
1417 | 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
|
1418 | hc->socket = NULL; |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
1419 | } |
|
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
|
1420 | } |
|
935120490eb2
HTTP: isolate socket-related code in http module; initial implementation for keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34234
diff
changeset
|
1421 | |
|
34316
2a3a587f5403
HTTP: make use of PurpleSocket
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
34314
diff
changeset
|
1422 | static void |
|
2a3a587f5403
HTTP: make use of PurpleSocket
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
34314
diff
changeset
|
1423 | _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
|
1424 | { |
|
34316
2a3a587f5403
HTTP: make use of PurpleSocket
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
34314
diff
changeset
|
1425 | 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
|
1426 | 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
|
1427 | |
|
34316
2a3a587f5403
HTTP: make use of PurpleSocket
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
34314
diff
changeset
|
1428 | if (ps != NULL) |
|
2a3a587f5403
HTTP: make use of PurpleSocket
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
34314
diff
changeset
|
1429 | hs = purple_socket_get_data(ps, "hs"); |
|
2a3a587f5403
HTTP: make use of PurpleSocket
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
34314
diff
changeset
|
1430 | |
|
34263
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
1431 | hc->socket_request = NULL; |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
1432 | hc->socket = hs; |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
1433 | |
|
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
|
1434 | 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
|
1435 | _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
|
1436 | 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
|
1437 | return; |
|
33430
013c5aebb665
Let's connect
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33429
diff
changeset
|
1438 | } |
|
34263
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
1439 | |
|
35156
1bc10c44beef
HTTP: fix some clang warnings
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
34516
diff
changeset
|
1440 | purple_socket_watch(ps, PURPLE_INPUT_WRITE, _purple_http_send, hc); |
|
33430
013c5aebb665
Let's connect
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33429
diff
changeset
|
1441 | } |
|
013c5aebb665
Let's connect
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33429
diff
changeset
|
1442 | |
|
013c5aebb665
Let's connect
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33429
diff
changeset
|
1443 | static gboolean _purple_http_reconnect(PurpleHttpConnection *hc) |
|
013c5aebb665
Let's connect
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33429
diff
changeset
|
1444 | { |
|
013c5aebb665
Let's connect
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33429
diff
changeset
|
1445 | PurpleHttpURL *url; |
|
013c5aebb665
Let's connect
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33429
diff
changeset
|
1446 | gboolean is_ssl = FALSE; |
|
013c5aebb665
Let's connect
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33429
diff
changeset
|
1447 | |
|
013c5aebb665
Let's connect
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33429
diff
changeset
|
1448 | g_return_val_if_fail(hc != NULL, FALSE); |
|
013c5aebb665
Let's connect
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33429
diff
changeset
|
1449 | g_return_val_if_fail(hc->url != NULL, FALSE); |
|
013c5aebb665
Let's connect
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33429
diff
changeset
|
1450 | |
|
34260
7a55eaa31da6
HTTP: implement keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34257
diff
changeset
|
1451 | _purple_http_disconnect(hc, TRUE); |
|
33430
013c5aebb665
Let's connect
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33429
diff
changeset
|
1452 | |
|
33438
66c4b90ff08a
More debug prints
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33437
diff
changeset
|
1453 | if (purple_debug_is_verbose()) { |
|
66c4b90ff08a
More debug prints
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33437
diff
changeset
|
1454 | if (purple_debug_is_unsafe()) { |
|
35156
1bc10c44beef
HTTP: fix some clang warnings
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
34516
diff
changeset
|
1455 | gchar *urlp = purple_http_url_print(hc->url); |
|
1bc10c44beef
HTTP: fix some clang warnings
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
34516
diff
changeset
|
1456 | purple_debug_misc("http", "Connecting to %s...\n", urlp); |
|
1bc10c44beef
HTTP: fix some clang warnings
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
34516
diff
changeset
|
1457 | g_free(urlp); |
|
33438
66c4b90ff08a
More debug prints
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33437
diff
changeset
|
1458 | } else |
|
66c4b90ff08a
More debug prints
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33437
diff
changeset
|
1459 | purple_debug_misc("http", "Connecting to %s...\n", |
|
66c4b90ff08a
More debug prints
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33437
diff
changeset
|
1460 | hc->url->host); |
|
66c4b90ff08a
More debug prints
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33437
diff
changeset
|
1461 | } |
|
66c4b90ff08a
More debug prints
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33437
diff
changeset
|
1462 | |
|
33430
013c5aebb665
Let's connect
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33429
diff
changeset
|
1463 | url = hc->url; |
|
35156
1bc10c44beef
HTTP: fix some clang warnings
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
34516
diff
changeset
|
1464 | if (g_strcmp0(url->protocol, "") == 0 || |
|
35362
a6223370667b
Style: fix braces for http, keyring
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35352
diff
changeset
|
1465 | g_ascii_strcasecmp(url->protocol, "http") == 0) |
|
a6223370667b
Style: fix braces for http, keyring
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35352
diff
changeset
|
1466 | { |
|
33430
013c5aebb665
Let's connect
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33429
diff
changeset
|
1467 | /* do nothing */ |
|
013c5aebb665
Let's connect
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33429
diff
changeset
|
1468 | } else if (g_ascii_strcasecmp(url->protocol, "https") == 0) { |
|
013c5aebb665
Let's connect
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33429
diff
changeset
|
1469 | is_ssl = TRUE; |
|
013c5aebb665
Let's connect
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33429
diff
changeset
|
1470 | } else { |
|
013c5aebb665
Let's connect
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33429
diff
changeset
|
1471 | _purple_http_error(hc, _("Unsupported protocol: %s"), |
|
013c5aebb665
Let's connect
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33429
diff
changeset
|
1472 | url->protocol); |
|
013c5aebb665
Let's connect
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33429
diff
changeset
|
1473 | return FALSE; |
|
013c5aebb665
Let's connect
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33429
diff
changeset
|
1474 | } |
|
013c5aebb665
Let's connect
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33429
diff
changeset
|
1475 | |
|
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
|
1476 | 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
|
1477 | _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
|
1478 | 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
|
1479 | "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
|
1480 | return FALSE; |
|
33430
013c5aebb665
Let's connect
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33429
diff
changeset
|
1481 | } |
|
013c5aebb665
Let's connect
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33429
diff
changeset
|
1482 | |
|
34263
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
1483 | if (hc->request->keepalive_pool != NULL) { |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
1484 | 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
|
1485 | 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
|
1486 | 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
|
1487 | } else { |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
1488 | 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
|
1489 | 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
|
1490 | } |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
1491 | |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
1492 | if (hc->socket_request == NULL && hc->socket == NULL) { |
|
33430
013c5aebb665
Let's connect
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33429
diff
changeset
|
1493 | _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
|
1494 | return FALSE; |
|
013c5aebb665
Let's connect
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33429
diff
changeset
|
1495 | } |
|
33432
9c4acb75b2e6
Let's parse response headers
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33431
diff
changeset
|
1496 | |
|
9c4acb75b2e6
Let's parse response headers
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33431
diff
changeset
|
1497 | purple_http_headers_free(hc->response->headers); |
|
9c4acb75b2e6
Let's parse response headers
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33431
diff
changeset
|
1498 | hc->response->headers = purple_http_headers_new(); |
|
9c4acb75b2e6
Let's parse response headers
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33431
diff
changeset
|
1499 | hc->response_buffer = g_string_new(""); |
|
9c4acb75b2e6
Let's parse response headers
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33431
diff
changeset
|
1500 | hc->main_header_got = FALSE; |
|
9c4acb75b2e6
Let's parse response headers
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33431
diff
changeset
|
1501 | hc->headers_got = FALSE; |
|
33433
fb7ac52ed7df
Let's get response contents
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33432
diff
changeset
|
1502 | if (hc->response->contents != NULL) |
|
fb7ac52ed7df
Let's get response contents
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33432
diff
changeset
|
1503 | g_string_free(hc->response->contents, TRUE); |
|
fb7ac52ed7df
Let's get response contents
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33432
diff
changeset
|
1504 | hc->response->contents = NULL; |
|
fb7ac52ed7df
Let's get response contents
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33432
diff
changeset
|
1505 | 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
|
1506 | hc->length_got_decompressed = 0; |
|
33433
fb7ac52ed7df
Let's get response contents
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33432
diff
changeset
|
1507 | hc->length_expected = -1; |
|
33434
ec4f343af107
Chunked file transfers support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33433
diff
changeset
|
1508 | hc->is_chunked = FALSE; |
|
ec4f343af107
Chunked file transfers support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33433
diff
changeset
|
1509 | hc->in_chunk = FALSE; |
|
ec4f343af107
Chunked file transfers support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33433
diff
changeset
|
1510 | hc->chunks_done = FALSE; |
|
33430
013c5aebb665
Let's connect
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33429
diff
changeset
|
1511 | |
|
33468
b057fee9d11a
HTTP progress watcher support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33466
diff
changeset
|
1512 | purple_http_conn_notify_progress_watcher(hc); |
|
b057fee9d11a
HTTP progress watcher support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33466
diff
changeset
|
1513 | |
|
33430
013c5aebb665
Let's connect
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33429
diff
changeset
|
1514 | return TRUE; |
|
013c5aebb665
Let's connect
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33429
diff
changeset
|
1515 | } |
|
013c5aebb665
Let's connect
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33429
diff
changeset
|
1516 | |
|
33427
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
1517 | /*** Performing HTTP requests *************************************************/ |
|
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
1518 | |
|
33450
4042907bcdf1
Timeout support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33448
diff
changeset
|
1519 | static gboolean purple_http_request_timeout(gpointer _hc) |
|
4042907bcdf1
Timeout support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33448
diff
changeset
|
1520 | { |
|
4042907bcdf1
Timeout support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33448
diff
changeset
|
1521 | PurpleHttpConnection *hc = _hc; |
|
4042907bcdf1
Timeout support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33448
diff
changeset
|
1522 | |
|
4042907bcdf1
Timeout support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33448
diff
changeset
|
1523 | purple_debug_warning("http", "Timeout reached for request %p\n", hc); |
|
4042907bcdf1
Timeout support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33448
diff
changeset
|
1524 | |
|
4042907bcdf1
Timeout support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33448
diff
changeset
|
1525 | purple_http_conn_cancel(hc); |
|
4042907bcdf1
Timeout support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33448
diff
changeset
|
1526 | |
|
4042907bcdf1
Timeout support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33448
diff
changeset
|
1527 | return FALSE; |
|
4042907bcdf1
Timeout support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33448
diff
changeset
|
1528 | } |
|
4042907bcdf1
Timeout support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33448
diff
changeset
|
1529 | |
|
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
|
1530 | 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
|
1531 | 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
|
1532 | { |
|
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
1533 | PurpleHttpRequest *request; |
|
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
1534 | PurpleHttpConnection *hc; |
|
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
1535 | |
|
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
1536 | 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
|
1537 | |
|
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
1538 | request = purple_http_request_new(url); |
|
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
1539 | 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
|
1540 | purple_http_request_unref(request); |
|
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
1541 | |
|
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
1542 | return hc; |
|
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
1543 | } |
|
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
1544 | |
|
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
|
1545 | 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
|
1546 | 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
|
1547 | 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
|
1548 | { |
|
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 | 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
|
1550 | 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
|
1551 | 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
|
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 | 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
|
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 | 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
|
1556 | 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
|
1557 | 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
|
1558 | |
|
8bdcc4f84a5e
HTTP: introduce purple_http_get_printf, make purple_http_get consistent with it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34232
diff
changeset
|
1559 | 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
|
1560 | 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
|
1561 | |
|
8bdcc4f84a5e
HTTP: introduce purple_http_get_printf, make purple_http_get consistent with it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34232
diff
changeset
|
1562 | 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
|
1563 | } |
|
8bdcc4f84a5e
HTTP: introduce purple_http_get_printf, make purple_http_get consistent with it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34232
diff
changeset
|
1564 | |
|
33427
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
1565 | PurpleHttpConnection * purple_http_request(PurpleConnection *gc, |
|
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
1566 | PurpleHttpRequest *request, PurpleHttpCallback callback, |
|
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
1567 | gpointer user_data) |
|
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
1568 | { |
|
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
1569 | PurpleHttpConnection *hc; |
|
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
1570 | |
|
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
1571 | 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
|
1572 | |
|
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
|
1573 | 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
|
1574 | 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
|
1575 | "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
|
1576 | 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
|
1577 | } |
|
a5517f235e0f
HTTP: migrate purple_util_fetch_url_request to new API for GG prpl
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34225
diff
changeset
|
1578 | |
|
34262
3b8ce83bac96
HTTP: get rid of one (of two) msn's own http implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34261
diff
changeset
|
1579 | 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
|
1580 | 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
|
1581 | "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
|
1582 | "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
|
1583 | 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
|
1584 | } |
|
3b8ce83bac96
HTTP: get rid of one (of two) msn's own http implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34261
diff
changeset
|
1585 | |
|
33448
4d41b1f7b95f
Cancelling all HTTP connections on account disconnect or app shutdown
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33447
diff
changeset
|
1586 | 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
|
1587 | hc->callback = callback; |
|
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
1588 | hc->user_data = user_data; |
|
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
1589 | |
|
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
|
1590 | 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
|
1591 | |
|
33429
1ce1faf4e675
Extend URL parsing
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33427
diff
changeset
|
1592 | if (purple_debug_is_unsafe()) |
|
1ce1faf4e675
Extend URL parsing
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33427
diff
changeset
|
1593 | 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
|
1594 | hc, request->url); |
|
1ce1faf4e675
Extend URL parsing
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33427
diff
changeset
|
1595 | 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
|
1596 | 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
|
1597 | 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
|
1598 | |
|
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
|
1599 | 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
|
1600 | purple_debug_error("http", "Invalid URL requested.\n"); |
|
1ce1faf4e675
Extend URL parsing
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33427
diff
changeset
|
1601 | purple_http_connection_terminate(hc); |
|
1ce1faf4e675
Extend URL parsing
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33427
diff
changeset
|
1602 | return NULL; |
|
1ce1faf4e675
Extend URL parsing
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33427
diff
changeset
|
1603 | } |
|
33427
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
1604 | |
|
33430
013c5aebb665
Let's connect
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33429
diff
changeset
|
1605 | _purple_http_reconnect(hc); |
|
013c5aebb665
Let's connect
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33429
diff
changeset
|
1606 | |
|
33450
4042907bcdf1
Timeout support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33448
diff
changeset
|
1607 | hc->timeout_handle = purple_timeout_add_seconds(request->timeout, |
|
4042907bcdf1
Timeout support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33448
diff
changeset
|
1608 | purple_http_request_timeout, hc); |
|
33427
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
1609 | |
|
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
1610 | return hc; |
|
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 | |
|
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
1613 | /*** HTTP connection API ******************************************************/ |
|
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
1614 | |
|
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
1615 | 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
|
1616 | 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
|
1617 | |
|
33448
4d41b1f7b95f
Cancelling all HTTP connections on account disconnect or app shutdown
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33447
diff
changeset
|
1618 | 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
|
1619 | PurpleHttpRequest *request, PurpleConnection *gc) |
|
33427
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
1620 | { |
|
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
1621 | PurpleHttpConnection *hc = g_new0(PurpleHttpConnection, 1); |
|
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
1622 | |
|
35156
1bc10c44beef
HTTP: fix some clang warnings
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
34516
diff
changeset
|
1623 | g_assert(request != NULL); |
|
1bc10c44beef
HTTP: fix some clang warnings
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
34516
diff
changeset
|
1624 | |
|
33429
1ce1faf4e675
Extend URL parsing
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33427
diff
changeset
|
1625 | hc->request = request; |
|
1ce1faf4e675
Extend URL parsing
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33427
diff
changeset
|
1626 | purple_http_request_ref(request); |
|
33427
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
1627 | 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
|
1628 | 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
|
1629 | |
|
33448
4d41b1f7b95f
Cancelling all HTTP connections on account disconnect or app shutdown
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33447
diff
changeset
|
1630 | 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
|
1631 | 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
|
1632 | 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
|
1633 | if (gc) { |
|
4d41b1f7b95f
Cancelling all HTTP connections on account disconnect or app shutdown
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33447
diff
changeset
|
1634 | 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
|
1635 | 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
|
1636 | 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
|
1637 | 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
|
1638 | hc->gc = gc; |
|
4d41b1f7b95f
Cancelling all HTTP connections on account disconnect or app shutdown
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33447
diff
changeset
|
1639 | } |
|
4d41b1f7b95f
Cancelling all HTTP connections on account disconnect or app shutdown
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33447
diff
changeset
|
1640 | |
|
33427
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
1641 | return hc; |
|
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
1642 | } |
|
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
1643 | |
|
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
1644 | 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
|
1645 | { |
|
33450
4042907bcdf1
Timeout support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33448
diff
changeset
|
1646 | if (hc->timeout_handle) |
|
4042907bcdf1
Timeout support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33448
diff
changeset
|
1647 | 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
|
1648 | 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
|
1649 | purple_timeout_remove(hc->watcher_delayed_handle); |
|
33450
4042907bcdf1
Timeout support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33448
diff
changeset
|
1650 | |
|
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
|
1651 | 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
|
1652 | 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
|
1653 | |
|
33429
1ce1faf4e675
Extend URL parsing
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33427
diff
changeset
|
1654 | purple_http_url_free(hc->url); |
|
1ce1faf4e675
Extend URL parsing
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33427
diff
changeset
|
1655 | 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
|
1656 | purple_http_response_free(hc->response); |
|
33430
013c5aebb665
Let's connect
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33429
diff
changeset
|
1657 | |
|
33466
918507303f45
HTTP API: PurpleHttpContentReader support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33464
diff
changeset
|
1658 | if (hc->contents_reader_buffer) |
|
918507303f45
HTTP API: PurpleHttpContentReader support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33464
diff
changeset
|
1659 | 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
|
1660 | purple_http_gz_free(hc->gz_stream); |
|
33466
918507303f45
HTTP API: PurpleHttpContentReader support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33464
diff
changeset
|
1661 | |
|
33431
704de181d1d2
Let's request
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33430
diff
changeset
|
1662 | if (hc->request_header) |
|
704de181d1d2
Let's request
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33430
diff
changeset
|
1663 | g_string_free(hc->request_header, TRUE); |
|
704de181d1d2
Let's request
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33430
diff
changeset
|
1664 | |
|
33448
4d41b1f7b95f
Cancelling all HTTP connections on account disconnect or app shutdown
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33447
diff
changeset
|
1665 | 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
|
1666 | hc->link_global); |
|
4d41b1f7b95f
Cancelling all HTTP connections on account disconnect or app shutdown
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33447
diff
changeset
|
1667 | 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
|
1668 | if (hc->gc) { |
|
4d41b1f7b95f
Cancelling all HTTP connections on account disconnect or app shutdown
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33447
diff
changeset
|
1669 | 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
|
1670 | 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
|
1671 | 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
|
1672 | |
|
4d41b1f7b95f
Cancelling all HTTP connections on account disconnect or app shutdown
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33447
diff
changeset
|
1673 | 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
|
1674 | 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
|
1675 | 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
|
1676 | 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
|
1677 | 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
|
1678 | 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
|
1679 | } |
|
4d41b1f7b95f
Cancelling all HTTP connections on account disconnect or app shutdown
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33447
diff
changeset
|
1680 | } |
|
4d41b1f7b95f
Cancelling all HTTP connections on account disconnect or app shutdown
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33447
diff
changeset
|
1681 | |
|
33427
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
1682 | g_free(hc); |
|
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
1683 | } |
|
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
1684 | |
|
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
1685 | /* call callback and do the cleanup */ |
|
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
1686 | 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
|
1687 | { |
|
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
1688 | g_return_if_fail(hc != NULL); |
|
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
1689 | |
|
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
1690 | 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
|
1691 | 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
|
1692 | "successfully" : "without success"); |
|
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
1693 | |
|
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
1694 | if (hc->callback) |
|
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
1695 | 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
|
1696 | |
|
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
1697 | purple_http_connection_free(hc); |
|
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
1698 | } |
|
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
1699 | |
|
33430
013c5aebb665
Let's connect
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33429
diff
changeset
|
1700 | void purple_http_conn_cancel(PurpleHttpConnection *http_conn) |
|
013c5aebb665
Let's connect
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33429
diff
changeset
|
1701 | { |
|
33464
9605c0a2839e
Don't crash when cancelling non-existent HTTP connection
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33462
diff
changeset
|
1702 | if (http_conn == NULL) |
|
9605c0a2839e
Don't crash when cancelling non-existent HTTP connection
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33462
diff
changeset
|
1703 | return; |
|
9605c0a2839e
Don't crash when cancelling non-existent HTTP connection
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33462
diff
changeset
|
1704 | |
|
34263
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
1705 | if (http_conn->is_cancelling) |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
1706 | return; |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
1707 | http_conn->is_cancelling = TRUE; |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
1708 | |
|
34260
7a55eaa31da6
HTTP: implement keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34257
diff
changeset
|
1709 | if (purple_debug_is_verbose()) { |
|
7a55eaa31da6
HTTP: implement keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34257
diff
changeset
|
1710 | purple_debug_misc("http", "Cancelling connection %p...\n", |
|
7a55eaa31da6
HTTP: implement keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34257
diff
changeset
|
1711 | http_conn); |
|
7a55eaa31da6
HTTP: implement keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34257
diff
changeset
|
1712 | } |
|
7a55eaa31da6
HTTP: implement keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34257
diff
changeset
|
1713 | |
|
33430
013c5aebb665
Let's connect
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33429
diff
changeset
|
1714 | http_conn->response->code = 0; |
|
34260
7a55eaa31da6
HTTP: implement keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34257
diff
changeset
|
1715 | _purple_http_disconnect(http_conn, FALSE); |
|
33430
013c5aebb665
Let's connect
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33429
diff
changeset
|
1716 | purple_http_connection_terminate(http_conn); |
|
013c5aebb665
Let's connect
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33429
diff
changeset
|
1717 | } |
|
013c5aebb665
Let's connect
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33429
diff
changeset
|
1718 | |
|
34260
7a55eaa31da6
HTTP: implement keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34257
diff
changeset
|
1719 | static void |
|
7a55eaa31da6
HTTP: implement keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34257
diff
changeset
|
1720 | purple_http_conn_retry(PurpleHttpConnection *http_conn) |
|
7a55eaa31da6
HTTP: implement keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34257
diff
changeset
|
1721 | { |
|
7a55eaa31da6
HTTP: implement keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34257
diff
changeset
|
1722 | if (http_conn == NULL) |
|
7a55eaa31da6
HTTP: implement keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34257
diff
changeset
|
1723 | return; |
|
7a55eaa31da6
HTTP: implement keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34257
diff
changeset
|
1724 | |
|
7a55eaa31da6
HTTP: implement keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34257
diff
changeset
|
1725 | 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
|
1726 | |
|
7a55eaa31da6
HTTP: implement keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34257
diff
changeset
|
1727 | http_conn->response->code = 0; |
|
7a55eaa31da6
HTTP: implement keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34257
diff
changeset
|
1728 | _purple_http_disconnect(http_conn, FALSE); |
|
7a55eaa31da6
HTTP: implement keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34257
diff
changeset
|
1729 | _purple_http_reconnect(http_conn); |
|
7a55eaa31da6
HTTP: implement keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34257
diff
changeset
|
1730 | } |
|
7a55eaa31da6
HTTP: implement keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34257
diff
changeset
|
1731 | |
|
33427
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
1732 | 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
|
1733 | { |
|
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
|
1734 | 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
|
1735 | |
|
e6de87604147
HTTP: get rid of the second msn's own HTTP implementation (for soap)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34263
diff
changeset
|
1736 | 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
|
1737 | 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
|
1738 | "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
|
1739 | } |
|
e6de87604147
HTTP: get rid of the second msn's own HTTP implementation (for soap)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34263
diff
changeset
|
1740 | |
|
e6de87604147
HTTP: get rid of the second msn's own HTTP implementation (for soap)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34263
diff
changeset
|
1741 | 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
|
1742 | |
|
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 | 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
|
1744 | |
|
33448
4d41b1f7b95f
Cancelling all HTTP connections on account disconnect or app shutdown
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33447
diff
changeset
|
1745 | while (gc_list) { |
|
4d41b1f7b95f
Cancelling all HTTP connections on account disconnect or app shutdown
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33447
diff
changeset
|
1746 | 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
|
1747 | 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
|
1748 | 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
|
1749 | } |
|
4d41b1f7b95f
Cancelling all HTTP connections on account disconnect or app shutdown
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33447
diff
changeset
|
1750 | |
|
34262
3b8ce83bac96
HTTP: get rid of one (of two) msn's own http implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34261
diff
changeset
|
1751 | 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
|
1752 | |
|
33448
4d41b1f7b95f
Cancelling all HTTP connections on account disconnect or app shutdown
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33447
diff
changeset
|
1753 | 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
|
1754 | 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
|
1755 | "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
|
1756 | } |
|
4d41b1f7b95f
Cancelling all HTTP connections on account disconnect or app shutdown
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33447
diff
changeset
|
1757 | |
|
37366
1cbcea2165c1
facebook: ignore canceling HTTP requests
James Geboski <jgeboski@gmail.com>
parents:
36047
diff
changeset
|
1758 | gboolean purple_http_conn_is_cancelling(PurpleHttpConnection *http_conn) |
|
1cbcea2165c1
facebook: ignore canceling HTTP requests
James Geboski <jgeboski@gmail.com>
parents:
36047
diff
changeset
|
1759 | { |
|
1cbcea2165c1
facebook: ignore canceling HTTP requests
James Geboski <jgeboski@gmail.com>
parents:
36047
diff
changeset
|
1760 | if (http_conn == NULL) |
|
1cbcea2165c1
facebook: ignore canceling HTTP requests
James Geboski <jgeboski@gmail.com>
parents:
36047
diff
changeset
|
1761 | return FALSE; |
|
1cbcea2165c1
facebook: ignore canceling HTTP requests
James Geboski <jgeboski@gmail.com>
parents:
36047
diff
changeset
|
1762 | return http_conn->is_cancelling; |
|
1cbcea2165c1
facebook: ignore canceling HTTP requests
James Geboski <jgeboski@gmail.com>
parents:
36047
diff
changeset
|
1763 | } |
|
1cbcea2165c1
facebook: ignore canceling HTTP requests
James Geboski <jgeboski@gmail.com>
parents:
36047
diff
changeset
|
1764 | |
|
33448
4d41b1f7b95f
Cancelling all HTTP connections on account disconnect or app shutdown
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33447
diff
changeset
|
1765 | 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
|
1766 | { |
|
4d41b1f7b95f
Cancelling all HTTP connections on account disconnect or app shutdown
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33447
diff
changeset
|
1767 | 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
|
1768 | return FALSE; |
|
4d41b1f7b95f
Cancelling all HTTP connections on account disconnect or app shutdown
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33447
diff
changeset
|
1769 | 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
|
1770 | } |
|
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
1771 | |
|
33451
27d0e5dbc2a1
Implement missing getters/setters and corresponding features
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33450
diff
changeset
|
1772 | 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
|
1773 | { |
|
27d0e5dbc2a1
Implement missing getters/setters and corresponding features
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33450
diff
changeset
|
1774 | 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
|
1775 | |
|
27d0e5dbc2a1
Implement missing getters/setters and corresponding features
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33450
diff
changeset
|
1776 | return http_conn->request; |
|
27d0e5dbc2a1
Implement missing getters/setters and corresponding features
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33450
diff
changeset
|
1777 | } |
|
27d0e5dbc2a1
Implement missing getters/setters and corresponding features
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33450
diff
changeset
|
1778 | |
|
33456
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
1779 | PurpleHttpCookieJar * purple_http_conn_get_cookie_jar( |
|
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
1780 | PurpleHttpConnection *http_conn) |
|
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
1781 | { |
|
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
1782 | 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
|
1783 | http_conn)); |
|
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
1784 | } |
|
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
1785 | |
|
33451
27d0e5dbc2a1
Implement missing getters/setters and corresponding features
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33450
diff
changeset
|
1786 | 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
|
1787 | PurpleHttpConnection *http_conn) |
|
27d0e5dbc2a1
Implement missing getters/setters and corresponding features
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33450
diff
changeset
|
1788 | { |
|
27d0e5dbc2a1
Implement missing getters/setters and corresponding features
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33450
diff
changeset
|
1789 | 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
|
1790 | |
|
27d0e5dbc2a1
Implement missing getters/setters and corresponding features
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33450
diff
changeset
|
1791 | return http_conn->gc; |
|
27d0e5dbc2a1
Implement missing getters/setters and corresponding features
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33450
diff
changeset
|
1792 | } |
|
27d0e5dbc2a1
Implement missing getters/setters and corresponding features
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33450
diff
changeset
|
1793 | |
|
33468
b057fee9d11a
HTTP progress watcher support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33466
diff
changeset
|
1794 | 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
|
1795 | 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
|
1796 | gint interval_threshold) |
|
33468
b057fee9d11a
HTTP progress watcher support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33466
diff
changeset
|
1797 | { |
|
b057fee9d11a
HTTP progress watcher support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33466
diff
changeset
|
1798 | g_return_if_fail(http_conn != NULL); |
|
b057fee9d11a
HTTP progress watcher support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33466
diff
changeset
|
1799 | |
|
34272
8df870b218ca
HTTP: chop off another HTTP implementation (for xmpp oob file transfers)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34268
diff
changeset
|
1800 | 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
|
1801 | interval_threshold = |
|
8df870b218ca
HTTP: chop off another HTTP implementation (for xmpp oob file transfers)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34268
diff
changeset
|
1802 | 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
|
1803 | } |
|
8df870b218ca
HTTP: chop off another HTTP implementation (for xmpp oob file transfers)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34268
diff
changeset
|
1804 | |
|
33468
b057fee9d11a
HTTP progress watcher support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33466
diff
changeset
|
1805 | http_conn->watcher = watcher; |
|
b057fee9d11a
HTTP progress watcher support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33466
diff
changeset
|
1806 | http_conn->watcher_user_data = user_data; |
|
b057fee9d11a
HTTP progress watcher support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33466
diff
changeset
|
1807 | http_conn->watcher_interval_threshold = interval_threshold; |
|
b057fee9d11a
HTTP progress watcher support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33466
diff
changeset
|
1808 | } |
|
b057fee9d11a
HTTP progress watcher support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33466
diff
changeset
|
1809 | |
|
b057fee9d11a
HTTP progress watcher support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33466
diff
changeset
|
1810 | static void purple_http_conn_notify_progress_watcher( |
|
b057fee9d11a
HTTP progress watcher support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33466
diff
changeset
|
1811 | PurpleHttpConnection *hc) |
|
b057fee9d11a
HTTP progress watcher support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33466
diff
changeset
|
1812 | { |
|
b057fee9d11a
HTTP progress watcher support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33466
diff
changeset
|
1813 | gint64 now; |
|
b057fee9d11a
HTTP progress watcher support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33466
diff
changeset
|
1814 | gboolean reading_state; |
|
b057fee9d11a
HTTP progress watcher support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33466
diff
changeset
|
1815 | int processed, total; |
|
b057fee9d11a
HTTP progress watcher support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33466
diff
changeset
|
1816 | |
|
b057fee9d11a
HTTP progress watcher support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33466
diff
changeset
|
1817 | g_return_if_fail(hc != NULL); |
|
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 | if (hc->watcher == NULL) |
|
b057fee9d11a
HTTP progress watcher support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33466
diff
changeset
|
1820 | return; |
|
b057fee9d11a
HTTP progress watcher support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33466
diff
changeset
|
1821 | |
|
b057fee9d11a
HTTP progress watcher support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33466
diff
changeset
|
1822 | reading_state = hc->is_reading; |
|
b057fee9d11a
HTTP progress watcher support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33466
diff
changeset
|
1823 | if (reading_state) { |
|
b057fee9d11a
HTTP progress watcher support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33466
diff
changeset
|
1824 | total = hc->length_expected; |
|
b057fee9d11a
HTTP progress watcher support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33466
diff
changeset
|
1825 | processed = hc->length_got; |
|
b057fee9d11a
HTTP progress watcher support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33466
diff
changeset
|
1826 | } else { |
|
b057fee9d11a
HTTP progress watcher support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33466
diff
changeset
|
1827 | total = hc->request->contents_length; |
|
b057fee9d11a
HTTP progress watcher support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33466
diff
changeset
|
1828 | processed = hc->request_contents_written; |
|
b057fee9d11a
HTTP progress watcher support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33466
diff
changeset
|
1829 | if (total == 0) |
|
b057fee9d11a
HTTP progress watcher support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33466
diff
changeset
|
1830 | total = -1; |
|
b057fee9d11a
HTTP progress watcher support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33466
diff
changeset
|
1831 | } |
|
b057fee9d11a
HTTP progress watcher support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33466
diff
changeset
|
1832 | if (total != -1 && total < processed) { |
|
b057fee9d11a
HTTP progress watcher support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33466
diff
changeset
|
1833 | purple_debug_warning("http", "Processed too much\n"); |
|
b057fee9d11a
HTTP progress watcher support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33466
diff
changeset
|
1834 | total = processed; |
|
b057fee9d11a
HTTP progress watcher support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33466
diff
changeset
|
1835 | } |
|
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 | now = g_get_monotonic_time(); |
|
b057fee9d11a
HTTP progress watcher support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33466
diff
changeset
|
1838 | if (hc->watcher_last_call + hc->watcher_interval_threshold |
|
35362
a6223370667b
Style: fix braces for http, keyring
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35352
diff
changeset
|
1839 | > now && processed != total) |
|
a6223370667b
Style: fix braces for http, keyring
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35352
diff
changeset
|
1840 | { |
|
33521
43c34cda245d
HTTP: don't forget to notify about progress before connection freeze
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33517
diff
changeset
|
1841 | 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
|
1842 | return; |
|
43c34cda245d
HTTP: don't forget to notify about progress before connection freeze
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33517
diff
changeset
|
1843 | 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
|
1844 | 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
|
1845 | purple_http_conn_notify_progress_watcher_timeout, hc); |
|
33468
b057fee9d11a
HTTP progress watcher support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33466
diff
changeset
|
1846 | return; |
|
33521
43c34cda245d
HTTP: don't forget to notify about progress before connection freeze
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33517
diff
changeset
|
1847 | } |
|
43c34cda245d
HTTP: don't forget to notify about progress before connection freeze
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33517
diff
changeset
|
1848 | |
|
43c34cda245d
HTTP: don't forget to notify about progress before connection freeze
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33517
diff
changeset
|
1849 | 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
|
1850 | 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
|
1851 | 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
|
1852 | |
|
33468
b057fee9d11a
HTTP progress watcher support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33466
diff
changeset
|
1853 | hc->watcher_last_call = now; |
|
b057fee9d11a
HTTP progress watcher support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33466
diff
changeset
|
1854 | 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
|
1855 | } |
|
b057fee9d11a
HTTP progress watcher support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33466
diff
changeset
|
1856 | |
|
33521
43c34cda245d
HTTP: don't forget to notify about progress before connection freeze
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33517
diff
changeset
|
1857 | 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
|
1858 | { |
|
43c34cda245d
HTTP: don't forget to notify about progress before connection freeze
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33517
diff
changeset
|
1859 | 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
|
1860 | |
|
43c34cda245d
HTTP: don't forget to notify about progress before connection freeze
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33517
diff
changeset
|
1861 | 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
|
1862 | |
|
43c34cda245d
HTTP: don't forget to notify about progress before connection freeze
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33517
diff
changeset
|
1863 | return FALSE; |
|
43c34cda245d
HTTP: don't forget to notify about progress before connection freeze
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33517
diff
changeset
|
1864 | } |
|
43c34cda245d
HTTP: don't forget to notify about progress before connection freeze
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33517
diff
changeset
|
1865 | |
|
33456
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
1866 | /*** Cookie jar API ***********************************************************/ |
|
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
1867 | |
|
33459
722a6d753cb2
Better cookies, better chunked transfer support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33458
diff
changeset
|
1868 | 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
|
1869 | void purple_http_cookie_free(PurpleHttpCookie *cookie); |
|
722a6d753cb2
Better cookies, better chunked transfer support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33458
diff
changeset
|
1870 | |
|
722a6d753cb2
Better cookies, better chunked transfer support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33458
diff
changeset
|
1871 | 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
|
1872 | 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
|
1873 | |
|
722a6d753cb2
Better cookies, better chunked transfer support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33458
diff
changeset
|
1874 | 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
|
1875 | { |
|
722a6d753cb2
Better cookies, better chunked transfer support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33458
diff
changeset
|
1876 | PurpleHttpCookie *cookie = g_new0(PurpleHttpCookie, 1); |
|
722a6d753cb2
Better cookies, better chunked transfer support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33458
diff
changeset
|
1877 | |
|
722a6d753cb2
Better cookies, better chunked transfer support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33458
diff
changeset
|
1878 | cookie->value = g_strdup(value); |
|
722a6d753cb2
Better cookies, better chunked transfer support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33458
diff
changeset
|
1879 | cookie->expires = -1; |
|
722a6d753cb2
Better cookies, better chunked transfer support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33458
diff
changeset
|
1880 | |
|
722a6d753cb2
Better cookies, better chunked transfer support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33458
diff
changeset
|
1881 | return cookie; |
|
722a6d753cb2
Better cookies, better chunked transfer support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33458
diff
changeset
|
1882 | } |
|
722a6d753cb2
Better cookies, better chunked transfer support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33458
diff
changeset
|
1883 | |
|
722a6d753cb2
Better cookies, better chunked transfer support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33458
diff
changeset
|
1884 | void purple_http_cookie_free(PurpleHttpCookie *cookie) |
|
722a6d753cb2
Better cookies, better chunked transfer support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33458
diff
changeset
|
1885 | { |
|
722a6d753cb2
Better cookies, better chunked transfer support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33458
diff
changeset
|
1886 | g_free(cookie->value); |
|
722a6d753cb2
Better cookies, better chunked transfer support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33458
diff
changeset
|
1887 | g_free(cookie); |
|
722a6d753cb2
Better cookies, better chunked transfer support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33458
diff
changeset
|
1888 | } |
|
722a6d753cb2
Better cookies, better chunked transfer support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33458
diff
changeset
|
1889 | |
|
33456
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
1890 | void purple_http_cookie_jar_free(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 | PurpleHttpCookieJar * purple_http_cookie_jar_new(void) |
|
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 | PurpleHttpCookieJar *cjar = g_new0(PurpleHttpCookieJar, 1); |
|
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 | cjar->ref_count = 1; |
|
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
1897 | 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
|
1898 | (GDestroyNotify)purple_http_cookie_free); |
|
33456
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 | return cjar; |
|
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
1901 | } |
|
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 | void purple_http_cookie_jar_free(PurpleHttpCookieJar *cookie_jar) |
|
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 | g_hash_table_destroy(cookie_jar->tab); |
|
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
1906 | g_free(cookie_jar); |
|
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
1907 | } |
|
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 | void purple_http_cookie_jar_ref(PurpleHttpCookieJar *cookie_jar) |
|
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
1910 | { |
|
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
1911 | g_return_if_fail(cookie_jar != NULL); |
|
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 | cookie_jar->ref_count++; |
|
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
1914 | } |
|
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 | PurpleHttpCookieJar * purple_http_cookie_jar_unref( |
|
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
1917 | PurpleHttpCookieJar *cookie_jar) |
|
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
1918 | { |
|
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
1919 | if (cookie_jar == NULL) |
|
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
1920 | return NULL; |
|
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
1921 | |
|
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
1922 | 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
|
1923 | |
|
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
1924 | cookie_jar->ref_count--; |
|
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
1925 | if (cookie_jar->ref_count > 0) |
|
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
1926 | return cookie_jar; |
|
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
1927 | |
|
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
1928 | purple_http_cookie_jar_free(cookie_jar); |
|
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
1929 | return NULL; |
|
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
1930 | } |
|
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
1931 | |
|
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
1932 | static void purple_http_cookie_jar_parse(PurpleHttpCookieJar *cookie_jar, |
|
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
1933 | GList *values) |
|
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 | values = g_list_first(values); |
|
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
1936 | while (values) { |
|
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
1937 | const gchar *cookie = values->data; |
|
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
1938 | const gchar *eqsign, *semicolon; |
|
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
1939 | gchar *name, *value; |
|
33460
c37dd51516aa
Deleting (or expiring) a cookie
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33459
diff
changeset
|
1940 | time_t expires = -1; |
|
33456
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
1941 | values = g_list_next(values); |
|
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
1942 | |
|
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
1943 | eqsign = strchr(cookie, '='); |
|
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
1944 | semicolon = strchr(cookie, ';'); |
|
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
1945 | |
|
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
1946 | if (eqsign == NULL || eqsign == cookie || |
|
35362
a6223370667b
Style: fix braces for http, keyring
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35352
diff
changeset
|
1947 | (semicolon != NULL && semicolon < eqsign)) |
|
a6223370667b
Style: fix braces for http, keyring
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35352
diff
changeset
|
1948 | { |
|
33456
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
1949 | if (purple_debug_is_unsafe()) |
|
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
1950 | purple_debug_warning("http", |
|
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
1951 | "Invalid cookie: [%s]\n", cookie); |
|
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
1952 | else |
|
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
1953 | purple_debug_warning("http", "Invalid cookie."); |
|
36047
2d7d55acd82c
Coverity: fix null pointer dereferences
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35475
diff
changeset
|
1954 | continue; |
|
33456
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
1955 | } |
|
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
1956 | |
|
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
1957 | name = g_strndup(cookie, eqsign - cookie); |
|
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
1958 | eqsign++; |
|
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
1959 | if (semicolon != NULL) |
|
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
1960 | value = g_strndup(eqsign, semicolon - eqsign); |
|
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
1961 | else |
|
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
1962 | value = g_strdup(eqsign); |
|
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
1963 | |
|
33459
722a6d753cb2
Better cookies, better chunked transfer support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33458
diff
changeset
|
1964 | if (semicolon != NULL) { |
|
33460
c37dd51516aa
Deleting (or expiring) a cookie
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33459
diff
changeset
|
1965 | GMatchInfo *match_info; |
|
36047
2d7d55acd82c
Coverity: fix null pointer dereferences
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35475
diff
changeset
|
1966 | GRegex *re_expires = g_regex_new( /* XXX: make it static */ |
|
33460
c37dd51516aa
Deleting (or expiring) a cookie
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33459
diff
changeset
|
1967 | "expires=([a-z0-9, :]+)", |
|
c37dd51516aa
Deleting (or expiring) a cookie
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33459
diff
changeset
|
1968 | G_REGEX_OPTIMIZE | G_REGEX_CASELESS, |
|
c37dd51516aa
Deleting (or expiring) a cookie
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33459
diff
changeset
|
1969 | G_REGEX_MATCH_NOTEMPTY, NULL); |
|
c37dd51516aa
Deleting (or expiring) a cookie
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33459
diff
changeset
|
1970 | |
|
c37dd51516aa
Deleting (or expiring) a cookie
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33459
diff
changeset
|
1971 | 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
|
1972 | if (g_match_info_matches(match_info)) { |
|
c37dd51516aa
Deleting (or expiring) a cookie
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33459
diff
changeset
|
1973 | gchar *expire_date = |
|
c37dd51516aa
Deleting (or expiring) a cookie
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33459
diff
changeset
|
1974 | g_match_info_fetch(match_info, 1); |
|
c37dd51516aa
Deleting (or expiring) a cookie
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33459
diff
changeset
|
1975 | expires = purple_http_rfc1123_to_time( |
|
c37dd51516aa
Deleting (or expiring) a cookie
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33459
diff
changeset
|
1976 | expire_date); |
|
c37dd51516aa
Deleting (or expiring) a cookie
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33459
diff
changeset
|
1977 | g_free(expire_date); |
|
c37dd51516aa
Deleting (or expiring) a cookie
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33459
diff
changeset
|
1978 | } |
|
c37dd51516aa
Deleting (or expiring) a cookie
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33459
diff
changeset
|
1979 | g_match_info_free(match_info); |
|
c37dd51516aa
Deleting (or expiring) a cookie
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33459
diff
changeset
|
1980 | |
|
c37dd51516aa
Deleting (or expiring) a cookie
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33459
diff
changeset
|
1981 | g_regex_unref(re_expires); |
|
33459
722a6d753cb2
Better cookies, better chunked transfer support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33458
diff
changeset
|
1982 | } |
|
722a6d753cb2
Better cookies, better chunked transfer support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33458
diff
changeset
|
1983 | |
|
33460
c37dd51516aa
Deleting (or expiring) a cookie
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33459
diff
changeset
|
1984 | 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
|
1985 | |
|
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
1986 | g_free(name); |
|
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
1987 | g_free(value); |
|
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
1988 | } |
|
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
1989 | } |
|
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
1990 | |
|
33458
59b3364f690e
Sending cookies
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33457
diff
changeset
|
1991 | static gchar * purple_http_cookie_jar_gen(PurpleHttpCookieJar *cookie_jar) |
|
59b3364f690e
Sending cookies
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33457
diff
changeset
|
1992 | { |
|
59b3364f690e
Sending cookies
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33457
diff
changeset
|
1993 | GHashTableIter it; |
|
33459
722a6d753cb2
Better cookies, better chunked transfer support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33458
diff
changeset
|
1994 | gchar *key; |
|
722a6d753cb2
Better cookies, better chunked transfer support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33458
diff
changeset
|
1995 | PurpleHttpCookie *cookie; |
|
33458
59b3364f690e
Sending cookies
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33457
diff
changeset
|
1996 | GString *str; |
|
33460
c37dd51516aa
Deleting (or expiring) a cookie
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33459
diff
changeset
|
1997 | time_t now = time(NULL); |
|
33458
59b3364f690e
Sending cookies
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33457
diff
changeset
|
1998 | |
|
59b3364f690e
Sending cookies
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33457
diff
changeset
|
1999 | g_return_val_if_fail(cookie_jar != NULL, NULL); |
|
59b3364f690e
Sending cookies
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33457
diff
changeset
|
2000 | |
|
59b3364f690e
Sending cookies
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33457
diff
changeset
|
2001 | str = g_string_new(""); |
|
59b3364f690e
Sending cookies
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33457
diff
changeset
|
2002 | |
|
59b3364f690e
Sending cookies
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33457
diff
changeset
|
2003 | 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
|
2004 | while (g_hash_table_iter_next(&it, (gpointer*)&key, |
|
35362
a6223370667b
Style: fix braces for http, keyring
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35352
diff
changeset
|
2005 | (gpointer*)&cookie)) |
|
a6223370667b
Style: fix braces for http, keyring
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35352
diff
changeset
|
2006 | { |
|
33460
c37dd51516aa
Deleting (or expiring) a cookie
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33459
diff
changeset
|
2007 | if (cookie->expires != -1 && cookie->expires <= now) |
|
c37dd51516aa
Deleting (or expiring) a cookie
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33459
diff
changeset
|
2008 | continue; |
|
33459
722a6d753cb2
Better cookies, better chunked transfer support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33458
diff
changeset
|
2009 | 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
|
2010 | } |
|
33458
59b3364f690e
Sending cookies
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33457
diff
changeset
|
2011 | |
|
59b3364f690e
Sending cookies
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33457
diff
changeset
|
2012 | if (str->len > 0) |
|
59b3364f690e
Sending cookies
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33457
diff
changeset
|
2013 | g_string_truncate(str, str->len - 2); |
|
59b3364f690e
Sending cookies
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33457
diff
changeset
|
2014 | return g_string_free(str, FALSE); |
|
59b3364f690e
Sending cookies
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33457
diff
changeset
|
2015 | } |
|
59b3364f690e
Sending cookies
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33457
diff
changeset
|
2016 | |
|
33456
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
2017 | void purple_http_cookie_jar_set(PurpleHttpCookieJar *cookie_jar, |
|
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
2018 | const gchar *name, const gchar *value) |
|
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
2019 | { |
|
33459
722a6d753cb2
Better cookies, better chunked transfer support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33458
diff
changeset
|
2020 | 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
|
2021 | } |
|
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 | 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
|
2024 | 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
|
2025 | { |
|
33456
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
2026 | g_return_if_fail(cookie_jar != NULL); |
|
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
2027 | g_return_if_fail(name != NULL); |
|
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
2028 | |
|
33460
c37dd51516aa
Deleting (or expiring) a cookie
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33459
diff
changeset
|
2029 | if (expires != -1 && time(NULL) >= expires) |
|
33459
722a6d753cb2
Better cookies, better chunked transfer support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33458
diff
changeset
|
2030 | value = NULL; |
|
722a6d753cb2
Better cookies, better chunked transfer support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33458
diff
changeset
|
2031 | |
|
722a6d753cb2
Better cookies, better chunked transfer support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33458
diff
changeset
|
2032 | if (value != NULL) { |
|
722a6d753cb2
Better cookies, better chunked transfer support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33458
diff
changeset
|
2033 | PurpleHttpCookie *cookie = purple_http_cookie_new(value); |
|
722a6d753cb2
Better cookies, better chunked transfer support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33458
diff
changeset
|
2034 | cookie->expires = expires; |
|
722a6d753cb2
Better cookies, better chunked transfer support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33458
diff
changeset
|
2035 | 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
|
2036 | } else |
|
33456
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
2037 | g_hash_table_remove(cookie_jar->tab, name); |
|
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
2038 | } |
|
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 | const gchar * purple_http_cookie_jar_get(PurpleHttpCookieJar *cookie_jar, |
|
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
2041 | const gchar *name) |
|
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
2042 | { |
|
33459
722a6d753cb2
Better cookies, better chunked transfer support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33458
diff
changeset
|
2043 | PurpleHttpCookie *cookie; |
|
722a6d753cb2
Better cookies, better chunked transfer support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33458
diff
changeset
|
2044 | |
|
722a6d753cb2
Better cookies, better chunked transfer support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33458
diff
changeset
|
2045 | 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
|
2046 | 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
|
2047 | |
|
722a6d753cb2
Better cookies, better chunked transfer support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33458
diff
changeset
|
2048 | 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
|
2049 | if (!cookie) |
|
722a6d753cb2
Better cookies, better chunked transfer support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33458
diff
changeset
|
2050 | return NULL; |
|
722a6d753cb2
Better cookies, better chunked transfer support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33458
diff
changeset
|
2051 | |
|
722a6d753cb2
Better cookies, better chunked transfer support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33458
diff
changeset
|
2052 | return cookie->value; |
|
33456
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 | |
|
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
2055 | gchar * purple_http_cookie_jar_dump(PurpleHttpCookieJar *cjar) |
|
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
2056 | { |
|
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
2057 | GHashTableIter it; |
|
33459
722a6d753cb2
Better cookies, better chunked transfer support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33458
diff
changeset
|
2058 | gchar *key; |
|
722a6d753cb2
Better cookies, better chunked transfer support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33458
diff
changeset
|
2059 | PurpleHttpCookie *cookie; |
|
33456
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
2060 | GString *str = g_string_new(""); |
|
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
2061 | |
|
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
2062 | 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
|
2063 | 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
|
2064 | 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
|
2065 | ")\n", key, cookie->value, (gint64)cookie->expires); |
|
33456
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
2066 | |
|
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
2067 | if (str->len > 0) |
|
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
2068 | g_string_truncate(str, str->len - 1); |
|
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
2069 | return g_string_free(str, FALSE); |
|
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
2070 | } |
|
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
2071 | |
|
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
2072 | gboolean purple_http_cookie_jar_is_empty(PurpleHttpCookieJar *cookie_jar) |
|
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
2073 | { |
|
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
2074 | g_return_val_if_fail(cookie_jar != NULL, TRUE); |
|
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
2075 | |
|
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
2076 | return g_hash_table_size(cookie_jar->tab) == 0; |
|
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
2077 | } |
|
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
2078 | |
|
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
|
2079 | /*** 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
|
2080 | |
|
34260
7a55eaa31da6
HTTP: implement keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34257
diff
changeset
|
2081 | static void |
|
34263
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
2082 | 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
|
2083 | |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
2084 | static void |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
2085 | purple_http_keepalive_host_free(gpointer _host) |
|
34260
7a55eaa31da6
HTTP: implement keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34257
diff
changeset
|
2086 | { |
|
34263
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
2087 | PurpleHttpKeepaliveHost *host = _host; |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
2088 | |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
2089 | g_free(host->host); |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
2090 | |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
2091 | g_slist_free_full(host->queue, |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
2092 | (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
|
2093 | g_slist_free_full(host->sockets, |
|
34260
7a55eaa31da6
HTTP: implement keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34257
diff
changeset
|
2094 | (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
|
2095 | |
|
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
|
2096 | 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
|
2097 | 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
|
2098 | 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
|
2099 | } |
|
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
|
2100 | |
|
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
|
2101 | |
|
34263
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
2102 | g_free(host); |
|
34260
7a55eaa31da6
HTTP: implement keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34257
diff
changeset
|
2103 | } |
|
7a55eaa31da6
HTTP: implement keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34257
diff
changeset
|
2104 | |
|
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
|
2105 | 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
|
2106 | 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
|
2107 | { |
|
935120490eb2
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 | 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
|
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 | pool->ref_count = 1; |
|
34260
7a55eaa31da6
HTTP: implement keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34257
diff
changeset
|
2111 | 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
|
2112 | 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
|
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 | 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
|
2115 | } |
|
935120490eb2
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 | |
|
935120490eb2
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 | 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
|
2118 | 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
|
2119 | { |
|
935120490eb2
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 | 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
|
2121 | |
|
34263
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
2122 | if (pool->is_destroying) |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
2123 | return; |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
2124 | pool->is_destroying = TRUE; |
|
34260
7a55eaa31da6
HTTP: implement keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34257
diff
changeset
|
2125 | 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
|
2126 | 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
|
2127 | } |
|
935120490eb2
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 | |
|
935120490eb2
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 | 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
|
2130 | 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
|
2131 | { |
|
935120490eb2
HTTP: isolate socket-related code in http module; initial implementation for keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34234
diff
changeset
|
2132 | 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
|
2133 | |
|
935120490eb2
HTTP: isolate socket-related code in http module; initial implementation for keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34234
diff
changeset
|
2134 | 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
|
2135 | } |
|
935120490eb2
HTTP: isolate socket-related code in http module; initial implementation for keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34234
diff
changeset
|
2136 | |
|
935120490eb2
HTTP: isolate socket-related code in http module; initial implementation for keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34234
diff
changeset
|
2137 | 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
|
2138 | 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
|
2139 | { |
|
935120490eb2
HTTP: isolate socket-related code in http module; initial implementation for keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34234
diff
changeset
|
2140 | 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
|
2141 | 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
|
2142 | |
|
935120490eb2
HTTP: isolate socket-related code in http module; initial implementation for keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34234
diff
changeset
|
2143 | 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
|
2144 | |
|
935120490eb2
HTTP: isolate socket-related code in http module; initial implementation for keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34234
diff
changeset
|
2145 | 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
|
2146 | 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
|
2147 | 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
|
2148 | |
|
935120490eb2
HTTP: isolate socket-related code in http module; initial implementation for keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34234
diff
changeset
|
2149 | 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
|
2150 | 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
|
2151 | } |
|
935120490eb2
HTTP: isolate socket-related code in http module; initial implementation for keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34234
diff
changeset
|
2152 | |
|
34263
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
2153 | static PurpleHttpKeepaliveRequest * |
|
34260
7a55eaa31da6
HTTP: implement keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34257
diff
changeset
|
2154 | purple_http_keepalive_pool_request(PurpleHttpKeepalivePool *pool, |
|
7a55eaa31da6
HTTP: implement keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34257
diff
changeset
|
2155 | 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
|
2156 | PurpleSocketConnectCb cb, gpointer user_data) |
|
34260
7a55eaa31da6
HTTP: implement keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34257
diff
changeset
|
2157 | { |
|
34263
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
2158 | PurpleHttpKeepaliveRequest *req; |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
2159 | PurpleHttpKeepaliveHost *kahost; |
|
34260
7a55eaa31da6
HTTP: implement keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34257
diff
changeset
|
2160 | gchar *hash; |
|
34263
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
2161 | |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
2162 | 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
|
2163 | g_return_val_if_fail(host != NULL, NULL); |
|
7a55eaa31da6
HTTP: implement keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34257
diff
changeset
|
2164 | |
|
34263
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
2165 | if (pool->is_destroying) { |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
2166 | 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
|
2167 | return NULL; |
|
34260
7a55eaa31da6
HTTP: implement keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34257
diff
changeset
|
2168 | } |
|
7a55eaa31da6
HTTP: implement keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34257
diff
changeset
|
2169 | |
|
7a55eaa31da6
HTTP: implement keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34257
diff
changeset
|
2170 | 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
|
2171 | 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
|
2172 | |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
2173 | if (kahost == NULL) { |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
2174 | kahost = g_new0(PurpleHttpKeepaliveHost, 1); |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
2175 | kahost->pool = pool; |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
2176 | kahost->host = g_strdup(host); |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
2177 | kahost->port = port; |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
2178 | kahost->is_ssl = is_ssl; |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
2179 | |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
2180 | 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
|
2181 | } |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
2182 | |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
2183 | g_free(hash); |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
2184 | |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
2185 | req = g_new0(PurpleHttpKeepaliveRequest, 1); |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
2186 | req->gc = gc; |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
2187 | req->cb = cb; |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
2188 | req->user_data = user_data; |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
2189 | req->host = kahost; |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
2190 | |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
2191 | 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
|
2192 | |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
2193 | 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
|
2194 | |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
2195 | return req; |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
2196 | } |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
2197 | |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
2198 | static void |
|
34316
2a3a587f5403
HTTP: make use of PurpleSocket
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
34314
diff
changeset
|
2199 | _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
|
2200 | const gchar *error, gpointer _req) |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
2201 | { |
|
34316
2a3a587f5403
HTTP: make use of PurpleSocket
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
34314
diff
changeset
|
2202 | PurpleHttpSocket *hs = NULL; |
|
34263
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
2203 | PurpleHttpKeepaliveRequest *req = _req; |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
2204 | |
|
34316
2a3a587f5403
HTTP: make use of PurpleSocket
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
34314
diff
changeset
|
2205 | if (ps != NULL) |
|
2a3a587f5403
HTTP: make use of PurpleSocket
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
34314
diff
changeset
|
2206 | hs = purple_socket_get_data(ps, "hs"); |
|
2a3a587f5403
HTTP: make use of PurpleSocket
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
34314
diff
changeset
|
2207 | |
|
34263
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
2208 | if (hs != NULL) |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
2209 | hs->use_count++; |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
2210 | |
|
35156
1bc10c44beef
HTTP: fix some clang warnings
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
34516
diff
changeset
|
2211 | req->cb(ps, error, req->user_data); |
|
34263
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
2212 | g_free(req); |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
2213 | } |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
2214 | |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
2215 | static gboolean |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
2216 | _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
|
2217 | { |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
2218 | PurpleHttpKeepaliveRequest *req; |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
2219 | PurpleHttpKeepaliveHost *host = _host; |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
2220 | PurpleHttpSocket *hs = NULL; |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
2221 | GSList *it; |
|
34305
5804117fb298
Fix the rest of libpurple warnings about -Wsign-compare
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34295
diff
changeset
|
2222 | guint sockets_count; |
|
34263
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
2223 | |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
2224 | 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
|
2225 | |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
2226 | host->process_queue_timeout = 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 | if (host->queue == NULL) |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
2229 | return FALSE; |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
2230 | |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
2231 | sockets_count = 0; |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
2232 | it = host->sockets; |
|
34260
7a55eaa31da6
HTTP: implement keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34257
diff
changeset
|
2233 | while (it != NULL) { |
|
7a55eaa31da6
HTTP: implement keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34257
diff
changeset
|
2234 | PurpleHttpSocket *hs_current = it->data; |
|
7a55eaa31da6
HTTP: implement keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34257
diff
changeset
|
2235 | |
|
34263
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
2236 | sockets_count++; |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
2237 | |
|
34260
7a55eaa31da6
HTTP: implement keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34257
diff
changeset
|
2238 | if (!hs_current->is_busy) { |
|
7a55eaa31da6
HTTP: implement keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34257
diff
changeset
|
2239 | hs = hs_current; |
|
7a55eaa31da6
HTTP: implement keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34257
diff
changeset
|
2240 | break; |
|
7a55eaa31da6
HTTP: implement keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34257
diff
changeset
|
2241 | } |
|
7a55eaa31da6
HTTP: implement keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34257
diff
changeset
|
2242 | |
|
7a55eaa31da6
HTTP: implement keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34257
diff
changeset
|
2243 | it = g_slist_next(it); |
|
7a55eaa31da6
HTTP: implement keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34257
diff
changeset
|
2244 | } |
|
7a55eaa31da6
HTTP: implement keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34257
diff
changeset
|
2245 | |
|
34263
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
2246 | /* 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
|
2247 | 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
|
2248 | host->pool->limit_per_host > 0) |
|
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 | return FALSE; |
|
34260
7a55eaa31da6
HTTP: implement keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34257
diff
changeset
|
2251 | } |
|
7a55eaa31da6
HTTP: implement keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34257
diff
changeset
|
2252 | |
|
34263
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
2253 | req = host->queue->data; |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
2254 | 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
|
2255 | |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
2256 | if (hs != NULL) { |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
2257 | if (purple_debug_is_verbose()) { |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
2258 | 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
|
2259 | "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 | |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
2262 | hs->is_busy = TRUE; |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
2263 | hs->use_count++; |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
2264 | |
|
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
|
2265 | 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
|
2266 | |
|
34316
2a3a587f5403
HTTP: make use of PurpleSocket
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
34314
diff
changeset
|
2267 | 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
|
2268 | g_free(req); |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
2269 | |
|
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
|
2270 | return FALSE; |
|
34263
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
2271 | } |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
2272 | |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
2273 | 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
|
2274 | 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
|
2275 | _purple_http_keepalive_socket_connected, req); |
|
35156
1bc10c44beef
HTTP: fix some clang warnings
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
34516
diff
changeset
|
2276 | if (hs == NULL) { |
|
1bc10c44beef
HTTP: fix some clang warnings
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
34516
diff
changeset
|
2277 | purple_debug_error("http", "failed creating new socket"); |
|
1bc10c44beef
HTTP: fix some clang warnings
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
34516
diff
changeset
|
2278 | return FALSE; |
|
1bc10c44beef
HTTP: fix some clang warnings
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
34516
diff
changeset
|
2279 | } |
|
1bc10c44beef
HTTP: fix some clang warnings
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
34516
diff
changeset
|
2280 | |
|
34263
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
2281 | req->hs = hs; |
|
34260
7a55eaa31da6
HTTP: implement keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34257
diff
changeset
|
2282 | hs->is_busy = TRUE; |
|
34263
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
2283 | hs->host = host; |
|
34260
7a55eaa31da6
HTTP: implement keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34257
diff
changeset
|
2284 | |
|
34262
3b8ce83bac96
HTTP: get rid of one (of two) msn's own http implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34261
diff
changeset
|
2285 | if (purple_debug_is_verbose()) |
|
34263
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
2286 | 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
|
2287 | |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
2288 | 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
|
2289 | |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
2290 | return FALSE; |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
2291 | } |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
2292 | |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
2293 | static void |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
2294 | 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
|
2295 | { |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
2296 | g_return_if_fail(host != NULL); |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
2297 | |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
2298 | if (host->process_queue_timeout > 0) |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
2299 | return; |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
2300 | |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
2301 | 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
|
2302 | _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
|
2303 | } |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
2304 | |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
2305 | static void |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
2306 | 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
|
2307 | { |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
2308 | if (req == NULL) |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
2309 | return; |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
2310 | |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
2311 | if (req->host != NULL) |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
2312 | 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
|
2313 | |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
2314 | if (req->hs != NULL) { |
|
35156
1bc10c44beef
HTTP: fix some clang warnings
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
34516
diff
changeset
|
2315 | if (G_LIKELY(req->host)) { |
|
1bc10c44beef
HTTP: fix some clang warnings
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
34516
diff
changeset
|
2316 | req->host->sockets = g_slist_remove(req->host->sockets, |
|
1bc10c44beef
HTTP: fix some clang warnings
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
34516
diff
changeset
|
2317 | req->hs); |
|
1bc10c44beef
HTTP: fix some clang warnings
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
34516
diff
changeset
|
2318 | } |
|
34263
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
2319 | 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
|
2320 | /* 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
|
2321 | } else { |
|
34316
2a3a587f5403
HTTP: make use of PurpleSocket
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
34314
diff
changeset
|
2322 | 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
|
2323 | g_free(req); |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
2324 | } |
|
34260
7a55eaa31da6
HTTP: implement keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34257
diff
changeset
|
2325 | } |
|
7a55eaa31da6
HTTP: implement keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34257
diff
changeset
|
2326 | |
|
7a55eaa31da6
HTTP: implement keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34257
diff
changeset
|
2327 | static void |
|
7a55eaa31da6
HTTP: implement keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34257
diff
changeset
|
2328 | 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
|
2329 | { |
|
34263
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
2330 | PurpleHttpKeepaliveHost *host; |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
2331 | |
|
34260
7a55eaa31da6
HTTP: implement keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34257
diff
changeset
|
2332 | if (hs == NULL) |
|
7a55eaa31da6
HTTP: implement keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34257
diff
changeset
|
2333 | return; |
|
7a55eaa31da6
HTTP: implement keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34257
diff
changeset
|
2334 | |
|
34262
3b8ce83bac96
HTTP: get rid of one (of two) msn's own http implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34261
diff
changeset
|
2335 | 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
|
2336 | 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
|
2337 | |
|
34316
2a3a587f5403
HTTP: make use of PurpleSocket
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
34314
diff
changeset
|
2338 | 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
|
2339 | hs->is_busy = FALSE; |
|
34263
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
2340 | host = hs->host; |
|
34260
7a55eaa31da6
HTTP: implement keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34257
diff
changeset
|
2341 | |
|
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
|
2342 | 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
|
2343 | 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
|
2344 | 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
|
2345 | } |
|
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
|
2346 | |
|
34260
7a55eaa31da6
HTTP: implement keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34257
diff
changeset
|
2347 | if (invalidate) { |
|
34263
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
2348 | 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
|
2349 | purple_http_socket_close_free(hs); |
|
7a55eaa31da6
HTTP: implement keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34257
diff
changeset
|
2350 | } |
|
34263
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
2351 | |
|
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
|
2352 | 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
|
2353 | } |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
2354 | |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
2355 | void |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
2356 | 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
|
2357 | guint limit) |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
2358 | { |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
2359 | g_return_if_fail(pool != NULL); |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
2360 | |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
2361 | pool->limit_per_host = limit; |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
2362 | } |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
2363 | |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
2364 | guint |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
2365 | 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
|
2366 | { |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
2367 | 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
|
2368 | |
|
e55133eaa11a
HTTP: queuing requests for Keep-Alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34262
diff
changeset
|
2369 | return pool->limit_per_host; |
|
34260
7a55eaa31da6
HTTP: implement keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34257
diff
changeset
|
2370 | } |
|
7a55eaa31da6
HTTP: implement keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34257
diff
changeset
|
2371 | |
|
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
|
2372 | /*** 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
|
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 | 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
|
2375 | 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
|
2376 | { |
|
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 | 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
|
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 | 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
|
2380 | 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
|
2381 | |
|
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 | 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
|
2383 | } |
|
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 | |
|
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 | 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
|
2386 | 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
|
2387 | { |
|
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 | 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
|
2389 | 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
|
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 | 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
|
2392 | |
|
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 | 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
|
2394 | 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
|
2395 | 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
|
2396 | |
|
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 | 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
|
2398 | 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
|
2399 | 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
|
2400 | |
|
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 | 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
|
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 | |
|
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
|
2404 | 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
|
2405 | 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
|
2406 | } |
|
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
|
2407 | |
|
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
|
2408 | 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
|
2409 | 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
|
2410 | 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
|
2411 | { |
|
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
|
2412 | 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
|
2413 | 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
|
2414 | 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
|
2415 | 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
|
2416 | 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
|
2417 | 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
|
2418 | 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
|
2419 | } |
|
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
|
2420 | 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
|
2421 | 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
|
2422 | } |
|
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
|
2423 | |
|
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
|
2424 | 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
|
2425 | 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
|
2426 | 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
|
2427 | { |
|
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
|
2428 | 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
|
2429 | 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
|
2430 | 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
|
2431 | } |
|
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
|
2432 | |
|
33427
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
2433 | /*** Request API **************************************************************/ |
|
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
2434 | |
|
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
2435 | 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
|
2436 | |
|
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
2437 | 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
|
2438 | { |
|
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
2439 | PurpleHttpRequest *request; |
|
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 = g_new0(PurpleHttpRequest, 1); |
|
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 | request->ref_count = 1; |
|
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
2444 | 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
|
2445 | request->headers = purple_http_headers_new(); |
|
33456
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
2446 | 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
|
2447 | 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
|
2448 | |
|
33450
4042907bcdf1
Timeout support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33448
diff
changeset
|
2449 | 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
|
2450 | 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
|
2451 | 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
|
2452 | 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
|
2453 | |
|
33427
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
2454 | return request; |
|
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
2455 | } |
|
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
2456 | |
|
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
2457 | 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
|
2458 | { |
|
33447
b890f231e15f
Request headers support, wrapping new API with legacy purple_util_fetch_url
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33446
diff
changeset
|
2459 | purple_http_headers_free(request->headers); |
|
33456
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
2460 | 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
|
2461 | purple_http_keepalive_pool_unref(request->keepalive_pool); |
|
37212
e0ca691299e6
Fix a memory leak on the http request
Jorge Villaseñor <salinasv@pidgin.im>
parents:
36047
diff
changeset
|
2462 | g_free(request->method); |
|
e0ca691299e6
Fix a memory leak on the http request
Jorge Villaseñor <salinasv@pidgin.im>
parents:
36047
diff
changeset
|
2463 | g_free(request->contents); |
|
33427
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
2464 | g_free(request->url); |
|
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
2465 | g_free(request); |
|
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
2466 | } |
|
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
2467 | |
|
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
2468 | 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
|
2469 | { |
|
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
2470 | g_return_if_fail(request != NULL); |
|
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
2471 | |
|
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
2472 | request->ref_count++; |
|
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
2473 | } |
|
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
2474 | |
|
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
2475 | 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
|
2476 | { |
|
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
2477 | if (request == NULL) |
|
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
2478 | return NULL; |
|
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
2479 | |
|
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
2480 | 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
|
2481 | |
|
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
2482 | request->ref_count--; |
|
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
2483 | if (request->ref_count > 0) |
|
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
2484 | return request; |
|
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
2485 | |
|
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
2486 | purple_http_request_free(request); |
|
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
2487 | return NULL; |
|
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
2488 | } |
|
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
2489 | |
|
33451
27d0e5dbc2a1
Implement missing getters/setters and corresponding features
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33450
diff
changeset
|
2490 | 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
|
2491 | { |
|
27d0e5dbc2a1
Implement missing getters/setters and corresponding features
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33450
diff
changeset
|
2492 | g_return_if_fail(request != NULL); |
|
27d0e5dbc2a1
Implement missing getters/setters and corresponding features
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33450
diff
changeset
|
2493 | g_return_if_fail(url != NULL); |
|
27d0e5dbc2a1
Implement missing getters/setters and corresponding features
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33450
diff
changeset
|
2494 | |
|
27d0e5dbc2a1
Implement missing getters/setters and corresponding features
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33450
diff
changeset
|
2495 | g_free(request->url); |
|
27d0e5dbc2a1
Implement missing getters/setters and corresponding features
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33450
diff
changeset
|
2496 | request->url = g_strdup(url); |
|
27d0e5dbc2a1
Implement missing getters/setters and corresponding features
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33450
diff
changeset
|
2497 | } |
|
27d0e5dbc2a1
Implement missing getters/setters and corresponding features
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33450
diff
changeset
|
2498 | |
|
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
|
2499 | 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
|
2500 | 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
|
2501 | { |
|
a5517f235e0f
HTTP: migrate purple_util_fetch_url_request to new API for GG prpl
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34225
diff
changeset
|
2502 | 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
|
2503 | 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
|
2504 | |
|
a5517f235e0f
HTTP: migrate purple_util_fetch_url_request to new API for GG prpl
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34225
diff
changeset
|
2505 | 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
|
2506 | 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
|
2507 | |
|
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 | 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
|
2509 | 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
|
2510 | 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
|
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 | 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
|
2513 | 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
|
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 | |
|
33451
27d0e5dbc2a1
Implement missing getters/setters and corresponding features
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33450
diff
changeset
|
2516 | 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
|
2517 | { |
|
27d0e5dbc2a1
Implement missing getters/setters and corresponding features
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33450
diff
changeset
|
2518 | 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
|
2519 | |
|
27d0e5dbc2a1
Implement missing getters/setters and corresponding features
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33450
diff
changeset
|
2520 | return request->url; |
|
27d0e5dbc2a1
Implement missing getters/setters and corresponding features
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33450
diff
changeset
|
2521 | } |
|
27d0e5dbc2a1
Implement missing getters/setters and corresponding features
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33450
diff
changeset
|
2522 | |
|
27d0e5dbc2a1
Implement missing getters/setters and corresponding features
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33450
diff
changeset
|
2523 | 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
|
2524 | { |
|
27d0e5dbc2a1
Implement missing getters/setters and corresponding features
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33450
diff
changeset
|
2525 | g_return_if_fail(request != NULL); |
|
27d0e5dbc2a1
Implement missing getters/setters and corresponding features
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33450
diff
changeset
|
2526 | |
|
27d0e5dbc2a1
Implement missing getters/setters and corresponding features
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33450
diff
changeset
|
2527 | g_free(request->method); |
|
27d0e5dbc2a1
Implement missing getters/setters and corresponding features
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33450
diff
changeset
|
2528 | request->method = g_strdup(method); |
|
27d0e5dbc2a1
Implement missing getters/setters and corresponding features
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33450
diff
changeset
|
2529 | } |
|
27d0e5dbc2a1
Implement missing getters/setters and corresponding features
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33450
diff
changeset
|
2530 | |
|
27d0e5dbc2a1
Implement missing getters/setters and corresponding features
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33450
diff
changeset
|
2531 | 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
|
2532 | { |
|
27d0e5dbc2a1
Implement missing getters/setters and corresponding features
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33450
diff
changeset
|
2533 | 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
|
2534 | |
|
27d0e5dbc2a1
Implement missing getters/setters and corresponding features
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33450
diff
changeset
|
2535 | return request->method; |
|
27d0e5dbc2a1
Implement missing getters/setters and corresponding features
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33450
diff
changeset
|
2536 | } |
|
27d0e5dbc2a1
Implement missing getters/setters and corresponding features
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33450
diff
changeset
|
2537 | |
|
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
|
2538 | 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
|
2539 | 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
|
2540 | { |
|
a5517f235e0f
HTTP: migrate purple_util_fetch_url_request to new API for GG prpl
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34225
diff
changeset
|
2541 | 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
|
2542 | |
|
a5517f235e0f
HTTP: migrate purple_util_fetch_url_request to new API for GG prpl
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34225
diff
changeset
|
2543 | 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
|
2544 | 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
|
2545 | |
|
a5517f235e0f
HTTP: migrate purple_util_fetch_url_request to new API for GG prpl
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34225
diff
changeset
|
2546 | 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
|
2547 | 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
|
2548 | 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
|
2549 | 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
|
2550 | } |
|
a5517f235e0f
HTTP: migrate purple_util_fetch_url_request to new API for GG prpl
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34225
diff
changeset
|
2551 | |
|
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
|
2552 | 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
|
2553 | 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
|
2554 | 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
|
2555 | { |
|
935120490eb2
HTTP: isolate socket-related code in http module; initial implementation for keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34234
diff
changeset
|
2556 | 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
|
2557 | |
|
34260
7a55eaa31da6
HTTP: implement keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34257
diff
changeset
|
2558 | if (pool != NULL) |
|
7a55eaa31da6
HTTP: implement keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34257
diff
changeset
|
2559 | purple_http_keepalive_pool_ref(pool); |
|
7a55eaa31da6
HTTP: implement keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34257
diff
changeset
|
2560 | |
|
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
|
2561 | 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
|
2562 | 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
|
2563 | 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
|
2564 | } |
|
935120490eb2
HTTP: isolate socket-related code in http module; initial implementation for keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34234
diff
changeset
|
2565 | |
|
34260
7a55eaa31da6
HTTP: implement keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34257
diff
changeset
|
2566 | 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
|
2567 | 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
|
2568 | } |
|
935120490eb2
HTTP: isolate socket-related code in http module; initial implementation for keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34234
diff
changeset
|
2569 | |
|
935120490eb2
HTTP: isolate socket-related code in http module; initial implementation for keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34234
diff
changeset
|
2570 | 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
|
2571 | 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
|
2572 | { |
|
935120490eb2
HTTP: isolate socket-related code in http module; initial implementation for keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34234
diff
changeset
|
2573 | 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
|
2574 | |
|
935120490eb2
HTTP: isolate socket-related code in http module; initial implementation for keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34234
diff
changeset
|
2575 | 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
|
2576 | } |
|
935120490eb2
HTTP: isolate socket-related code in http module; initial implementation for keep-alive connections
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34234
diff
changeset
|
2577 | |
|
33457
81f92a310aff
Writing request contents
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33456
diff
changeset
|
2578 | void purple_http_request_set_contents(PurpleHttpRequest *request, |
|
81f92a310aff
Writing request contents
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33456
diff
changeset
|
2579 | const gchar *contents, int length) |
|
81f92a310aff
Writing request contents
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33456
diff
changeset
|
2580 | { |
|
81f92a310aff
Writing request contents
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33456
diff
changeset
|
2581 | g_return_if_fail(request != NULL); |
|
81f92a310aff
Writing request contents
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33456
diff
changeset
|
2582 | g_return_if_fail(length >= -1); |
|
81f92a310aff
Writing request contents
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33456
diff
changeset
|
2583 | |
|
33466
918507303f45
HTTP API: PurpleHttpContentReader support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33464
diff
changeset
|
2584 | request->contents_reader = NULL; |
|
918507303f45
HTTP API: PurpleHttpContentReader support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33464
diff
changeset
|
2585 | request->contents_reader_data = NULL; |
|
918507303f45
HTTP API: PurpleHttpContentReader support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33464
diff
changeset
|
2586 | |
|
33457
81f92a310aff
Writing request contents
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33456
diff
changeset
|
2587 | g_free(request->contents); |
|
81f92a310aff
Writing request contents
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33456
diff
changeset
|
2588 | if (contents == NULL || length == 0) { |
|
81f92a310aff
Writing request contents
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33456
diff
changeset
|
2589 | request->contents = NULL; |
|
81f92a310aff
Writing request contents
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33456
diff
changeset
|
2590 | request->contents_length = 0; |
|
81f92a310aff
Writing request contents
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33456
diff
changeset
|
2591 | return; |
|
81f92a310aff
Writing request contents
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33456
diff
changeset
|
2592 | } |
|
81f92a310aff
Writing request contents
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33456
diff
changeset
|
2593 | |
|
81f92a310aff
Writing request contents
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33456
diff
changeset
|
2594 | if (length == -1) |
|
81f92a310aff
Writing request contents
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33456
diff
changeset
|
2595 | length = strlen(contents); |
|
81f92a310aff
Writing request contents
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33456
diff
changeset
|
2596 | request->contents = g_memdup(contents, length); |
|
81f92a310aff
Writing request contents
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33456
diff
changeset
|
2597 | request->contents_length = length; |
|
81f92a310aff
Writing request contents
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33456
diff
changeset
|
2598 | } |
|
81f92a310aff
Writing request contents
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33456
diff
changeset
|
2599 | |
|
33466
918507303f45
HTTP API: PurpleHttpContentReader support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33464
diff
changeset
|
2600 | void purple_http_request_set_contents_reader(PurpleHttpRequest *request, |
|
918507303f45
HTTP API: PurpleHttpContentReader support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33464
diff
changeset
|
2601 | PurpleHttpContentReader reader, int contents_length, gpointer user_data) |
|
918507303f45
HTTP API: PurpleHttpContentReader support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33464
diff
changeset
|
2602 | { |
|
918507303f45
HTTP API: PurpleHttpContentReader support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33464
diff
changeset
|
2603 | g_return_if_fail(request != NULL); |
|
918507303f45
HTTP API: PurpleHttpContentReader support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33464
diff
changeset
|
2604 | g_return_if_fail(reader != NULL); |
|
918507303f45
HTTP API: PurpleHttpContentReader support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33464
diff
changeset
|
2605 | g_return_if_fail(contents_length >= -1); |
|
918507303f45
HTTP API: PurpleHttpContentReader support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33464
diff
changeset
|
2606 | |
|
918507303f45
HTTP API: PurpleHttpContentReader support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33464
diff
changeset
|
2607 | g_free(request->contents); |
|
918507303f45
HTTP API: PurpleHttpContentReader support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33464
diff
changeset
|
2608 | request->contents = NULL; |
|
918507303f45
HTTP API: PurpleHttpContentReader support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33464
diff
changeset
|
2609 | request->contents_length = contents_length; |
|
918507303f45
HTTP API: PurpleHttpContentReader support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33464
diff
changeset
|
2610 | request->contents_reader = reader; |
|
918507303f45
HTTP API: PurpleHttpContentReader support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33464
diff
changeset
|
2611 | request->contents_reader_data = user_data; |
|
918507303f45
HTTP API: PurpleHttpContentReader support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33464
diff
changeset
|
2612 | } |
|
918507303f45
HTTP API: PurpleHttpContentReader support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33464
diff
changeset
|
2613 | |
|
33517
ddd9e37c4b07
HTTP: PurpleHttpContentWriter support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33469
diff
changeset
|
2614 | void purple_http_request_set_response_writer(PurpleHttpRequest *request, |
|
ddd9e37c4b07
HTTP: PurpleHttpContentWriter support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33469
diff
changeset
|
2615 | PurpleHttpContentWriter writer, gpointer user_data) |
|
ddd9e37c4b07
HTTP: PurpleHttpContentWriter support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33469
diff
changeset
|
2616 | { |
|
ddd9e37c4b07
HTTP: PurpleHttpContentWriter support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33469
diff
changeset
|
2617 | g_return_if_fail(request != NULL); |
|
ddd9e37c4b07
HTTP: PurpleHttpContentWriter support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33469
diff
changeset
|
2618 | |
|
ddd9e37c4b07
HTTP: PurpleHttpContentWriter support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33469
diff
changeset
|
2619 | if (writer == NULL) |
|
ddd9e37c4b07
HTTP: PurpleHttpContentWriter support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33469
diff
changeset
|
2620 | user_data = NULL; |
|
ddd9e37c4b07
HTTP: PurpleHttpContentWriter support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33469
diff
changeset
|
2621 | request->response_writer = writer; |
|
ddd9e37c4b07
HTTP: PurpleHttpContentWriter support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33469
diff
changeset
|
2622 | request->response_writer_data = user_data; |
|
ddd9e37c4b07
HTTP: PurpleHttpContentWriter support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33469
diff
changeset
|
2623 | } |
|
ddd9e37c4b07
HTTP: PurpleHttpContentWriter support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33469
diff
changeset
|
2624 | |
|
33450
4042907bcdf1
Timeout support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33448
diff
changeset
|
2625 | void purple_http_request_set_timeout(PurpleHttpRequest *request, int timeout) |
|
4042907bcdf1
Timeout support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33448
diff
changeset
|
2626 | { |
|
4042907bcdf1
Timeout support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33448
diff
changeset
|
2627 | g_return_if_fail(request != NULL); |
|
4042907bcdf1
Timeout support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33448
diff
changeset
|
2628 | |
|
4042907bcdf1
Timeout support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33448
diff
changeset
|
2629 | if (timeout < -1) |
|
4042907bcdf1
Timeout support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33448
diff
changeset
|
2630 | timeout = -1; |
|
4042907bcdf1
Timeout support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33448
diff
changeset
|
2631 | |
|
4042907bcdf1
Timeout support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33448
diff
changeset
|
2632 | request->timeout = timeout; |
|
4042907bcdf1
Timeout support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33448
diff
changeset
|
2633 | } |
|
4042907bcdf1
Timeout support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33448
diff
changeset
|
2634 | |
|
4042907bcdf1
Timeout support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33448
diff
changeset
|
2635 | int purple_http_request_get_timeout(PurpleHttpRequest *request) |
|
4042907bcdf1
Timeout support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33448
diff
changeset
|
2636 | { |
|
4042907bcdf1
Timeout support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33448
diff
changeset
|
2637 | g_return_val_if_fail(request != NULL, -1); |
|
4042907bcdf1
Timeout support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33448
diff
changeset
|
2638 | |
|
4042907bcdf1
Timeout support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33448
diff
changeset
|
2639 | return request->timeout; |
|
4042907bcdf1
Timeout support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33448
diff
changeset
|
2640 | } |
|
4042907bcdf1
Timeout support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33448
diff
changeset
|
2641 | |
|
33444
b3afec292014
New features: http version switching and limits for redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33443
diff
changeset
|
2642 | 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
|
2643 | int max_redirects) |
|
b3afec292014
New features: http version switching and limits for redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33443
diff
changeset
|
2644 | { |
|
b3afec292014
New features: http version switching and limits for redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33443
diff
changeset
|
2645 | 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
|
2646 | |
|
b3afec292014
New features: http version switching and limits for redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33443
diff
changeset
|
2647 | if (max_redirects < -1) |
|
b3afec292014
New features: http version switching and limits for redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33443
diff
changeset
|
2648 | max_redirects = -1; |
|
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 | 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
|
2651 | } |
|
b3afec292014
New features: http version switching and limits for redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33443
diff
changeset
|
2652 | |
|
b3afec292014
New features: http version switching and limits for redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33443
diff
changeset
|
2653 | 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
|
2654 | { |
|
b3afec292014
New features: http version switching and limits for redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33443
diff
changeset
|
2655 | 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
|
2656 | |
|
b3afec292014
New features: http version switching and limits for redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33443
diff
changeset
|
2657 | return request->max_redirects; |
|
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 | |
|
33456
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
2660 | void purple_http_request_set_cookie_jar(PurpleHttpRequest *request, |
|
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
2661 | PurpleHttpCookieJar *cookie_jar) |
|
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
2662 | { |
|
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
2663 | g_return_if_fail(request != NULL); |
|
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
2664 | g_return_if_fail(cookie_jar != NULL); |
|
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
2665 | |
|
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
2666 | purple_http_cookie_jar_ref(cookie_jar); |
|
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
2667 | purple_http_cookie_jar_unref(request->cookie_jar); |
|
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
2668 | request->cookie_jar = cookie_jar; |
|
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
2669 | } |
|
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
2670 | |
|
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
2671 | PurpleHttpCookieJar * purple_http_request_get_cookie_jar( |
|
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
2672 | PurpleHttpRequest *request) |
|
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
2673 | { |
|
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
2674 | g_return_val_if_fail(request != NULL, NULL); |
|
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
2675 | |
|
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
2676 | return request->cookie_jar; |
|
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
2677 | } |
|
35a2f951a850
Cookies support (reading)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33455
diff
changeset
|
2678 | |
|
33444
b3afec292014
New features: http version switching and limits for redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33443
diff
changeset
|
2679 | 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
|
2680 | { |
|
b3afec292014
New features: http version switching and limits for redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33443
diff
changeset
|
2681 | 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
|
2682 | |
|
b3afec292014
New features: http version switching and limits for redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33443
diff
changeset
|
2683 | request->http11 = http11; |
|
b3afec292014
New features: http version switching and limits for redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33443
diff
changeset
|
2684 | } |
|
b3afec292014
New features: http version switching and limits for redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33443
diff
changeset
|
2685 | |
|
b3afec292014
New features: http version switching and limits for redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33443
diff
changeset
|
2686 | 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
|
2687 | { |
|
b3afec292014
New features: http version switching and limits for redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33443
diff
changeset
|
2688 | 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
|
2689 | |
|
b3afec292014
New features: http version switching and limits for redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33443
diff
changeset
|
2690 | return request->http11; |
|
b3afec292014
New features: http version switching and limits for redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33443
diff
changeset
|
2691 | } |
|
b3afec292014
New features: http version switching and limits for redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33443
diff
changeset
|
2692 | |
|
33446
95fda782966c
New feature: setting maximum length of response
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33445
diff
changeset
|
2693 | 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
|
2694 | { |
|
95fda782966c
New feature: setting maximum length of response
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33445
diff
changeset
|
2695 | g_return_if_fail(request != NULL); |
|
95fda782966c
New feature: setting maximum length of response
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33445
diff
changeset
|
2696 | |
|
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
|
2697 | 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
|
2698 | 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
|
2699 | |
|
95fda782966c
New feature: setting maximum length of response
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33445
diff
changeset
|
2700 | request->max_length = max_len; |
|
95fda782966c
New feature: setting maximum length of response
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33445
diff
changeset
|
2701 | } |
|
95fda782966c
New feature: setting maximum length of response
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33445
diff
changeset
|
2702 | |
|
95fda782966c
New feature: setting maximum length of response
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33445
diff
changeset
|
2703 | 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
|
2704 | { |
|
95fda782966c
New feature: setting maximum length of response
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33445
diff
changeset
|
2705 | 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
|
2706 | |
|
95fda782966c
New feature: setting maximum length of response
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33445
diff
changeset
|
2707 | return request->max_length; |
|
95fda782966c
New feature: setting maximum length of response
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33445
diff
changeset
|
2708 | } |
|
95fda782966c
New feature: setting maximum length of response
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33445
diff
changeset
|
2709 | |
|
33447
b890f231e15f
Request headers support, wrapping new API with legacy purple_util_fetch_url
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33446
diff
changeset
|
2710 | 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
|
2711 | 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
|
2712 | { |
|
b890f231e15f
Request headers support, wrapping new API with legacy purple_util_fetch_url
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33446
diff
changeset
|
2713 | 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
|
2714 | 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
|
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 | 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
|
2717 | 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
|
2718 | 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
|
2719 | } |
|
b890f231e15f
Request headers support, wrapping new API with legacy purple_util_fetch_url
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33446
diff
changeset
|
2720 | |
|
33455
2de654702970
Print-like setting headers, vestigal keepalive support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33454
diff
changeset
|
2721 | 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
|
2722 | const gchar *key, const gchar *format, ...) |
|
2de654702970
Print-like setting headers, vestigal keepalive support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33454
diff
changeset
|
2723 | { |
|
2de654702970
Print-like setting headers, vestigal keepalive support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33454
diff
changeset
|
2724 | va_list args; |
|
2de654702970
Print-like setting headers, vestigal keepalive support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33454
diff
changeset
|
2725 | gchar *value; |
|
2de654702970
Print-like setting headers, vestigal keepalive support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33454
diff
changeset
|
2726 | |
|
2de654702970
Print-like setting headers, vestigal keepalive support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33454
diff
changeset
|
2727 | g_return_if_fail(request != NULL); |
|
2de654702970
Print-like setting headers, vestigal keepalive support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33454
diff
changeset
|
2728 | g_return_if_fail(key != NULL); |
|
2de654702970
Print-like setting headers, vestigal keepalive support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33454
diff
changeset
|
2729 | g_return_if_fail(format != NULL); |
|
2de654702970
Print-like setting headers, vestigal keepalive support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33454
diff
changeset
|
2730 | |
|
2de654702970
Print-like setting headers, vestigal keepalive support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33454
diff
changeset
|
2731 | va_start(args, format); |
|
2de654702970
Print-like setting headers, vestigal keepalive support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33454
diff
changeset
|
2732 | value = g_strdup_vprintf(format, args); |
|
2de654702970
Print-like setting headers, vestigal keepalive support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33454
diff
changeset
|
2733 | va_end(args); |
|
2de654702970
Print-like setting headers, vestigal keepalive support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33454
diff
changeset
|
2734 | |
|
2de654702970
Print-like setting headers, vestigal keepalive support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33454
diff
changeset
|
2735 | 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
|
2736 | g_free(value); |
|
2de654702970
Print-like setting headers, vestigal keepalive support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33454
diff
changeset
|
2737 | } |
|
2de654702970
Print-like setting headers, vestigal keepalive support
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33454
diff
changeset
|
2738 | |
|
33447
b890f231e15f
Request headers support, wrapping new API with legacy purple_util_fetch_url
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33446
diff
changeset
|
2739 | 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
|
2740 | 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
|
2741 | { |
|
b890f231e15f
Request headers support, wrapping new API with legacy purple_util_fetch_url
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33446
diff
changeset
|
2742 | 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
|
2743 | 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
|
2744 | |
|
b890f231e15f
Request headers support, wrapping new API with legacy purple_util_fetch_url
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33446
diff
changeset
|
2745 | 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
|
2746 | } |
|
b890f231e15f
Request headers support, wrapping new API with legacy purple_util_fetch_url
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33446
diff
changeset
|
2747 | |
|
33427
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
2748 | /*** HTTP response API ********************************************************/ |
|
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
2749 | |
|
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
2750 | 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
|
2751 | { |
|
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
2752 | PurpleHttpResponse *response = g_new0(PurpleHttpResponse, 1); |
|
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 | return 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 | |
|
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
2757 | 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
|
2758 | { |
|
33433
fb7ac52ed7df
Let's get response contents
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33432
diff
changeset
|
2759 | if (response->contents != NULL) |
|
fb7ac52ed7df
Let's get response contents
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33432
diff
changeset
|
2760 | g_string_free(response->contents, TRUE); |
|
33430
013c5aebb665
Let's connect
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33429
diff
changeset
|
2761 | g_free(response->error); |
|
33432
9c4acb75b2e6
Let's parse response headers
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33431
diff
changeset
|
2762 | 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
|
2763 | g_free(response); |
|
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
2764 | } |
|
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
2765 | |
|
34287
6cd0c77b1f6a
HTTP: successful is spelled with one l
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34286
diff
changeset
|
2766 | 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
|
2767 | { |
|
33432
9c4acb75b2e6
Let's parse response headers
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33431
diff
changeset
|
2768 | int code; |
|
9c4acb75b2e6
Let's parse response headers
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33431
diff
changeset
|
2769 | |
|
33427
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
2770 | 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
|
2771 | |
|
33432
9c4acb75b2e6
Let's parse response headers
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33431
diff
changeset
|
2772 | code = response->code; |
|
9c4acb75b2e6
Let's parse response headers
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33431
diff
changeset
|
2773 | |
|
9c4acb75b2e6
Let's parse response headers
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33431
diff
changeset
|
2774 | if (code <= 0) |
|
9c4acb75b2e6
Let's parse response headers
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33431
diff
changeset
|
2775 | return FALSE; |
|
9c4acb75b2e6
Let's parse response headers
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33431
diff
changeset
|
2776 | |
|
34262
3b8ce83bac96
HTTP: get rid of one (of two) msn's own http implementations
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34261
diff
changeset
|
2777 | /* 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
|
2778 | |
|
33458
59b3364f690e
Sending cookies
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33457
diff
changeset
|
2779 | if (code / 100 == 2) |
|
33432
9c4acb75b2e6
Let's parse response headers
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33431
diff
changeset
|
2780 | return TRUE; |
|
9c4acb75b2e6
Let's parse response headers
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33431
diff
changeset
|
2781 | |
|
9c4acb75b2e6
Let's parse response headers
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33431
diff
changeset
|
2782 | return FALSE; |
|
33427
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
2783 | } |
|
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
2784 | |
|
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
2785 | 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
|
2786 | { |
|
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
2787 | 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
|
2788 | |
|
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
2789 | return response->code; |
|
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
2790 | } |
|
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
2791 | |
|
33430
013c5aebb665
Let's connect
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33429
diff
changeset
|
2792 | const gchar * purple_http_response_get_error(PurpleHttpResponse *response) |
|
013c5aebb665
Let's connect
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33429
diff
changeset
|
2793 | { |
|
013c5aebb665
Let's connect
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33429
diff
changeset
|
2794 | g_return_val_if_fail(response != NULL, NULL); |
|
013c5aebb665
Let's connect
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33429
diff
changeset
|
2795 | |
|
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
|
2796 | 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
|
2797 | 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
|
2798 | |
|
34287
6cd0c77b1f6a
HTTP: successful is spelled with one l
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34286
diff
changeset
|
2799 | 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
|
2800 | 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
|
2801 | 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
|
2802 | 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
|
2803 | _("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
|
2804 | } 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
|
2805 | 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
|
2806 | _("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
|
2807 | 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
|
2808 | } |
|
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
|
2809 | 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
|
2810 | } |
|
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
|
2811 | |
|
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
|
2812 | return NULL; |
|
33430
013c5aebb665
Let's connect
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33429
diff
changeset
|
2813 | } |
|
013c5aebb665
Let's connect
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33429
diff
changeset
|
2814 | |
|
33427
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
2815 | 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
|
2816 | { |
|
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
2817 | 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
|
2818 | |
|
33433
fb7ac52ed7df
Let's get response contents
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33432
diff
changeset
|
2819 | if (response->contents == NULL) |
|
fb7ac52ed7df
Let's get response contents
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33432
diff
changeset
|
2820 | return 0; |
|
fb7ac52ed7df
Let's get response contents
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33432
diff
changeset
|
2821 | |
|
fb7ac52ed7df
Let's get response contents
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33432
diff
changeset
|
2822 | return response->contents->len; |
|
33427
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
2823 | } |
|
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
2824 | |
|
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
|
2825 | 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
|
2826 | { |
|
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
|
2827 | 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
|
2828 | |
|
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
|
2829 | 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
|
2830 | |
|
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
|
2831 | 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
|
2832 | ret = response->contents->str; |
|
35349
e41c41659c26
HTTP: fix some code style errors
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35319
diff
changeset
|
2833 | if (len) |
|
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
|
2834 | *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
|
2835 | } else { |
|
35349
e41c41659c26
HTTP: fix some code style errors
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35319
diff
changeset
|
2836 | if (len) |
|
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
|
2837 | *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
|
2838 | } |
|
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
|
2839 | |
|
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
|
2840 | return ret; |
|
33427
dd0c0860e293
Basic API and testing actions for it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33425
diff
changeset
|
2841 | } |
|
33429
1ce1faf4e675
Extend URL parsing
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33427
diff
changeset
|
2842 | |
|
33451
27d0e5dbc2a1
Implement missing getters/setters and corresponding features
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33450
diff
changeset
|
2843 | 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
|
2844 | { |
|
27d0e5dbc2a1
Implement missing getters/setters and corresponding features
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33450
diff
changeset
|
2845 | 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
|
2846 | |
|
27d0e5dbc2a1
Implement missing getters/setters and corresponding features
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33450
diff
changeset
|
2847 | 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
|
2848 | } |
|
27d0e5dbc2a1
Implement missing getters/setters and corresponding features
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33450
diff
changeset
|
2849 | |
|
27d0e5dbc2a1
Implement missing getters/setters and corresponding features
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33450
diff
changeset
|
2850 | 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
|
2851 | PurpleHttpResponse *response, const gchar *name) |
|
27d0e5dbc2a1
Implement missing getters/setters and corresponding features
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33450
diff
changeset
|
2852 | { |
|
27d0e5dbc2a1
Implement missing getters/setters and corresponding features
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33450
diff
changeset
|
2853 | 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
|
2854 | 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
|
2855 | |
|
27d0e5dbc2a1
Implement missing getters/setters and corresponding features
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33450
diff
changeset
|
2856 | 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
|
2857 | } |
|
27d0e5dbc2a1
Implement missing getters/setters and corresponding features
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33450
diff
changeset
|
2858 | |
|
27d0e5dbc2a1
Implement missing getters/setters and corresponding features
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33450
diff
changeset
|
2859 | 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
|
2860 | const gchar *name) |
|
27d0e5dbc2a1
Implement missing getters/setters and corresponding features
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33450
diff
changeset
|
2861 | { |
|
27d0e5dbc2a1
Implement missing getters/setters and corresponding features
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33450
diff
changeset
|
2862 | 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
|
2863 | 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
|
2864 | |
|
27d0e5dbc2a1
Implement missing getters/setters and corresponding features
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33450
diff
changeset
|
2865 | 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
|
2866 | } |
|
27d0e5dbc2a1
Implement missing getters/setters and corresponding features
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33450
diff
changeset
|
2867 | |
|
33429
1ce1faf4e675
Extend URL parsing
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33427
diff
changeset
|
2868 | /*** URL functions ************************************************************/ |
|
1ce1faf4e675
Extend URL parsing
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33427
diff
changeset
|
2869 | |
|
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
|
2870 | 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
|
2871 | purple_http_url_parse(const char *raw_url) |
|
33429
1ce1faf4e675
Extend URL parsing
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33427
diff
changeset
|
2872 | { |
|
33439
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
2873 | PurpleHttpURL *url; |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
2874 | GMatchInfo *match_info; |
|
33429
1ce1faf4e675
Extend URL parsing
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33427
diff
changeset
|
2875 | |
|
33439
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
2876 | gchar *host_full, *tmp; |
|
33429
1ce1faf4e675
Extend URL parsing
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33427
diff
changeset
|
2877 | |
|
33439
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
2878 | g_return_val_if_fail(raw_url != NULL, NULL); |
|
33429
1ce1faf4e675
Extend URL parsing
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33427
diff
changeset
|
2879 | |
|
33439
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
2880 | 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
|
2881 | if (purple_debug_is_verbose() && purple_debug_is_unsafe()) { |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
2882 | purple_debug_warning("http", |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
2883 | "Invalid URL provided: %s\n", |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
2884 | raw_url); |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
2885 | } |
|
33429
1ce1faf4e675
Extend URL parsing
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33427
diff
changeset
|
2886 | return NULL; |
|
1ce1faf4e675
Extend URL parsing
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33427
diff
changeset
|
2887 | } |
|
1ce1faf4e675
Extend URL parsing
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33427
diff
changeset
|
2888 | |
|
37242
98995eed6e7b
Fix memory leak at parsing http
Jorge Villaseñor <salinasv@pidgin.im>
parents:
37212
diff
changeset
|
2889 | url = g_new0(PurpleHttpURL, 1); |
|
98995eed6e7b
Fix memory leak at parsing http
Jorge Villaseñor <salinasv@pidgin.im>
parents:
37212
diff
changeset
|
2890 | |
|
33439
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
2891 | url->protocol = g_match_info_fetch(match_info, 1); |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
2892 | host_full = g_match_info_fetch(match_info, 2); |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
2893 | url->path = g_match_info_fetch(match_info, 3); |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
2894 | url->fragment = g_match_info_fetch(match_info, 4); |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
2895 | g_match_info_free(match_info); |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
2896 | |
|
36047
2d7d55acd82c
Coverity: fix null pointer dereferences
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35475
diff
changeset
|
2897 | if (g_strcmp0(url->protocol, "") == 0) { |
|
33439
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
2898 | g_free(url->protocol); |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
2899 | url->protocol = NULL; |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
2900 | } else if (url->protocol != NULL) { |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
2901 | tmp = url->protocol; |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
2902 | url->protocol = g_ascii_strdown(url->protocol, -1); |
|
33431
704de181d1d2
Let's request
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33430
diff
changeset
|
2903 | g_free(tmp); |
|
704de181d1d2
Let's request
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33430
diff
changeset
|
2904 | } |
|
33439
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
2905 | if (host_full[0] == '\0') { |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
2906 | g_free(host_full); |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
2907 | host_full = NULL; |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
2908 | } |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
2909 | if (url->path[0] == '\0') { |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
2910 | g_free(url->path); |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
2911 | url->path = NULL; |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
2912 | } |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
2913 | if ((url->protocol == NULL) != (host_full == NULL)) |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
2914 | purple_debug_warning("http", "Protocol or host not present " |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
2915 | "(unlikely case)\n"); |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
2916 | |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
2917 | if (host_full) { |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
2918 | gchar *port_str; |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
2919 | |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
2920 | if (!g_regex_match(purple_http_re_url_host, host_full, 0, |
|
35362
a6223370667b
Style: fix braces for http, keyring
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35352
diff
changeset
|
2921 | &match_info)) |
|
a6223370667b
Style: fix braces for http, keyring
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35352
diff
changeset
|
2922 | { |
|
33439
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
2923 | if (purple_debug_is_verbose() && |
|
35362
a6223370667b
Style: fix braces for http, keyring
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35352
diff
changeset
|
2924 | purple_debug_is_unsafe()) |
|
a6223370667b
Style: fix braces for http, keyring
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35352
diff
changeset
|
2925 | { |
|
33439
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
2926 | purple_debug_warning("http", |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
2927 | "Invalid host provided for URL: %s\n", |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
2928 | raw_url); |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
2929 | } |
|
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 | purple_http_url_free(url); |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
2933 | return NULL; |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
2934 | } |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
2935 | |
|
34219
eee308def583
HTTP: get rid of purple_url_parse
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34218
diff
changeset
|
2936 | url->username = g_match_info_fetch(match_info, 1); |
|
33439
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
2937 | url->password = g_match_info_fetch(match_info, 2); |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
2938 | url->host = g_match_info_fetch(match_info, 3); |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
2939 | port_str = g_match_info_fetch(match_info, 4); |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
2940 | |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
2941 | if (port_str && port_str[0]) |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
2942 | url->port = atoi(port_str); |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
2943 | |
|
34219
eee308def583
HTTP: get rid of purple_url_parse
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34218
diff
changeset
|
2944 | if (url->username[0] == '\0') { |
|
eee308def583
HTTP: get rid of purple_url_parse
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34218
diff
changeset
|
2945 | g_free(url->username); |
|
eee308def583
HTTP: get rid of purple_url_parse
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34218
diff
changeset
|
2946 | url->username = NULL; |
|
33439
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
2947 | } |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
2948 | if (url->password[0] == '\0') { |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
2949 | g_free(url->password); |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
2950 | url->password = NULL; |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
2951 | } |
|
36047
2d7d55acd82c
Coverity: fix null pointer dereferences
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35475
diff
changeset
|
2952 | if (g_strcmp0(url->host, "") == 0) { |
|
33439
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
2953 | g_free(url->host); |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
2954 | url->host = NULL; |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
2955 | } else if (url->host != NULL) { |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
2956 | tmp = url->host; |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
2957 | url->host = g_ascii_strdown(url->host, -1); |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
2958 | g_free(tmp); |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
2959 | } |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
2960 | |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
2961 | g_free(port_str); |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
2962 | g_match_info_free(match_info); |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
2963 | |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
2964 | g_free(host_full); |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
2965 | host_full = NULL; |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
2966 | } |
|
33431
704de181d1d2
Let's request
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33430
diff
changeset
|
2967 | |
|
33439
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
2968 | if (url->host != NULL) { |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
2969 | if (url->protocol == NULL) |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
2970 | url->protocol = g_strdup("http"); |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
2971 | if (url->port == 0 && 0 == strcmp(url->protocol, "http")) |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
2972 | url->port = 80; |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
2973 | if (url->port == 0 && 0 == strcmp(url->protocol, "https")) |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
2974 | url->port = 443; |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
2975 | if (url->path == NULL) |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
2976 | url->path = g_strdup("/"); |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
2977 | if (url->path[0] != '/') |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
2978 | purple_debug_warning("http", |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
2979 | "URL path doesn't start with slash\n"); |
|
33431
704de181d1d2
Let's request
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33430
diff
changeset
|
2980 | } |
|
704de181d1d2
Let's request
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33430
diff
changeset
|
2981 | |
|
33439
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
2982 | return url; |
|
33429
1ce1faf4e675
Extend URL parsing
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33427
diff
changeset
|
2983 | } |
|
1ce1faf4e675
Extend URL parsing
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33427
diff
changeset
|
2984 | |
|
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
|
2985 | 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
|
2986 | purple_http_url_free(PurpleHttpURL *parsed_url) |
|
33429
1ce1faf4e675
Extend URL parsing
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33427
diff
changeset
|
2987 | { |
|
1ce1faf4e675
Extend URL parsing
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33427
diff
changeset
|
2988 | if (parsed_url == NULL) |
|
1ce1faf4e675
Extend URL parsing
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33427
diff
changeset
|
2989 | return; |
|
1ce1faf4e675
Extend URL parsing
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33427
diff
changeset
|
2990 | |
|
1ce1faf4e675
Extend URL parsing
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33427
diff
changeset
|
2991 | g_free(parsed_url->protocol); |
|
34219
eee308def583
HTTP: get rid of purple_url_parse
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34218
diff
changeset
|
2992 | g_free(parsed_url->username); |
|
33439
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
2993 | g_free(parsed_url->password); |
|
33429
1ce1faf4e675
Extend URL parsing
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33427
diff
changeset
|
2994 | g_free(parsed_url->host); |
|
1ce1faf4e675
Extend URL parsing
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33427
diff
changeset
|
2995 | g_free(parsed_url->path); |
|
33439
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
2996 | g_free(parsed_url->fragment); |
|
33429
1ce1faf4e675
Extend URL parsing
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33427
diff
changeset
|
2997 | g_free(parsed_url); |
|
1ce1faf4e675
Extend URL parsing
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33427
diff
changeset
|
2998 | } |
|
1ce1faf4e675
Extend URL parsing
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33427
diff
changeset
|
2999 | |
|
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
|
3000 | 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
|
3001 | purple_http_url_relative(PurpleHttpURL *base_url, PurpleHttpURL *relative_url) |
|
33439
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
3002 | { |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
3003 | g_return_if_fail(base_url != NULL); |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
3004 | g_return_if_fail(relative_url != NULL); |
|
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 | if (relative_url->host) { |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
3007 | g_free(base_url->protocol); |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
3008 | 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
|
3009 | g_free(base_url->username); |
|
eee308def583
HTTP: get rid of purple_url_parse
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34218
diff
changeset
|
3010 | base_url->username = g_strdup(relative_url->username); |
|
33439
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
3011 | g_free(base_url->password); |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
3012 | base_url->password = g_strdup(relative_url->password); |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
3013 | g_free(base_url->host); |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
3014 | base_url->host = g_strdup(relative_url->host); |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
3015 | base_url->port = relative_url->port; |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
3016 | |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
3017 | g_free(base_url->path); |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
3018 | base_url->path = NULL; |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
3019 | } |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
3020 | |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
3021 | if (relative_url->path) { |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
3022 | if (relative_url->path[0] == '/' || |
|
35362
a6223370667b
Style: fix braces for http, keyring
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35352
diff
changeset
|
3023 | base_url->path == NULL) |
|
a6223370667b
Style: fix braces for http, keyring
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35352
diff
changeset
|
3024 | { |
|
33439
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
3025 | g_free(base_url->path); |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
3026 | base_url->path = g_strdup(relative_url->path); |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
3027 | } else { |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
3028 | gchar *last_slash = strrchr(base_url->path, '/'); |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
3029 | gchar *tmp; |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
3030 | if (last_slash == NULL) |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
3031 | base_url->path[0] = '\0'; |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
3032 | else |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
3033 | last_slash[1] = '\0'; |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
3034 | tmp = base_url->path; |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
3035 | base_url->path = g_strconcat(base_url->path, |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
3036 | relative_url->path, NULL); |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
3037 | g_free(tmp); |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
3038 | } |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
3039 | } |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
3040 | |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
3041 | g_free(base_url->fragment); |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
3042 | base_url->fragment = g_strdup(relative_url->fragment); |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
3043 | } |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
3044 | |
|
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
|
3045 | 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
|
3046 | purple_http_url_print(PurpleHttpURL *parsed_url) |
|
33429
1ce1faf4e675
Extend URL parsing
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33427
diff
changeset
|
3047 | { |
|
33438
66c4b90ff08a
More debug prints
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33437
diff
changeset
|
3048 | GString *url = g_string_new(""); |
|
66c4b90ff08a
More debug prints
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33437
diff
changeset
|
3049 | gboolean before_host_printed = FALSE, host_printed = FALSE; |
|
33439
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
3050 | gboolean port_is_default = FALSE; |
|
33430
013c5aebb665
Let's connect
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33429
diff
changeset
|
3051 | |
|
33439
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
3052 | if (parsed_url->protocol) { |
|
33438
66c4b90ff08a
More debug prints
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33437
diff
changeset
|
3053 | g_string_append_printf(url, "%s://", parsed_url->protocol); |
|
66c4b90ff08a
More debug prints
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33437
diff
changeset
|
3054 | before_host_printed = TRUE; |
|
33439
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
3055 | if (parsed_url->port == 80 && 0 == strcmp(parsed_url->protocol, |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
3056 | "http")) |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
3057 | port_is_default = TRUE; |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
3058 | if (parsed_url->port == 443 && 0 == strcmp(parsed_url->protocol, |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
3059 | "https")) |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
3060 | port_is_default = TRUE; |
|
33438
66c4b90ff08a
More debug prints
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33437
diff
changeset
|
3061 | } |
|
34219
eee308def583
HTTP: get rid of purple_url_parse
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34218
diff
changeset
|
3062 | 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
|
3063 | if (parsed_url->username) |
|
eee308def583
HTTP: get rid of purple_url_parse
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34218
diff
changeset
|
3064 | g_string_append(url, parsed_url->username); |
|
33438
66c4b90ff08a
More debug prints
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33437
diff
changeset
|
3065 | g_string_append_printf(url, ":%s", parsed_url->password); |
|
66c4b90ff08a
More debug prints
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33437
diff
changeset
|
3066 | g_string_append(url, "@"); |
|
66c4b90ff08a
More debug prints
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33437
diff
changeset
|
3067 | before_host_printed = TRUE; |
|
66c4b90ff08a
More debug prints
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33437
diff
changeset
|
3068 | } |
|
33439
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
3069 | if (parsed_url->host || parsed_url->port) { |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
3070 | if (!parsed_url->host) |
|
33438
66c4b90ff08a
More debug prints
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33437
diff
changeset
|
3071 | g_string_append_printf(url, "{???}:%d", |
|
66c4b90ff08a
More debug prints
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33437
diff
changeset
|
3072 | parsed_url->port); |
|
66c4b90ff08a
More debug prints
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33437
diff
changeset
|
3073 | else { |
|
66c4b90ff08a
More debug prints
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33437
diff
changeset
|
3074 | g_string_append(url, parsed_url->host); |
|
33439
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
3075 | if (!port_is_default) |
|
33438
66c4b90ff08a
More debug prints
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33437
diff
changeset
|
3076 | g_string_append_printf(url, ":%d", |
|
66c4b90ff08a
More debug prints
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33437
diff
changeset
|
3077 | parsed_url->port); |
|
66c4b90ff08a
More debug prints
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33437
diff
changeset
|
3078 | } |
|
66c4b90ff08a
More debug prints
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33437
diff
changeset
|
3079 | host_printed = TRUE; |
|
66c4b90ff08a
More debug prints
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33437
diff
changeset
|
3080 | } |
|
33439
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
3081 | if (parsed_url->path) { |
|
33438
66c4b90ff08a
More debug prints
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33437
diff
changeset
|
3082 | if (!host_printed && before_host_printed) |
|
66c4b90ff08a
More debug prints
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33437
diff
changeset
|
3083 | g_string_append(url, "{???}"); |
|
66c4b90ff08a
More debug prints
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33437
diff
changeset
|
3084 | g_string_append(url, parsed_url->path); |
|
66c4b90ff08a
More debug prints
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33437
diff
changeset
|
3085 | } |
|
33439
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
3086 | if (parsed_url->fragment) |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
3087 | g_string_append_printf(url, "#%s", parsed_url->fragment); |
|
33429
1ce1faf4e675
Extend URL parsing
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33427
diff
changeset
|
3088 | |
|
33438
66c4b90ff08a
More debug prints
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33437
diff
changeset
|
3089 | return g_string_free(url, FALSE); |
|
33429
1ce1faf4e675
Extend URL parsing
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33427
diff
changeset
|
3090 | } |
|
33439
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
3091 | |
|
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
|
3092 | 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
|
3093 | 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
|
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 | 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
|
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 | 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
|
3098 | } |
|
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 | |
|
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 | const gchar * |
|
34219
eee308def583
HTTP: get rid of purple_url_parse
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34218
diff
changeset
|
3101 | 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
|
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 | 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
|
3104 | |
|
34219
eee308def583
HTTP: get rid of purple_url_parse
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34218
diff
changeset
|
3105 | 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
|
3106 | } |
|
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 | |
|
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 | 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
|
3109 | 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
|
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 | 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
|
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 | 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
|
3114 | } |
|
de45cb0670a5
HTTP: make purple_url_parse deprecated in favor of purple_http_url_parse
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33868
diff
changeset
|
3115 | |
|
de45cb0670a5
HTTP: make purple_url_parse deprecated in favor of purple_http_url_parse
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33868
diff
changeset
|
3116 | 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
|
3117 | 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
|
3118 | { |
|
de45cb0670a5
HTTP: make purple_url_parse deprecated in favor of purple_http_url_parse
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33868
diff
changeset
|
3119 | 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
|
3120 | |
|
de45cb0670a5
HTTP: make purple_url_parse deprecated in favor of purple_http_url_parse
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33868
diff
changeset
|
3121 | 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
|
3122 | } |
|
de45cb0670a5
HTTP: make purple_url_parse deprecated in favor of purple_http_url_parse
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33868
diff
changeset
|
3123 | |
|
de45cb0670a5
HTTP: make purple_url_parse deprecated in favor of purple_http_url_parse
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33868
diff
changeset
|
3124 | 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
|
3125 | 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
|
3126 | { |
|
de45cb0670a5
HTTP: make purple_url_parse deprecated in favor of purple_http_url_parse
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33868
diff
changeset
|
3127 | 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
|
3128 | |
|
de45cb0670a5
HTTP: make purple_url_parse deprecated in favor of purple_http_url_parse
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33868
diff
changeset
|
3129 | 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
|
3130 | } |
|
de45cb0670a5
HTTP: make purple_url_parse deprecated in favor of purple_http_url_parse
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33868
diff
changeset
|
3131 | |
|
de45cb0670a5
HTTP: make purple_url_parse deprecated in favor of purple_http_url_parse
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33868
diff
changeset
|
3132 | 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
|
3133 | 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
|
3134 | { |
|
de45cb0670a5
HTTP: make purple_url_parse deprecated in favor of purple_http_url_parse
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33868
diff
changeset
|
3135 | 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
|
3136 | |
|
de45cb0670a5
HTTP: make purple_url_parse deprecated in favor of purple_http_url_parse
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33868
diff
changeset
|
3137 | 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
|
3138 | } |
|
de45cb0670a5
HTTP: make purple_url_parse deprecated in favor of purple_http_url_parse
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33868
diff
changeset
|
3139 | |
|
de45cb0670a5
HTTP: make purple_url_parse deprecated in favor of purple_http_url_parse
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33868
diff
changeset
|
3140 | 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
|
3141 | 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
|
3142 | { |
|
de45cb0670a5
HTTP: make purple_url_parse deprecated in favor of purple_http_url_parse
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33868
diff
changeset
|
3143 | 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
|
3144 | |
|
de45cb0670a5
HTTP: make purple_url_parse deprecated in favor of purple_http_url_parse
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33868
diff
changeset
|
3145 | 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
|
3146 | } |
|
de45cb0670a5
HTTP: make purple_url_parse deprecated in favor of purple_http_url_parse
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33868
diff
changeset
|
3147 | |
|
33439
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
3148 | /*** HTTP Subsystem ***********************************************************/ |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
3149 | |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
3150 | void purple_http_init(void) |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
3151 | { |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
3152 | purple_http_re_url = g_regex_new("^" |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
3153 | |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
3154 | "(?:" /* host part beginning */ |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
3155 | "([a-z]+)\\:/*" /* protocol */ |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
3156 | "([^/]+)" /* username, password, host, port */ |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
3157 | ")?" /* host part ending */ |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
3158 | |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
3159 | "([^#]*)" /* path */ |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
3160 | |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
3161 | "(?:#" "(.*)" ")?" /* fragment */ |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
3162 | |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
3163 | "$", G_REGEX_OPTIMIZE | G_REGEX_CASELESS, |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
3164 | G_REGEX_MATCH_NOTEMPTY, NULL); |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
3165 | |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
3166 | purple_http_re_url_host = g_regex_new("^" |
|
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 | "(?:" /* user credentials part beginning */ |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
3169 | "([" PURPLE_HTTP_URL_CREDENTIALS_CHARS "]+)" /* username */ |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
3170 | "(?::([" PURPLE_HTTP_URL_CREDENTIALS_CHARS "]+))" /* password */ |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
3171 | "@)?" /* user credentials part ending */ |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
3172 | |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
3173 | "([a-z0-9.-]+)" /* host */ |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
3174 | "(?::([0-9]+))?" /* port*/ |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
3175 | |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
3176 | "$", G_REGEX_OPTIMIZE | G_REGEX_CASELESS, |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
3177 | 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
|
3178 | |
|
33460
c37dd51516aa
Deleting (or expiring) a cookie
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33459
diff
changeset
|
3179 | purple_http_re_rfc1123 = g_regex_new( |
|
c37dd51516aa
Deleting (or expiring) a cookie
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33459
diff
changeset
|
3180 | "^[a-z]+, " /* weekday */ |
|
c37dd51516aa
Deleting (or expiring) a cookie
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33459
diff
changeset
|
3181 | "([0-9]+) " /* date */ |
|
c37dd51516aa
Deleting (or expiring) a cookie
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33459
diff
changeset
|
3182 | "([a-z]+) " /* month */ |
|
c37dd51516aa
Deleting (or expiring) a cookie
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33459
diff
changeset
|
3183 | "([0-9]+) " /* year */ |
|
c37dd51516aa
Deleting (or expiring) a cookie
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33459
diff
changeset
|
3184 | "([0-9]+:[0-9]+:[0-9]+) " /* time */ |
|
c37dd51516aa
Deleting (or expiring) a cookie
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33459
diff
changeset
|
3185 | "(?:GMT|UTC)$", |
|
c37dd51516aa
Deleting (or expiring) a cookie
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33459
diff
changeset
|
3186 | G_REGEX_OPTIMIZE | G_REGEX_CASELESS, |
|
c37dd51516aa
Deleting (or expiring) a cookie
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33459
diff
changeset
|
3187 | G_REGEX_MATCH_NOTEMPTY, NULL); |
|
c37dd51516aa
Deleting (or expiring) a cookie
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33459
diff
changeset
|
3188 | |
|
33448
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_list = NULL; |
|
4d41b1f7b95f
Cancelling all HTTP connections on account disconnect or app shutdown
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33447
diff
changeset
|
3190 | 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
|
3191 | 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
|
3192 | 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
|
3193 | 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
|
3194 | } |
|
4d41b1f7b95f
Cancelling all HTTP connections on account disconnect or app shutdown
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33447
diff
changeset
|
3195 | |
|
4d41b1f7b95f
Cancelling all HTTP connections on account disconnect or app shutdown
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33447
diff
changeset
|
3196 | 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
|
3197 | { |
|
4d41b1f7b95f
Cancelling all HTTP connections on account disconnect or app shutdown
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33447
diff
changeset
|
3198 | PurpleHttpConnection *hc = _hc; |
|
4d41b1f7b95f
Cancelling all HTTP connections on account disconnect or app shutdown
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33447
diff
changeset
|
3199 | purple_http_conn_cancel(hc); |
|
33439
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
3200 | } |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
3201 | |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
3202 | void purple_http_uninit(void) |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
3203 | { |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
3204 | g_regex_unref(purple_http_re_url); |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
3205 | purple_http_re_url = NULL; |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
3206 | g_regex_unref(purple_http_re_url_host); |
|
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
3207 | purple_http_re_url_host = NULL; |
|
33460
c37dd51516aa
Deleting (or expiring) a cookie
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33459
diff
changeset
|
3208 | g_regex_unref(purple_http_re_rfc1123); |
|
c37dd51516aa
Deleting (or expiring) a cookie
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33459
diff
changeset
|
3209 | 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
|
3210 | |
|
4d41b1f7b95f
Cancelling all HTTP connections on account disconnect or app shutdown
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33447
diff
changeset
|
3211 | 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
|
3212 | NULL); |
|
4d41b1f7b95f
Cancelling all HTTP connections on account disconnect or app shutdown
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33447
diff
changeset
|
3213 | |
|
4d41b1f7b95f
Cancelling all HTTP connections on account disconnect or app shutdown
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33447
diff
changeset
|
3214 | 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
|
3215 | 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
|
3216 | 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
|
3217 | 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
|
3218 | "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
|
3219 | |
|
4d41b1f7b95f
Cancelling all HTTP connections on account disconnect or app shutdown
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33447
diff
changeset
|
3220 | 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
|
3221 | 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
|
3222 | 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
|
3223 | 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
|
3224 | 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
|
3225 | 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
|
3226 | 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
|
3227 | purple_http_cancelling_gc = NULL; |
|
33439
178eb69a3f11
Handle redirects
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33438
diff
changeset
|
3228 | } |