comparison libpurple/protocols/msn/soap2.c @ 20529:1180920ffcec

handle unauthenticated soap connection
author Ka-Hing Cheung <khc@hxbc.us>
date Mon, 24 Sep 2007 06:04:54 +0000
parents 06527cc0f79b
children 719ce4acfcb9
comparison
equal deleted inserted replaced
20528:06527cc0f79b 20529:1180920ffcec
363 443, msn_soap_connected_cb, msn_soap_error_cb, conn); 363 443, msn_soap_connected_cb, msn_soap_error_cb, conn);
364 } else if (conn->connected) { 364 } else if (conn->connected) {
365 int len = -1; 365 int len = -1;
366 char *body = xmlnode_to_str(req->message->xml, &len); 366 char *body = xmlnode_to_str(req->message->xml, &len);
367 GSList *iter; 367 GSList *iter;
368 char *authstr = NULL;
368 369
369 g_queue_pop_head(conn->queue); 370 g_queue_pop_head(conn->queue);
370 371
371 conn->buf = g_string_new(""); 372 conn->buf = g_string_new("");
373
374 if (conn->session->passport_info.mspauth)
375 authstr = g_strdup_printf("Cookie: MSPAuth=%s\r\n",
376 conn->session->passport_info.mspauth);
377
372 378
373 g_string_append_printf(conn->buf, 379 g_string_append_printf(conn->buf,
374 "POST %s HTTP/1.1\r\n" 380 "POST %s HTTP/1.1\r\n"
375 "SOAPAction: %s\r\n" 381 "SOAPAction: %s\r\n"
376 "Content-Type:text/xml; charset=utf-8\r\n" 382 "Content-Type:text/xml; charset=utf-8\r\n"
377 "Cookie: MSPAuth=%s\r\n" 383 "%s"
378 "User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)\r\n" 384 "User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)\r\n"
379 "Accept: */*\r\n" 385 "Accept: */*\r\n"
380 "Host: %s\r\n" 386 "Host: %s\r\n"
381 "Content-Length: %d\r\n" 387 "Content-Length: %d\r\n"
382 "Connection: Keep-Alive\r\n" 388 "Connection: Keep-Alive\r\n"
383 "Cache-Control: no-cache\r\n", 389 "Cache-Control: no-cache\r\n",
384 req->path, req->message->action, 390 req->path, req->message->action ? req->message->action : "",
385 conn->session->passport_info.mspauth, 391 authstr ? authstr : "", conn->host, len);
386 conn->host, len);
387 392
388 for (iter = req->message->headers; iter; iter = iter->next) { 393 for (iter = req->message->headers; iter; iter = iter->next) {
389 g_string_append(conn->buf, (char *)iter->data); 394 g_string_append(conn->buf, (char *)iter->data);
390 g_string_append(conn->buf, "\r\n"); 395 g_string_append(conn->buf, "\r\n");
391 } 396 }
397 conn->current_request = req; 402 conn->current_request = req;
398 403
399 conn->event_handle = purple_input_add(conn->ssl->fd, 404 conn->event_handle = purple_input_add(conn->ssl->fd,
400 PURPLE_INPUT_WRITE, msn_soap_write_cb, conn); 405 PURPLE_INPUT_WRITE, msn_soap_write_cb, conn);
401 msn_soap_write_cb(conn, conn->ssl->fd, PURPLE_INPUT_WRITE); 406 msn_soap_write_cb(conn, conn->ssl->fd, PURPLE_INPUT_WRITE);
407
408 g_free(authstr);
402 } 409 }
403 } 410 }
404 411
405 return FALSE; 412 return FALSE;
406 } 413 }