cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: HTTPPOST is not working with servlet

From: Linus Nielsen Feltzing <linus_at_haxx.se>
Date: Fri, 26 Sep 2008 13:17:47 +0200

Shirish Kulkarni wrote:
> I just tried an example (multi-post.c) given in documentation and used a
> servlet. CURLOPT_POSTFIEDS works perfectly with servlet, but it has a
> limitation that only one parameter can be passed at a time and also it
> could not be used if I wanted to do an operation like uploading a file.
>
> This doesn't seem to be working with servlets. Any pointers as what's
> the proper way or if I'm missing something would be highly appreciated.

I think you have to be more specific than this in your problem
description. If your servlet handles file uploading, then it must
support multipart POST. As far as I can see, there is no restriction in
the Servlet architecture that prevents you from using multipart POST,
you just have to parse the MIME data yourself.

Also, CURLOPT_POSTFIELDS is not restricted to one POST field, you are
supposed to pass the entire POST data like this:

curl_setopt(ch, CURLOPT_POSTFIELDS,
"name=Linus&Occupation=Clown&Stupid=yes");

Linus
Received on 2008-09-26