Hi Woo,

I know it is a bit confusing but "HTTPClient" is not the same as
"Commons HttpClient". Please follow the link given in the FAQ entry (I
hope it's still valid!). That said development on "HTTPClient" has been
stopped for a while now.

I think the best would be for you to post a mail to the jakarta commons
mailing list to see if any project there supports sending
multipart/form-data.

Alternatively, if you have some time, you can submit a patch for Cactus
and I'll apply it.

Hope it helps,
-Vincent

> -----Original Message-----
> From: Woo, Chen Ching [mailto:[EMAIL PROTECTED]]
> Sent: 18 September 2002 20:47
> To: Cactus Users List
> Subject: How to do multipart/form-data testing?
> 
> Hi all,
> 
> How do I send a multipart/form-data request in Cactus? The FAQ says
use
> the following code, but the HttpClient's API(now part of the Commons
> project)has changed a lot, especially now the HTTPClient.Codecs class
no
> longer exists. Can anyone help?
> 
> Thanks a lot in advance.
> 
> chen.
> 
> import HTTPClient.Codecs;
> import HTTPClient.NVPair;
> .
> .
> .
> NVPair[] hdrs = new NVPair[1];
> 
> public void beginUpload(WebRequest theRequest)
> {
>   NVPair[] opts = { new NVPair("option", "myoption") };
>   NVPair[] file = { new NVPair("comment", "/home/alan/src.zip") };
>   try {
>     byte[] data = Codecs.mpFormDataEncode(opts, file, hdrs);
>     InputStream i = new ByteArrayInputStream(data);
>     theRequest.setUserData(i);
>     theRequest.setContentType(hdrs[0].getValue());
>     i.close();
>   } catch (IOException e) {
>     System.out.println("Error Building Multipart");
>   }
> }
> 
> --
> To unsubscribe, e-mail:   <mailto:cactus-user-
> [EMAIL PROTECTED]>
> For additional commands, e-mail: <mailto:cactus-user-
> [EMAIL PROTECTED]>



--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to