comparison src/protocols/msn/httpmethod.c @ 9158:c30d81b4dd22

[gaim-migrate @ 9942] Patch from Felipe Contreras to sync our MSN prpl with what's in his tree. He says this may fix a couple bugs, but the important thing is the restructuring of how MsnMessages work. Lots of style changes and other stuff as well. committer: Tailor Script <tailor@pidgin.im>
author Christian Hammond <chipx86@chipx86.com>
date Tue, 01 Jun 2004 06:42:20 +0000
parents 9885420f049f
children 502707ca1836
comparison
equal deleted inserted replaced
9157:bd1ea0a717d7 9158:c30d81b4dd22
58 58
59 if (servconn->http_data->dirty) 59 if (servconn->http_data->dirty)
60 { 60 {
61 #if 0 61 #if 0
62 gaim_debug_info("msn", "Polling server %s.\n", 62 gaim_debug_info("msn", "Polling server %s.\n",
63 servconn->http_data->gateway_ip); 63 servconn->http_data->gateway_host);
64 #endif 64 #endif
65 msn_http_servconn_poll(servconn); 65 msn_http_servconn_poll(servconn);
66 } 66 }
67 } 67 }
68 68
139 { 139 {
140 if (server_type) 140 if (server_type)
141 { 141 {
142 params = g_strdup_printf("Action=open&Server=%s&IP=%s", 142 params = g_strdup_printf("Action=open&Server=%s&IP=%s",
143 server_type, 143 server_type,
144 servconn->http_data->gateway_ip); 144 servconn->http_data->gateway_host);
145 } 145 }
146 else 146 else
147 { 147 {
148 params = g_strdup_printf("Action=open&IP=%s", 148 params = g_strdup_printf("Action=open&IP=%s",
149 servconn->http_data->gateway_ip); 149 servconn->http_data->gateway_host);
150 } 150 }
151 } 151 }
152 else 152 else
153 { 153 {
154 params = g_strdup_printf("SessionID=%s", 154 params = g_strdup_printf("SessionID=%s",
168 "Content-Length: %d\r\n" 168 "Content-Length: %d\r\n"
169 "\r\n" 169 "\r\n"
170 "%s", 170 "%s",
171 ((strcmp(server_type, "SB") == 0) && first 171 ((strcmp(server_type, "SB") == 0) && first
172 ? "gateway.messenger.hotmail.com" 172 ? "gateway.messenger.hotmail.com"
173 : servconn->http_data->gateway_ip), 173 : servconn->http_data->gateway_host),
174 params, 174 params,
175 servconn->http_data->gateway_ip, 175 servconn->http_data->gateway_host,
176 (int)size, 176 (int)size,
177 buf); 177 buf);
178 178
179 g_free(params); 179 g_free(params);
180 180
184 #endif 184 #endif
185 185
186 s = 0; 186 s = 0;
187 needed = strlen(temp); 187 needed = strlen(temp);
188 188
189 do { 189 do
190 {
190 res = write(servconn->fd, temp, needed); 191 res = write(servconn->fd, temp, needed);
191 if (res >= 0) 192 if (res >= 0)
192 s += res; 193 s += res;
193 else if (errno != EAGAIN) { 194 else if (errno != EAGAIN)
195 {
194 char *msg = g_strdup_printf("Unable to write to MSN server via HTTP (error %d)", errno); 196 char *msg = g_strdup_printf("Unable to write to MSN server via HTTP (error %d)", errno);
195 gaim_connection_error(servconn->session->account->gc, msg); 197 gaim_connection_error(servconn->session->account->gc, msg);
196 g_free(msg); 198 g_free(msg);
197 return -1; 199 return -1;
198 } 200 }
232 "Connection: Keep-Alive\r\n" 234 "Connection: Keep-Alive\r\n"
233 "Pragma: no-cache\r\n" 235 "Pragma: no-cache\r\n"
234 "Content-Type: application/x-msn-messenger\r\n" 236 "Content-Type: application/x-msn-messenger\r\n"
235 "Content-Length: 0\r\n" 237 "Content-Length: 0\r\n"
236 "\r\n", 238 "\r\n",
237 servconn->http_data->gateway_ip, 239 servconn->http_data->gateway_host,
238 servconn->http_data->session_id, 240 servconn->http_data->session_id,
239 servconn->http_data->gateway_ip); 241 servconn->http_data->gateway_host);
240 242
241 #if 0 243 #if 0
242 gaim_debug_misc("msn", "Writing to HTTP: {%s}\n", temp); 244 gaim_debug_misc("msn", "Writing to HTTP: {%s}\n", temp);
243 #endif 245 #endif
244 246
271 g_return_val_if_fail(ret_buf != NULL, FALSE); 273 g_return_val_if_fail(ret_buf != NULL, FALSE);
272 g_return_val_if_fail(ret_size != NULL, FALSE); 274 g_return_val_if_fail(ret_size != NULL, FALSE);
273 g_return_val_if_fail(error != NULL, FALSE); 275 g_return_val_if_fail(error != NULL, FALSE);
274 276
275 #if 0 277 #if 0
276 gaim_debug_info("msn", "parsing data {%s} from fd %d\n", buf, servconn->fd); 278 gaim_debug_info("msn", "parsing data {%s} from fd %d\n",
279 buf, servconn->fd);
277 #endif 280 #endif
278 servconn->http_data->waiting_response = FALSE; 281 servconn->http_data->waiting_response = FALSE;
279 282
280 gc = gaim_account_get_connection(servconn->session->account); 283 gc = gaim_account_get_connection(servconn->session->account);
281 284
284 *ret_size = 0; 287 *ret_size = 0;
285 *error = FALSE; 288 *error = FALSE;
286 289
287 /* First, some tests to see if we have a full block of stuff. */ 290 /* First, some tests to see if we have a full block of stuff. */
288 if (((strncmp(buf, "HTTP/1.1 200 OK\r\n", 17) != 0) && 291 if (((strncmp(buf, "HTTP/1.1 200 OK\r\n", 17) != 0) &&
289 (strncmp(buf, "HTTP/1.1 100 Continue\r\n", 23) != 0)) && 292 (strncmp(buf, "HTTP/1.1 100 Continue\r\n", 23) != 0)) &&
290 ((strncmp(buf, "HTTP/1.0 200 OK\r\n", 17) != 0) && 293 ((strncmp(buf, "HTTP/1.0 200 OK\r\n", 17) != 0) &&
291 (strncmp(buf, "HTTP/1.0 100 Continue\r\n", 23) != 0))) 294 (strncmp(buf, "HTTP/1.0 100 Continue\r\n", 23) != 0)))
292 { 295 {
293 *error = TRUE; 296 *error = TRUE;
297
294 return FALSE; 298 return FALSE;
295 } 299 }
296 300
297 if (strncmp(buf, "HTTP/1.1 100 Continue\r\n", 23) == 0) 301 if (strncmp(buf, "HTTP/1.1 100 Continue\r\n", 23) == 0)
298 { 302 {
406 410
407 /* Set the new data. */ 411 /* Set the new data. */
408 if (servconn->http_data->session_id != NULL) 412 if (servconn->http_data->session_id != NULL)
409 g_free(servconn->http_data->session_id); 413 g_free(servconn->http_data->session_id);
410 414
411 if (servconn->http_data->old_gateway_ip != NULL) 415 if (servconn->http_data->old_gateway_host != NULL)
412 g_free(servconn->http_data->old_gateway_ip); 416 g_free(servconn->http_data->old_gateway_host);
413 417
414 servconn->http_data->old_gateway_ip = servconn->http_data->gateway_ip; 418 servconn->http_data->old_gateway_host =
419 servconn->http_data->gateway_host;
415 420
416 servconn->http_data->session_id = session_id; 421 servconn->http_data->session_id = session_id;
417 servconn->http_data->gateway_ip = gw_ip; 422 servconn->http_data->gateway_host = gw_ip;
418 } 423 }
419 424
420 g_free(headers); 425 g_free(headers);
421 426
422 *ret_buf = body; 427 *ret_buf = body;