- From: Norbert Piega <npiega@SeeBeyond.com>
- Date: Mon, 11 Dec 2000 12:40:37 -0500 (EST)
- To: "'Steinar Bang'" <sb@metis.no>, www-lib@w3.org
- Message-ID: <9B85913BDA568742B72DAF6DF54ECBC6012BD202@mail01.stc.com>
Steinar, Thanks a lot!! HTAnchor_addFormatParam(src,"boundary",boundary); was the clincher. Thanks for the useful links as well. -Norbert >>-----Original Message----- >>From: Steinar Bang [mailto:sb@metis.no] >>Sent: Sunday, December 10, 2000 11:25 AM >>To: www-lib@w3.org >>Subject: Re: How do you post multipart/form-data? >> >> >>>>>>> Norbert Piega <npiega@SeeBeyond.com>: >> >>> Anybody out there with sample code for >>> posting multipart/form-data using libwww? >> >>I don't have any code in a usable shareable form. Basically you have >>to build a multipart/form-data request yourself. I build it into a >>char* buffer. Some things to be aware of: >> 1. all part header lines and boundary lines must be CRLF separated >> 2. the boundary between the parts starts with two "-" characters, >> the rest of the boundary, is what's given as the "boundary" >> parameter to the multipart/form-data MIME type >> 3. the terminating boundary has two extra "-" characters trailing it >> >>If "char* data" is a buffer holding the part set up above, and "char* >>boundary" is a text variable holding the boundary (except for the >>stuff added in 2 and 3), and "char* url" is the address you're POSTing >>to, the code for setting up the request, is something like this (NB! >>not tested as runnable code): >> ... >> HTParentAnchor* src = HTTmpAnchor(NULL); >> HTAnchor_setDocument(src,data); >> HTAnchor_setLength(src,strlen(data)); >> HTRequest* request = HTRequest_new(); >> HTAnchor_setFormat(src,HTAtom_for("multipart/form-data")); >> HTAnchor_addFormatParam(src,"boundary",boundary); >> HTAnchor* dest = HTAnchor_findAddress(url); >> int status = HTPutAnchor(src,dest,request); >> ... >> >>Some references: >> [1] RFC2388, the definition of the multipart/form-data MIME type >> <http://www.ietf.org/rfc/rfc2388.txt> >> [2] RFC2046, section 5 describes multiparts, and the syntax of >> multipart boundaries >> <http://www.ietf.org/rfc/rfc2046.txt> >>
Received on Monday, 11 December 2000 12:42:24 UTC