Mercurial > pidgin
comparison src/protocols/msn/httpmethod.c @ 7834:99ffabc6ce73
[gaim-migrate @ 8487]
This patch from Mike Hearn should fix HTTP proxy support for MSN, and
provides another step toward the MSN HTTP access method working. The HTTP
proxy may need testing from other people, but looks like it shouldn't give
any problems.
committer: Tailor Script <tailor@pidgin.im>
author | Christian Hammond <chipx86@chipx86.com> |
---|---|
date | Fri, 12 Dec 2003 00:14:40 +0000 |
parents | 414c701ef1ff |
children | aa44049e8891 |
comparison
equal
deleted
inserted
replaced
7833:ecb31b5d728d | 7834:99ffabc6ce73 |
---|---|
48 static gboolean | 48 static gboolean |
49 http_poll(gpointer data) | 49 http_poll(gpointer data) |
50 { | 50 { |
51 MsnServConn *servconn = data; | 51 MsnServConn *servconn = data; |
52 | 52 |
53 #if 0 | |
53 gaim_debug_info("msn", "Polling server %s.\n", | 54 gaim_debug_info("msn", "Polling server %s.\n", |
54 servconn->http_data->gateway_ip); | 55 servconn->http_data->gateway_ip); |
55 | 56 #endif |
56 msn_http_servconn_poll(servconn); | 57 msn_http_servconn_poll(servconn); |
57 | 58 |
58 servconn->http_data->timer = 0; | 59 servconn->http_data->timer = 0; |
59 | 60 |
60 return FALSE; | 61 return FALSE; |
80 | 81 |
81 size_t | 82 size_t |
82 msn_http_servconn_write(MsnServConn *servconn, const char *buf, size_t size, | 83 msn_http_servconn_write(MsnServConn *servconn, const char *buf, size_t size, |
83 const char *server_type) | 84 const char *server_type) |
84 { | 85 { |
85 size_t s; | 86 size_t s, needed; |
86 char *params; | 87 char *params; |
87 char *temp; | 88 char *temp; |
88 gboolean first; | 89 gboolean first; |
90 int res; /* result of the write operation */ | |
89 | 91 |
90 g_return_val_if_fail(servconn != NULL, 0); | 92 g_return_val_if_fail(servconn != NULL, 0); |
91 g_return_val_if_fail(buf != NULL, 0); | 93 g_return_val_if_fail(buf != NULL, 0); |
92 g_return_val_if_fail(size > 0, 0); | 94 g_return_val_if_fail(size > 0, 0); |
93 g_return_val_if_fail(servconn->http_data != NULL, 0); | 95 g_return_val_if_fail(servconn->http_data != NULL, 0); |
141 "Pragma: no-cache\r\n" | 143 "Pragma: no-cache\r\n" |
142 "Content-Type: application/x-msn-messenger\r\n" | 144 "Content-Type: application/x-msn-messenger\r\n" |
143 "Content-Length: %d\r\n" | 145 "Content-Length: %d\r\n" |
144 "\r\n" | 146 "\r\n" |
145 "%s", | 147 "%s", |
146 servconn->http_data->gateway_ip, | 148 ((strcmp(server_type, "SB") == 0) && first |
149 ? "gateway.messenger.hotmail.com" | |
150 : servconn->http_data->gateway_ip), | |
147 params, | 151 params, |
148 servconn->http_data->gateway_ip, | 152 servconn->http_data->gateway_ip, |
149 (int)size, | 153 (int)size, |
150 buf); | 154 buf); |
151 | 155 |
152 g_free(params); | 156 g_free(params); |
153 | 157 |
154 #if 0 | 158 #if 1 |
155 gaim_debug_misc("msn", "Writing to HTTP: {%s}\n", temp); | 159 gaim_debug_misc("msn", "Writing HTTP to fd %d: {%s}\n", |
160 servconn->fd, temp); | |
156 #endif | 161 #endif |
157 | 162 |
158 s = write(servconn->fd, temp, strlen(temp)); | 163 s = 0; |
159 | 164 needed = strlen(temp); |
165 | |
166 do { | |
167 res = write(servconn->fd, temp, needed); | |
168 if (res >= 0) | |
169 s += res; | |
170 else if (errno != EAGAIN) { | |
171 char *msg = g_strdup_printf("Unable to write to MSN server via HTTP (error %d)", errno); | |
172 gaim_connection_error(servconn->session->account->gc, msg); | |
173 g_free(msg); | |
174 return -1; | |
175 } | |
176 } while (s < needed); | |
177 | |
160 g_free(temp); | 178 g_free(temp); |
161 | 179 |
162 servconn->http_data->waiting_response = TRUE; | 180 servconn->http_data->waiting_response = TRUE; |
163 | 181 |
164 servconn->http_data->virgin = FALSE; | 182 servconn->http_data->virgin = FALSE; |
232 g_return_val_if_fail(size > 0, FALSE); | 250 g_return_val_if_fail(size > 0, FALSE); |
233 g_return_val_if_fail(ret_buf != NULL, FALSE); | 251 g_return_val_if_fail(ret_buf != NULL, FALSE); |
234 g_return_val_if_fail(ret_size != NULL, FALSE); | 252 g_return_val_if_fail(ret_size != NULL, FALSE); |
235 g_return_val_if_fail(error != NULL, FALSE); | 253 g_return_val_if_fail(error != NULL, FALSE); |
236 | 254 |
255 #if 0 | |
256 gaim_debug_info("msn", "parsing data {%s} from fd %d\n", buf, servconn->fd); | |
257 #endif | |
237 servconn->http_data->waiting_response = FALSE; | 258 servconn->http_data->waiting_response = FALSE; |
238 | 259 |
239 gc = gaim_account_get_connection(servconn->session->account); | 260 gc = gaim_account_get_connection(servconn->session->account); |
240 | 261 |
241 /* Healthy defaults. */ | 262 /* Healthy defaults. */ |
242 *ret_buf = NULL; | 263 *ret_buf = NULL; |
243 *ret_size = 0; | 264 *ret_size = 0; |
244 *error = FALSE; | 265 *error = FALSE; |
245 | 266 |
246 /* First, some tests to see if we have a full block of stuff. */ | 267 /* First, some tests to see if we have a full block of stuff. */ |
247 | 268 if (((strncmp(buf, "HTTP/1.1 200 OK\r\n", 17) != 0) && |
248 if (strncmp(buf, "HTTP/1.1 200 OK\r\n", 17) != 0 && | 269 (strncmp(buf, "HTTP/1.1 100 Continue\r\n", 23) != 0)) && |
249 strncmp(buf, "HTTP/1.1 100 Continue\r\n", 23) != 0) | 270 ((strncmp(buf, "HTTP/1.0 200 OK\r\n", 17) != 0) && |
271 (strncmp(buf, "HTTP/1.0 100 Continue\r\n", 23) != 0))) | |
250 { | 272 { |
251 *error = TRUE; | 273 *error = TRUE; |
252 | |
253 return FALSE; | 274 return FALSE; |
254 } | 275 } |
255 | 276 |
256 if (strncmp(buf, "HTTP/1.1 100 Continue\r\n", 23) == 0) | 277 if (strncmp(buf, "HTTP/1.1 100 Continue\r\n", 23) == 0) |
257 { | 278 { |