How to get wxCurl to automatically follow redirects?
I have a project that uses wxCurl to retrieve a file over HTTP. However, if the server sends a 301 or 302, all I get back is an empty string. I heard there was a way to get cURL to follow the location: headers sent by the server. How is this done?
Also, how do you set t开发者_如何学JAVAhe User-agent header in wxCurl?
Call mywxCurlHttpObject->SetOpt(CURLOPT_FOLLOWLOCATION, 1);
that will set the underlaying libCurl option correctly.
I don't know about the user agent -- you'd have to set that in the header in libCURL, but I don't see a way to set those with the wxCURL wrapper
When you call wxCurlHTTP::Get()
wxCurl overrites all settings you've done so far in wxCurlBase::SetCurlHandleToDefaults()
...
In wxCurlHTTP::Get()
your can add the line SetOpt(CURLOPT_FOLLOWLOCATION, 1);
after the method is calling SetCurlHandleToDefaults()
or you just inherit the method in a new class and add it there.
I've tried it with my RSS import tool written in wxWidgets & wxCurl. It worked!
精彩评论