Auto Redirect

Aug 26, 2014 at 12:30 PM
Hi all

Over the past 12 months I have been successfully using casablanca to communicate from linux processes to Azure cloud services and all is going quite well.

I am now trying to communicate with the Azure Media Services REST API following the steps described at and

Unfortunately I have become unstuck with one of the earlier steps that involves manually responding to a 301 redirect sent back by the server.

But it seems that casablanca is performing an auto redirect and I never get a chance to respond as I would like.

Am I correct in thinking that the casablanca libraries are performing an automatic redirect upon receipt of a 301 and, if so, how can I disable this facility?

Aug 27, 2014 at 12:48 PM
Hi all

Hi all

I looked harder at the source code and discovered a very nice capability within the existing http_client_config class which worked a treat:
    whttp::client::http_client_config config;
    config.set_nativehandle_options([](web::http::client::native_handle handle) {
        BOOL result = ::WinHttpSetOption(handle, WINHTTP_OPTION_DISABLE_FEATURE, &data, sizeof(data));
        if (!result)
            DWORD error = GetLastError();

    utility::string_t baseUrl = _XPLATSTR("");

    whttp::client::http_client client(baseUrl, config);
Obviously this will only work for windows but if I face the same problem on linux then I guess I will use a similar technique to turn off automatic redirect.

Very nice casablanca dev team - well done!

Marked as answer by jamesbernarddarcy on 8/27/2014 at 4:49 AM
Aug 27, 2014 at 5:32 PM
Hi James,

Yes in general we try to make our APIs layer so you can dive down deeper to the platform API we build on. What you have should work for Windows desktop, for Windows store/phone we build on a different API IXMLHttpRequest2. For Linux/OS X/iOS/Android we build on top of Boost ASIO. Unfortunately right now we don't have the native handle functionality exposed when on top of Boost ASIO. It is being tracked with this feature request. I don't think it would be a lot of work, if you have interest in implementing we accept contributions.

We have a feature request for redirect support, but haven't started on it at all.

Aug 27, 2014 at 11:51 PM
I'll have a go at getting this done Steve. I'll probably have a go sometime over the weekend.

Aug 28, 2014 at 12:09 AM
Yes would definitely be appreciated!