How to specify options with wxCURLHTTP?

Talk here about issues with one of the components hosted at wxCode, or suggest features for it.
jeancf
Earned a small fee
Earned a small fee
Posts: 16
Joined: Tue Aug 08, 2006 2:42 pm
Location: Brussels, Belgium
Contact:

How to specify options with wxCURLHTTP?

Postby jeancf » Mon Jul 23, 2007 7:50 pm

Hi,

I just started working with wxCURL. I want to use a wxCurlHTTP object to retrieve an xml file from the web into a buffer. I also want to add a user agent string to my HTTP header as some sites such as digg.com require such an option.

So I did this:

Code: Select all

wxString XmlUrl = wxT("http://www.digg.com/rss/index.xml");
char* XmlFile;
char UserAgent[] = "libcurl/7.16.1";

wxCurlHTTP Internet(XmlUrl);
Internet.SetOpt(CURLOPT_USERAGENT, UserAgent);
Internet.Get(XmlFile);


But it does not seem to work as my HTTP header looks like this in Wireshark:

Code: Select all

GET /rss/index.xml HTTP/1.1
Host: digg.com
Accept: */*\r\n
\r\n


As a result digg drops my request and my app remains frozen for a few minutes before giving up.

What am I doing wrong?

Thanks,

/~jc

gururamnath
Moderator
Moderator
Posts: 466
Joined: Sat Sep 18, 2004 2:49 am
Location: California, USA

Re: How to specify options with wxCURLHTTP?

Postby gururamnath » Tue Sep 04, 2007 9:13 pm

Hi,
In the Get function the curl options are reset using the function SetCurlHandleToDefaults (which calls ResetHandle() and which in turn calls curl_easy_reset). I think you need to add a member variable (and getter/setter functions) for user agent and set the curl options in the SetCurlHandleToDefaults (like the username and password).
wxWidgets Form Designer for Delphi and C++ Builder - http://www.twinforms.com

Code snippets for wxWidgets - http://wxsnippets.com


Return to “wxCode”

Who is online

Users browsing this forum: No registered users and 1 guest