curl-users
facing Space problem in cURL
Date: Fri, 14 Jan 2011 17:15:44 +0530
Hello,
I am completely new to the cURL. I am trying to integrate Apache Solr with c
client.
However I am trying to post http request through c client as following.
How ever I am not getting expected reply from the cURL.
but when I execute same thing through command promt it works fine.
curl "
http://localhost:8983/solr/update/extract?literal.id=doc1&uprefix=attr_&fmap.content=attr_content&fmap.div=foo_t&boost.foo_t=3&literal.tcent_dataItemOBID=vbofJekpni6w5pdmm70a-buSsuper%20usersuWLocdoc1.pdf&commit=true""
-F "myfile=@D:/fs/2007_MP6/suWLoc/doc1.pdf"
Can any one help to find what is the exact problem in my code?
int indexInSolr()
{
status dstat = OKAY;
CURL *curl;
CURLcode res;
curl = curl_easy_init();
if(curl)
{
struct solrString s;
init_string(&s);
//curl_easy_setopt(curl, CURLOPT_URL, cURLString);
curl_easy_setopt(curl, CURLOPT_URL, "
http://localhost:8983/solr/update/extract?literal.id=doc1&uprefix=attr_&fmap.content=attr_content&fmap.div=foo_t&boost.foo_t=3&literal.tcent_dataItemOBID=vbofJekpni6w5pdmm70a-buSsuper%20usersuWLocdoc1.pdf&commit=true\"\"
-F \"myfile=@D:\\fs\\2007_MP6\\suWLoc\\doc1.pdf");
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, writefunc);
curl_easy_setopt(curl, CURLOPT_WRITEDATA, &s);
res = curl_easy_perform(curl);
printf("\nPrinting value written in solrString \n%s\n", s.ptr);
printf("\nPrinting res in solrString \n%d\n", res);
free(s.ptr);
/* always cleanup */
curl_easy_cleanup(curl);
return 0;
};
struct solrString {
char *ptr;
size_t len;
};
void init_string(struct solrString *s) {
s->len = 0;
s->ptr = malloc(s->len+1);
if (s->ptr == NULL) {
fprintf(stderr, "malloc() failed\n");
exit(EXIT_FAILURE);
}
s->ptr[0] = '\0';
};
size_t writefunc(void *ptr, size_t size, size_t nmemb, struct solrString *s)
{
int input;
size_t new_len = s->len + size*nmemb;
//scanf("Please enter input for call bak function \n%d",&input);
s->ptr = realloc(s->ptr, new_len+1);
if (s->ptr == NULL) {
fprintf(stderr, "realloc() failed\n");
exit(EXIT_FAILURE);
}
memcpy(s->ptr+s->len, ptr, size*nmemb);
s->ptr[new_len] = '\0';
s->len = new_len;
return size*nmemb;
};
Thanks and Regards,
Prasad
-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-users
FAQ: http://curl.haxx.se/docs/faq.html
Etiquette: http://curl.haxx.se/mail/etiquette.html
Received on 2011-01-14