Search code examples
androidandroid-webviewcrosswalk-runtime

CrossWalk - Accept language header


How can I set the HTTP_ACCEPT_LANGUAGE header with CrossWalk?

I've tried looking for the same methods as the original Android webview (like described here: How can I override Android WebView to use custom Accept-Language header?) but no luck.

The normal webview sends the correct header, CrossWalk however doesn't include my native language, just 'en-US'.


Solution

  • I ended up editing the source, and then compiling from scratch.

    If you want to do the same, the file to look in is "xwalk/runtime/browser/runtime_url_request_context_getter.cc"

    Link to the file on Github

    And then look for this:

    storage_->set_http_user_agent_settings( 
    new net::StaticHttpUserAgentSettings("da-DK,da;q=0.8,en-US;q=0.6,en;q=0.4", base::EmptyString()));
    

    In this we added the "da-DK,da;q=0.8", but you get the idea.

    How to build Crosswalk from source