curl-library
Re: libcurl produces 0byte files for some refered links
From: Jan <haihappn_at_gmail.com>
Date: Tue, 14 Oct 2008 16:50:41 +0200
Date: Tue, 14 Oct 2008 16:50:41 +0200
Wei,
sorry for the late response.
i checked my 0byte files carefully and i found out that most of them are
redirects to https. my current libcurl build (windows) has no ssl support,
so thats the problem.
one url keeps me wondering:
http://www.youtube.com/?hl=en&tab=n1
when i use this one with your function i get a:
HTTP/1.1 400 Bad Request
but why? in firefox the redirect is working fine...
-- Jan 2008/10/8 Wei Weng <wweng_at_acedsl.com> > Jan wrote: > > Wei, > > > > like i wrote in the beginning of my post: > > http://mail.google.com/mail/?hl=nl&tab=nm <?hl=nl&tab=nm> > > http://www.google.com/calendar/render?hl=nl&tab=nc > > <http://www.google.com/calendar/render?hl=nl&tab=nc> > > > > -- > > Jan > > > > 2008/10/7 Wei Weng <wweng_at_acedsl.com <mailto:wweng_at_acedsl.com>> > > > > mr orgi wrote: > > > Hello, > > > > > > i have some problems using libcurl in my program. > > > > > > if i run it for example for all sublinks of news.google.com > > <http://news.google.com> > > > <http://news.google.com> some links are stored as 0byte files. > > > > > > some examples of these links: > > > http://mail.google.com/mail/?hl=nl&tab=nm > > <http://mail.google.com/mail/?hl=nl&tab=nm> > > > <http://mail.google.com/mail/?hl=nl&tab=nm > > <http://mail.google.com/mail/?hl=nl&tab=nm>> > > > http://www.google.com/calendar/render?hl=nl&tab=nc > > <http://www.google.com/calendar/render?hl=nl&tab=nc> > > > <http://www.google.com/calendar/render?hl=nl&tab=nc > > <http://www.google.com/calendar/render?hl=nl&tab=nc>> > > > > > > these are all links which are refered to another link.. i have > > read the > > > manpages and FOLLOWLOCATION should be the solution for this > > problem. but > > > for some links it still not works. > > > > > > my curl options are the following: > > > > > > CURL *curl; > > > curl = curl_easy_init(); > > > curl_easy_setopt(curl, CURLOPT_URL, link); > > > curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1); > > > curl_easy_setopt(curl, CURLOPT_MAXREDIRS, -1); > > > curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, write_data); > > > curl_easy_setopt(curl, CURLOPT_WRITEDATA, file); > > > curl_easy_perform(curl); > > > curl_easy_cleanup(curl); > > > > > > libcurl version: 7.16.4 > > > Visual Studio 2008 > > > libcurl compiled as static Multi Threaded > > > > > > any suggestions? > > > > > > thanks in advance, > > > Jan > > > > What are the links that it doesn't work for? > > > > Thanks > > Wei > > > > > > Jan, > > I wrote a small test program. > > #include <stdio.h> > > #include <curl/curl.h> > #include <curl/types.h> > #include <curl/easy.h> > > int main(int argc, char **argv) > { > CURL *curl; > CURLcode res; > const char* link; > > curl_global_init(CURL_GLOBAL_ALL); > > curl = curl_easy_init(); > if (curl) > { > link = "http://www.google.com/calendar/render?hl=nl&tab=nc > "; > > curl_easy_setopt(curl, CURLOPT_URL, link); > curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1); > curl_easy_setopt(curl, CURLOPT_MAXREDIRS, -1); > curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L); > > res = curl_easy_perform(curl); > > curl_easy_cleanup(curl); > > fprintf(stderr, "curl told us %d\n", res); > } > > curl_global_cleanup(); > > return 0; > } > > I can successfully connect to google calendar, in fact, below is part of > the > VERBOSE output: > > [ 13:20:25 ] wweng /home/wweng $ ./a.out > * About to connect() to www.google.com port 80 (#0) > * Trying 74.125.47.99... * connected > * Connected to www.google.com (74.125.47.99) port 80 (#0) > > GET /calendar/render?hl=nl&tab=nc HTTP/1.1 > Host: www.google.com > Accept: */* > > < HTTP/1.1 302 Moved Temporarily > < Location: > > https://www.google.com/accounts/ServiceLogin?service=cl&passive=true&nui=1&continue=http%3A%2F%2Fwww.google.com%2Fcalendar%2Frender%3Fhl%3Dnl%26tab%3Dnc&followup=http%3A%2F%2Fwww.google.com%2Fcalendar%2Frender%3Fhl%3Dnl%26tab%3Dnc&hl=nl > < Content-Type: text/html; charset=UTF-8 > < Date: Wed, 08 Oct 2008 17:20:40 GMT > < Expires: Wed, 08 Oct 2008 17:20:40 GMT > < Cache-Control: private, max-age=0 > < Content-Length: 438 > < Server: GFE/1.3 > < > * Ignoring the response-body > * Connection #0 to host www.google.com left intact > * Issue another request to this URL: > ' > https://www.google.com/accounts/ServiceLogin?service=cl&passive=true&nui=1&continue=http%3A%2F%2Fwww.google.com%2Fcalendar%2Frender%3Fhl%3Dnl%26tab%3Dnc&followup=http%3A%2F%2Fwww.google.com%2Fcalendar%2Frender%3Fhl%3Dnl%26tab%3Dnc&hl=nl > ' > * About to connect() to www.google.com port 443 (#1) > * Trying 209.85.165.103... * connected > * Connected to www.google.com (209.85.165.103) port 443 (#1) > * successfully set certificate verify locations: > * CAfile: /etc/ssl/certs/ca-certificates.crt > CApath: none > > Notice the "< HTTP/1.1 302 Moved Temporarily" line? > > So what exactly didn't work for you? > > Thanks > Wei > > >Received on 2008-10-14