cURL / Mailing Lists / curl-users / Single Mail

curl-users

Re: Java Binding libCurl HTTPPost Struct

From: Daniel Stenberg <daniel_at_haxx.se>
Date: Thu, 15 Nov 2007 11:30:51 +0100 (CET)

On Thu, 15 Nov 2007, Brett G. Dymond wrote:

> Hi, I am having problems using the java binding of LibCurl.

Then you post to the wrong mailing list. We do libcurl talk on the
curl-library list. But also note that very few people use or at least talk
about their use of the java binding.

Consider taking follow-ups on libcurl stuff there.

> I tried making java version of httpPost struct:

That sounds futile.

> class HttpPost {
> public HttpPost first = null;
> public HttpPost last = null;
> public String name;
> public String content;
> }
>
> then doing something like:
>
> HttpPost account = new HttpPost(); //default constructor to suppress
> //intialization errors
> account.name = "AccountName";
> account.content = "billing";
> account.first = account;
> account.last = account;

If you want to do multi-part formposts, you need to make sure curl_formadd()
and family works from java. You can't make your own java struct like that.

> setopt(CURL.OPT_HTTPPOST, account); //does not work, expecting an int

CURLOPT_HTTPPOST expects a pointed to a linked list, a list that you can
create with curl_formadd(). For a binding, you most probably need to wrap that
up somehow.

But note that for a "normal" POST, you don't want multi-part.

CURLOPT_POSTFIELDS is then typically your friend.

> There isn't any documentation for:
>
> public int formadd(int form_opt_copyname, String name,
> int form_opt_file, String file,
> int form_opt_type, String type);

Is there _any_ docs for the java binding?

> consequently I am dead in the water.

Going with the java binding unfortunately quite easily ends up that way...

> I have resorted to invoking curl.exe, how do I properly use the formadd() in
> the java binding of libcurl?

I don't know, quite possibly nobody made it possible and thus the binding
needs to be extended to support that first.

Do note that the bindings are all projects managed and maintained outside of
the (lib)curl project itself. The 'javacurl' maintainer/author may not even
read these lists...

-- 
  Commercial curl and libcurl Technical Support: http://haxx.se/curl.html
Received on 2007-11-15