- From: Nandika Mirihana <Nandika@eRunway.com>
- Date: Tue, 18 Dec 2001 09:13:14 +0600
- To: www-lib@w3.org
Hi , I am a new commer to the libwww. I want to post data to remote server and get response. I have already send a request ( without data) to the remote http server . but it is not the response that I want . This is my code int HTTPPost::sendRequest() { HTRequest * request = NULL; HTParentAnchor * src = NULL; HTAnchor * dst = NULL; HTChunk * chunck = NULL; char * dst_str = NULL; char * data = NULL; BOOL status = NO; HTChunk* p_pphc_responseData = NULL; dst_str ="http://nagoya.apache.org:5049"; //:5049/axis/servlet/AxisServlet"; data = "hello"; if (data && *data && dst_str && *dst_str) { /* Make source relative to where we are */ char * cwd = HTGetCurrentDirectoryURL(); HTPrint("Posting to %s\n", dst_str); /* Create a request */ request = HTRequest_new(); //set the output format and target stream HTRequest_setOutputStream(request, HTStreamToChunk(request, &p_pphc_responseData, -1)); HTRequest_setOutputFormat(request, HTAtom_for("text/xml")); /* Get an anchor object for the destination URI */ dst = HTAnchor_findAddress(dst_str); /* ** Dream up a source anchor (an editor can for example use this). ** After creation we associate the data that we want to post and ** set some metadata about what the data is. More formats can be found ** ../src/HTFormat.html */ src = HTTmpAnchor(NULL); HTAnchor_setDocument(src, data); HTAnchor_setFormat(src, WWW_PLAINTEXT); /* ** If not posting to an HTTP/1.1 server then content length MUST be ** there. If HTTP/1.1 then it doesn't matter as we just use chunked ** encoding under the covers */ HTAnchor_setLength(src, strlen(data)); /* POST the source to the dest */ status = HTPostAnchor(src, dst, request); //status = HTTraceAbsolute (dst_str,request); /* We don't need these anymore */ HT_FREE(cwd); /* Go into the event loop... */ if (status == YES) HTEventList_loop(request); } return 0; } This is the output Posting to http://nagoya.apache.org:5049 Looking up nagoya.apache.org Looking up nagoya.apache.org Contacting nagoya.apache.org Writing 1Kbytes Reading... Reading... Read 1Kbytes Done! A redirection may change the behavior of this method - proceed anyway? (y/n) y Writing 1Kbytes Reading... Reading... Please give name of file to save in: (RETURN for [C:\Temp\index.html]) Read (0% of 7K) Done! I don't know how "A redirection may change the behavior of this method - proceed anyway? (y/n) y" and "Please give name of file to save in: (RETURN for [C:\Temp\index.html])" come pls help me to send a request with data and get a response. Thank you Regards, -Nandika
Received on Monday, 17 December 2001 22:15:27 UTC