19784
|
1 /**
|
|
2 * @file soap.c
|
|
3 * SOAP connection related process
|
|
4 * Author
|
|
5 * MaYuan<mayuan2006@gmail.com>
|
|
6 * gaim
|
|
7 *
|
|
8 * Gaim is the legal property of its developers, whose names are too numerous
|
|
9 * to list here. Please refer to the COPYRIGHT file distributed with this
|
|
10 * source distribution.
|
|
11 *
|
|
12 * This program is free software; you can redistribute it and/or modify
|
|
13 * it under the terms of the GNU General Public License as published by
|
|
14 * the Free Software Foundation; either version 2 of the License, or
|
|
15 * (at your option) any later version.
|
|
16 *
|
|
17 * This program is distributed in the hope that it will be useful,
|
|
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
20 * GNU General Public License for more details.
|
|
21 *
|
|
22 * You should have received a copy of the GNU General Public License
|
|
23 * along with this program; if not, write to the Free Software
|
|
24 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
25 */
|
|
26 #include "msn.h"
|
|
27 #include "soap.h"
|
|
28
|
19814
|
29 /*local function prototype*/
|
|
30 void msn_soap_set_process_step(MsnSoapConn *soapconn, MsnSoapStep step);
|
|
31
|
19807
|
32 /*setup the soap process step*/
|
19806
|
33 void
|
|
34 msn_soap_set_process_step(MsnSoapConn *soapconn, MsnSoapStep step)
|
|
35 {
|
|
36 soapconn->step = step;
|
|
37 }
|
|
38
|
19785
|
39 //msn_soap_new(MsnSession *session,gpointer data,int sslconn)
|
19784
|
40 /*new a soap connection*/
|
|
41 MsnSoapConn *
|
19785
|
42 msn_soap_new(MsnSession *session,gpointer data,int sslconn)
|
19784
|
43 {
|
|
44 MsnSoapConn *soapconn;
|
|
45
|
|
46 soapconn = g_new0(MsnSoapConn, 1);
|
|
47 soapconn->session = session;
|
19785
|
48 soapconn->parent = data;
|
|
49 soapconn->ssl_conn = sslconn;
|
|
50
|
|
51 soapconn->gsc = NULL;
|
19784
|
52 soapconn->input_handler = -1;
|
|
53 soapconn->output_handler = -1;
|
19804
|
54
|
19806
|
55 msn_soap_set_process_step(soapconn,MSN_SOAP_UNCONNECTED);
|
19804
|
56 soapconn->soap_queue = g_queue_new();
|
19784
|
57 return soapconn;
|
|
58 }
|
|
59
|
|
60 /*ssl soap connect callback*/
|
|
61 void
|
|
62 msn_soap_connect_cb(gpointer data, GaimSslConnection *gsc,
|
|
63 GaimInputCondition cond)
|
|
64 {
|
|
65 MsnSoapConn * soapconn;
|
|
66 MsnSession *session;
|
|
67
|
|
68 gaim_debug_info("MaYuan","Soap connection connected!\n");
|
|
69 soapconn = data;
|
|
70 g_return_if_fail(soapconn != NULL);
|
|
71
|
|
72 session = soapconn->session;
|
|
73 g_return_if_fail(session != NULL);
|
|
74
|
|
75 soapconn->gsc = gsc;
|
|
76
|
|
77 /*connection callback*/
|
|
78 if(soapconn->connect_cb != NULL){
|
|
79 soapconn->connect_cb(data,gsc,cond);
|
|
80 }
|
19804
|
81
|
19806
|
82 msn_soap_set_process_step(soapconn,MSN_SOAP_CONNECTED);
|
19804
|
83 /*we do the SOAP request here*/
|
|
84 msn_soap_post_head_request(soapconn);
|
19784
|
85 }
|
|
86
|
|
87 /*ssl soap error callback*/
|
|
88 static void
|
|
89 msn_soap_error_cb(GaimSslConnection *gsc, GaimSslErrorType error, void *data)
|
|
90 {
|
|
91 MsnSoapConn * soapconn = data;
|
19817
|
92
|
19784
|
93 g_return_if_fail(data != NULL);
|
|
94 gaim_debug_info("MaYuan","Soap connection error!\n");
|
19817
|
95 msn_soap_set_process_step(soapconn, MSN_SOAP_UNCONNECTED);
|
|
96
|
19784
|
97 /*error callback*/
|
|
98 if(soapconn->error_cb != NULL){
|
|
99 soapconn->error_cb(gsc,error,data);
|
|
100 }
|
|
101 }
|
|
102
|
|
103 /*init the soap connection*/
|
|
104 void
|
|
105 msn_soap_init(MsnSoapConn *soapconn,char * host,int ssl,
|
|
106 GaimSslInputFunction connect_cb,
|
|
107 GaimSslErrorFunction error_cb)
|
|
108 {
|
19808
|
109 gaim_debug_info("MaYuan","msn_soap_init...\n");
|
19784
|
110 soapconn->login_host = g_strdup(host);
|
|
111 soapconn->ssl_conn = ssl;
|
|
112 soapconn->connect_cb = connect_cb;
|
|
113 soapconn->error_cb = error_cb;
|
19808
|
114 gaim_debug_info("MaYuan","msn_soap_init...done\n");
|
19804
|
115 }
|
|
116
|
19806
|
117 /*connect the soap connection*/
|
19804
|
118 void
|
|
119 msn_soap_connect(MsnSoapConn *soapconn)
|
|
120 {
|
19784
|
121 if(soapconn->ssl_conn){
|
|
122 gaim_ssl_connect(soapconn->session->account, soapconn->login_host,
|
|
123 GAIM_SSL_DEFAULT_PORT, msn_soap_connect_cb, msn_soap_error_cb,
|
|
124 soapconn);
|
|
125 }else{
|
|
126 }
|
19809
|
127 msn_soap_set_process_step(soapconn,MSN_SOAP_CONNECTING);
|
19784
|
128 }
|
|
129
|
19806
|
130 /*close the soap connection*/
|
19804
|
131 void
|
|
132 msn_soap_close(MsnSoapConn *soapconn)
|
|
133 {
|
|
134 if(soapconn->ssl_conn){
|
|
135 if(soapconn->gsc != NULL){
|
|
136 gaim_ssl_close(soapconn->gsc);
|
|
137 soapconn->gsc = NULL;
|
|
138 }
|
|
139 }else{
|
|
140 }
|
19806
|
141 msn_soap_set_process_step(soapconn,MSN_SOAP_UNCONNECTED);
|
19804
|
142 }
|
|
143
|
19784
|
144 /*destroy the soap connection*/
|
|
145 void
|
|
146 msn_soap_destroy(MsnSoapConn *soapconn)
|
|
147 {
|
19804
|
148 MsnSoapReq *request;
|
|
149
|
19791
|
150 if(soapconn->login_host)
|
|
151 g_free(soapconn->login_host);
|
|
152
|
|
153 if(soapconn->login_path)
|
|
154 g_free(soapconn->login_path);
|
19784
|
155
|
|
156 /*remove the write handler*/
|
|
157 if (soapconn->output_handler > 0){
|
|
158 gaim_input_remove(soapconn->output_handler);
|
|
159 }
|
|
160 /*remove the read handler*/
|
|
161 if (soapconn->input_handler > 0){
|
|
162 gaim_input_remove(soapconn->input_handler);
|
|
163 }
|
|
164 msn_soap_free_read_buf(soapconn);
|
|
165 msn_soap_free_write_buf(soapconn);
|
|
166
|
|
167 /*close ssl connection*/
|
19804
|
168 msn_soap_close(soapconn);
|
|
169
|
19806
|
170 /*process the unhandled soap request*/
|
19804
|
171 while ((request = g_queue_pop_head(soapconn->soap_queue)) != NULL){
|
|
172 msn_soap_request_free(request);
|
19788
|
173 }
|
19804
|
174 g_queue_free(soapconn->soap_queue);
|
19784
|
175 g_free(soapconn);
|
|
176 }
|
|
177
|
19785
|
178 /*check the soap is connected?
|
19806
|
179 * if connected return 1
|
19785
|
180 */
|
|
181 int
|
|
182 msn_soap_connected(MsnSoapConn *soapconn)
|
|
183 {
|
|
184 if(soapconn->ssl_conn){
|
19806
|
185 return (soapconn->gsc == NULL? 0 : 1);
|
19785
|
186 }
|
19806
|
187 return(soapconn->fd>0? 1 : 0);
|
19785
|
188 }
|
|
189
|
19784
|
190 /*read and append the content to the buffer*/
|
|
191 static gssize
|
|
192 msn_soap_read(MsnSoapConn *soapconn)
|
|
193 {
|
19809
|
194 gssize len,requested_len;
|
19796
|
195 char temp_buf[MSN_SOAP_READ_BUFF_SIZE];
|
19784
|
196
|
19809
|
197 // requested_len = (soapconn->need_to_read > 0) ? soapconn->need_to_read : MSN_SOAP_READ_BUFF_SIZE;
|
|
198 requested_len = MSN_SOAP_READ_BUFF_SIZE;
|
19784
|
199 if(soapconn->ssl_conn){
|
19809
|
200 len = gaim_ssl_read(soapconn->gsc, temp_buf,requested_len);
|
19784
|
201 }else{
|
19809
|
202 len = read(soapconn->fd, temp_buf,requested_len);
|
19784
|
203 }
|
|
204 if(len >0){
|
|
205 soapconn->read_buf = g_realloc(soapconn->read_buf,
|
|
206 soapconn->read_len + len + 1);
|
|
207 // strncpy(soapconn->read_buf + soapconn->read_len, temp_buf, len);
|
|
208 memcpy(soapconn->read_buf + soapconn->read_len, temp_buf, len);
|
|
209 soapconn->read_len += len;
|
|
210 soapconn->read_buf[soapconn->read_len] = '\0';
|
|
211 }
|
19814
|
212 gaim_debug_info("MaYuan","++soap ssl read:{%d}\n",len);
|
19784
|
213 // gaim_debug_info("MaYuan","nexus ssl read:{%s}\n",soapconn->read_buf);
|
19814
|
214 return len;
|
19784
|
215 }
|
|
216
|
|
217 /*read the whole SOAP server response*/
|
|
218 void
|
|
219 msn_soap_read_cb(gpointer data, gint source, GaimInputCondition cond)
|
|
220 {
|
|
221 MsnSoapConn *soapconn = data;
|
|
222 MsnSession *session;
|
|
223 int len;
|
|
224 char * body_start,*body_len;
|
|
225 char *length_start,*length_end;
|
|
226
|
19785
|
227 // gaim_debug_misc("MaYuan", "soap read cb\n");
|
19784
|
228 session = soapconn->session;
|
|
229 g_return_if_fail(session != NULL);
|
|
230
|
|
231 if (soapconn->input_handler == -1){
|
|
232 soapconn->input_handler = gaim_input_add(soapconn->gsc->fd,
|
|
233 GAIM_INPUT_READ, msn_soap_read_cb, soapconn);
|
|
234 }
|
|
235
|
|
236 /*read the request header*/
|
|
237 len = msn_soap_read(soapconn);
|
|
238 if (len < 0 && errno == EAGAIN){
|
|
239 return;
|
|
240 }else if (len < 0) {
|
|
241 gaim_debug_error("msn", "read Error!len:%d\n",len);
|
|
242 gaim_input_remove(soapconn->input_handler);
|
|
243 soapconn->input_handler = -1;
|
|
244 g_free(soapconn->read_buf);
|
|
245 soapconn->read_buf = NULL;
|
|
246 soapconn->read_len = 0;
|
|
247 /* TODO: error handling */
|
|
248 return;
|
|
249 }
|
|
250
|
|
251 if(soapconn->read_buf == NULL){
|
|
252 return;
|
|
253 }
|
|
254
|
19788
|
255 if (strstr(soapconn->read_buf, "HTTP/1.1 302") != NULL)
|
|
256 {
|
|
257 /* Redirect. */
|
|
258 char *location, *c;
|
|
259
|
19796
|
260 gaim_debug_error("MaYuan", "soap redirect\n");
|
19788
|
261 location = strstr(soapconn->read_buf, "Location: ");
|
|
262 if (location == NULL)
|
|
263 {
|
|
264 msn_soap_free_read_buf(soapconn);
|
|
265
|
|
266 return;
|
|
267 }
|
|
268 location = strchr(location, ' ') + 1;
|
|
269
|
|
270 if ((c = strchr(location, '\r')) != NULL)
|
|
271 *c = '\0';
|
|
272
|
|
273 /* Skip the http:// */
|
|
274 if ((c = strchr(location, '/')) != NULL)
|
|
275 location = c + 2;
|
|
276
|
|
277 if ((c = strchr(location, '/')) != NULL)
|
|
278 {
|
|
279 g_free(soapconn->login_path);
|
|
280 soapconn->login_path = g_strdup(c);
|
|
281
|
|
282 *c = '\0';
|
|
283 }
|
|
284
|
|
285 g_free(soapconn->login_host);
|
|
286 soapconn->login_host = g_strdup(location);
|
|
287
|
|
288 gaim_ssl_connect(session->account, soapconn->login_host,
|
|
289 GAIM_SSL_DEFAULT_PORT, msn_soap_connect_cb,
|
|
290 msn_soap_error_cb, soapconn);
|
19784
|
291 }
|
19788
|
292 else if (strstr(soapconn->read_buf, "HTTP/1.1 401 Unauthorized") != NULL)
|
|
293 {
|
|
294 const char *error;
|
19784
|
295
|
19796
|
296 gaim_debug_error("MaYuan", "soap 401\n");
|
19788
|
297 if ((error = strstr(soapconn->read_buf, "WWW-Authenticate")) != NULL)
|
|
298 {
|
|
299 if ((error = strstr(error, "cbtxt=")) != NULL)
|
|
300 {
|
|
301 const char *c;
|
|
302 char *temp;
|
|
303
|
|
304 error += strlen("cbtxt=");
|
|
305
|
|
306 if ((c = strchr(error, '\n')) == NULL)
|
|
307 c = error + strlen(error);
|
|
308
|
|
309 temp = g_strndup(error, c - error);
|
|
310 error = gaim_url_decode(temp);
|
|
311 g_free(temp);
|
|
312 }
|
|
313 }
|
19784
|
314
|
19788
|
315 msn_session_set_error(session, MSN_ERROR_SERV_UNAVAILABLE, error);
|
|
316 }
|
|
317 else if (strstr(soapconn->read_buf, "HTTP/1.1 200 OK"))
|
|
318 {
|
|
319 /*OK! process the SOAP body*/
|
|
320 body_start = (char *)g_strstr_len(soapconn->read_buf, soapconn->read_len,"\r\n\r\n");
|
|
321 if(!body_start){
|
|
322 return;
|
|
323 }
|
|
324 body_start += 4;
|
|
325
|
|
326 // gaim_debug_misc("msn", "Soap Read: {%s}\n", soapconn->read_buf);
|
19784
|
327
|
19788
|
328 /* we read the content-length*/
|
|
329 length_start = strstr(soapconn->read_buf, "Content-Length: ");
|
|
330 length_start += strlen("Content-Length: ");
|
|
331 length_end = strstr(length_start, "\r\n");
|
|
332 body_len = g_strndup(length_start,length_end - length_start);
|
19784
|
333
|
19788
|
334 /*setup the conn body */
|
|
335 soapconn->body = body_start;
|
|
336 soapconn->body_len = atoi(body_len);
|
19796
|
337 gaim_debug_misc("MaYuan","SOAP Read length :%d,body len:%d\n",soapconn->read_len,soapconn->body_len);
|
19788
|
338
|
19809
|
339 soapconn->need_to_read = (body_start - soapconn->read_buf +soapconn->body_len) - soapconn->read_len;
|
19796
|
340 if(soapconn->read_len < body_start - soapconn->read_buf + soapconn->body_len){
|
19809
|
341 // if(soapconn->need_to_read >0){
|
19804
|
342 return;
|
19788
|
343 }
|
|
344 g_free(body_len);
|
19784
|
345
|
19785
|
346 #if 1
|
19788
|
347 /*remove the read handler*/
|
|
348 gaim_input_remove(soapconn->input_handler);
|
|
349 soapconn->input_handler = -1;
|
19816
|
350 /*
|
|
351 * close the soap connection,if more soap request came,
|
|
352 * Just reconnect to do it,
|
|
353 *
|
|
354 * To solve the problem described below:
|
|
355 * When I post the soap request in one socket one after the other,
|
|
356 * The first read is ok, But the second soap read always got 0 bytes,
|
|
357 * Weird!
|
|
358 * */
|
|
359 msn_soap_close(soapconn);
|
19785
|
360 #endif
|
|
361
|
19788
|
362 /*call the read callback*/
|
|
363 if(soapconn->read_cb != NULL){
|
19804
|
364 soapconn->read_cb(soapconn,source,0);
|
19788
|
365 }
|
|
366 }
|
19796
|
367 return;
|
19784
|
368 }
|
|
369
|
|
370 void
|
|
371 msn_soap_free_read_buf(MsnSoapConn *soapconn)
|
|
372 {
|
|
373 if(soapconn->read_buf){
|
|
374 g_free(soapconn->read_buf);
|
|
375 }
|
|
376 soapconn->read_buf = NULL;
|
|
377 soapconn->read_len = 0;
|
19809
|
378 soapconn->need_to_read = 0;
|
19784
|
379 }
|
|
380
|
|
381 void
|
|
382 msn_soap_free_write_buf(MsnSoapConn *soapconn)
|
|
383 {
|
|
384 if(soapconn->write_buf){
|
|
385 g_free(soapconn->write_buf);
|
|
386 }
|
|
387 soapconn->write_buf = NULL;
|
|
388 soapconn->written_len = 0;
|
|
389 }
|
|
390
|
|
391 /*Soap write process func*/
|
|
392 static void
|
|
393 msn_soap_write_cb(gpointer data, gint source, GaimInputCondition cond)
|
|
394 {
|
|
395 MsnSoapConn *soapconn = data;
|
|
396 int len, total_len;
|
|
397
|
19796
|
398 g_return_if_fail(soapconn != NULL);
|
|
399 if(soapconn->write_buf == NULL){
|
|
400 gaim_debug_error("MaYuan","soap buffer is NULL\n");
|
|
401 gaim_input_remove(soapconn->output_handler);
|
|
402 soapconn->output_handler = -1;
|
|
403 return;
|
|
404 }
|
19784
|
405 total_len = strlen(soapconn->write_buf);
|
|
406
|
|
407 /*
|
|
408 * write the content to SSL server,
|
|
409 */
|
|
410 len = gaim_ssl_write(soapconn->gsc,
|
|
411 soapconn->write_buf + soapconn->written_len,
|
|
412 total_len - soapconn->written_len);
|
|
413
|
|
414 if (len < 0 && errno == EAGAIN)
|
|
415 return;
|
|
416 else if (len <= 0){
|
|
417 /*SSL write error!*/
|
|
418 gaim_input_remove(soapconn->output_handler);
|
|
419 soapconn->output_handler = -1;
|
|
420 /* TODO: notify of the error */
|
|
421 return;
|
|
422 }
|
|
423 soapconn->written_len += len;
|
|
424
|
|
425 if (soapconn->written_len < total_len)
|
|
426 return;
|
|
427
|
|
428 gaim_input_remove(soapconn->output_handler);
|
|
429 soapconn->output_handler = -1;
|
|
430
|
|
431 /*clear the write buff*/
|
|
432 msn_soap_free_write_buf(soapconn);
|
|
433
|
|
434 /* Write finish!
|
|
435 * callback for write done
|
|
436 */
|
|
437 if(soapconn->written_cb != NULL){
|
|
438 soapconn->written_cb(soapconn, source, 0);
|
|
439 }
|
19810
|
440 /*maybe we need to read the input?*/
|
|
441 msn_soap_read_cb(soapconn,source,0);
|
19784
|
442 }
|
|
443
|
|
444 /*write the buffer to SOAP connection*/
|
|
445 void
|
|
446 msn_soap_write(MsnSoapConn * soapconn, char *write_buf, GaimInputFunction written_cb)
|
|
447 {
|
|
448 soapconn->write_buf = write_buf;
|
|
449 soapconn->written_len = 0;
|
|
450 soapconn->written_cb = written_cb;
|
19785
|
451
|
|
452 /*clear the read buffer first*/
|
19784
|
453 /*start the write*/
|
|
454 soapconn->output_handler = gaim_input_add(soapconn->gsc->fd, GAIM_INPUT_WRITE,
|
|
455 msn_soap_write_cb, soapconn);
|
|
456 msn_soap_write_cb(soapconn, soapconn->gsc->fd, GAIM_INPUT_WRITE);
|
|
457 }
|
|
458
|
19804
|
459 /* New a soap request*/
|
|
460 MsnSoapReq *
|
|
461 msn_soap_request_new(const char *host,const char *post_url,const char *soap_action,
|
|
462 const char *body,
|
|
463 GaimInputFunction read_cb,GaimInputFunction written_cb)
|
|
464 {
|
|
465 MsnSoapReq *request;
|
|
466
|
|
467 request = g_new0(MsnSoapReq, 1);
|
|
468 request->id = 0;
|
|
469
|
|
470 request->login_host = g_strdup(host);
|
|
471 request->login_path = g_strdup(post_url);
|
|
472 request->soap_action = g_strdup(soap_action);
|
|
473 request->body = g_strdup(body);
|
|
474 request->read_cb = read_cb;
|
|
475 request->written_cb = written_cb;
|
|
476
|
|
477 return request;
|
|
478 }
|
|
479
|
|
480 /*free a soap request*/
|
19785
|
481 void
|
19804
|
482 msn_soap_request_free(MsnSoapReq *request)
|
|
483 {
|
|
484 g_return_if_fail(request != NULL);
|
|
485
|
|
486 g_free(request->login_host);
|
|
487 g_free(request->login_path);
|
|
488 g_free(request->soap_action);
|
|
489 g_free(request->body);
|
|
490 request->read_cb = NULL;
|
|
491 request->written_cb = NULL;
|
|
492
|
|
493 g_free(request);
|
|
494 }
|
|
495
|
19807
|
496 /*post the soap request queue's head request*/
|
19804
|
497 void
|
|
498 msn_soap_post_head_request(MsnSoapConn *soapconn)
|
|
499 {
|
19810
|
500 g_return_if_fail(soapconn->soap_queue != NULL);
|
|
501
|
19804
|
502 if(!g_queue_is_empty(soapconn->soap_queue)){
|
|
503 MsnSoapReq *request;
|
|
504 if((request = g_queue_pop_head(soapconn->soap_queue)) != NULL){
|
|
505 msn_soap_post_request(soapconn,request);
|
|
506 }
|
|
507 }
|
19806
|
508 msn_soap_set_process_step(soapconn,MSN_SOAP_CONNECTED_IDLE);
|
19804
|
509 }
|
|
510
|
19807
|
511 /*post the soap request ,
|
|
512 * if not connected, Connected first.
|
|
513 */
|
19804
|
514 void
|
19806
|
515 msn_soap_post(MsnSoapConn *soapconn,MsnSoapReq *request,
|
|
516 MsnSoapConnectInitFunction msn_soap_init_func)
|
19804
|
517 {
|
19816
|
518 if(request != NULL){
|
|
519 g_queue_push_tail(soapconn->soap_queue, request);
|
|
520 }
|
|
521 if(!msn_soap_connected(soapconn)&&(soapconn->step == MSN_SOAP_UNCONNECTED)
|
|
522 &&(!g_queue_is_empty(soapconn->soap_queue))){
|
|
523 /*not connected?and we have something to process connect it first*/
|
19806
|
524 gaim_debug_info("Ma Yuan","soap is not connected!\n");
|
|
525 msn_soap_init_func(soapconn);
|
19804
|
526 msn_soap_connect(soapconn);
|
|
527 return;
|
|
528 }
|
19806
|
529 gaim_debug_info("Ma Yuan","soap connected!\n");
|
19804
|
530 /*if connected, what we only needed to do is to queue the request,
|
|
531 * when SOAP request in the queue processed done, will do this command.
|
|
532 * we just waiting...
|
|
533 */
|
19806
|
534 if(soapconn->step == MSN_SOAP_CONNECTED_IDLE){
|
|
535 msn_soap_post_head_request(soapconn);
|
|
536 }
|
19804
|
537 }
|
|
538
|
|
539 /*Post the soap request action*/
|
|
540 void
|
|
541 msn_soap_post_request(MsnSoapConn *soapconn,MsnSoapReq *request)
|
19785
|
542 {
|
|
543 char * soap_head = NULL;
|
|
544 char * request_str = NULL;
|
|
545
|
19814
|
546 gaim_debug_info("MaYuan","msn_soap_post_request()...\n");
|
19806
|
547 msn_soap_set_process_step(soapconn,MSN_SOAP_PROCESSING);
|
19785
|
548 soap_head = g_strdup_printf(
|
|
549 "POST %s HTTP/1.1\r\n"
|
|
550 "SOAPAction: %s\r\n"
|
|
551 "Content-Type:text/xml; charset=utf-8\r\n"
|
|
552 "Cookie: MSPAuth=%s\r\n"
|
|
553 "User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)\r\n"
|
|
554 "Accept: text/*\r\n"
|
|
555 "Host: %s\r\n"
|
|
556 "Content-Length: %d\r\n"
|
|
557 "Connection: Keep-Alive\r\n"
|
|
558 "Cache-Control: no-cache\r\n\r\n",
|
19804
|
559 request->login_path,
|
|
560 request->soap_action,
|
19785
|
561 soapconn->session->passport_info.mspauth,
|
19804
|
562 request->login_host,
|
|
563 strlen(request->body)
|
19785
|
564 );
|
19804
|
565 request_str = g_strdup_printf("%s%s", soap_head,request->body);
|
19785
|
566 g_free(soap_head);
|
|
567
|
|
568 /*free read buffer*/
|
|
569 msn_soap_free_read_buf(soapconn);
|
19788
|
570 gaim_debug_info("MaYuan","send to server{%s}\n",request_str);
|
19804
|
571 msn_soap_write(soapconn,request_str,request->written_cb);
|
19785
|
572 }
|
|
573
|