How to specify options with wxCURLHTTP?

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

How to specify options with wxCURLHTTP?

Post by jeancf » Mon Jul 23, 2007 7:50 pm


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 require such an option.

So I did this:

Code: Select all

wxString XmlUrl = wxT("");
char* XmlFile;
char UserAgent[] = "libcurl/7.16.1";

wxCurlHTTP Internet(XmlUrl);
Internet.SetOpt(CURLOPT_USERAGENT, UserAgent);
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
Accept: */*\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?



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

Re: How to specify options with wxCURLHTTP?

Post by gururamnath » Tue Sep 04, 2007 9:13 pm

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 -

Code snippets for wxWidgets -

Post Reply