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:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to