cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: post without specific variable name

From: Robin Ericsson <lobbin_at_localhost.nu>
Date: 24 Jan 2002 15:01:42 +0100

On Thu, 2002-01-24 at 14:33, Daniel Stenberg wrote:
> On 24 Jan 2002, Robin Ericsson wrote:
>
> > I'm trying to reproduce the following javacode into c.
> >
> > This is no problem except for "writer.println(theXMLMessage)", which is a
> > java string containing a XML document..
> >
> > curl doesn't seem to want to post without naming a variable, using libcurl
> > 7.9.2.
>
> I don't know any internals that backs up that statement. When libcurl sends a
> POST, it sends whatever data you tell it to, it certainly has no knowledge
> about naming variables or similar. That's a concept far beyond libcurl's
> sphere of knowledge.
>
> [ java code cut out ]
>
> Instead of posting the (working) java code, why don't you instead show us the
> C code that doesn't work?

struct HttpPost *formpost = NULL, *lastptr = NULL;

curl_formadd(&formpost, &lastptr,
// CURLFORM_COPYNAME, "variable",
             CURLFORM_COPYCONTENTS, "some string",
             CURLFORM_END);
     
curl_easy_setopt(curl, CURLOPT_ERRORBUFFER, &errorbuf);
curl_easy_setopt(curl, CURLOPT_FILE, &retval);
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, WriteMemoryCallback);
curl_easy_setopt(curl, CURLOPT_HTTPPOST, formpost);
curl_easy_setopt(curl, CURLOPT_URL, "http://some.url/");
       
int res = curl_easy_perform(curl);

this ends up in a GET request, however, if I remove the comment on
COPYNAME, curl makes a POST request.

regards
robin
Received on 2002-01-24