Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do you add custom HTTP headers to Chrome Custom Tabs?

With standard Android WebViews, you use WebView.loadUrl(String url, Map<String, String> additionalHttpHeaders). How do you add your additional headers with Chrome Custom Tabs?

like image 567
Matt Quigley Avatar asked Feb 15 '16 21:02

Matt Quigley


People also ask

How do I add HTTP headers?

Select the web site where you want to add the custom HTTP response header. In the web site pane, double-click HTTP Response Headers in the IIS section. In the actions pane, select Add. In the Name box, type the custom HTTP header name.


2 Answers

I'm not sure if you can send headers or anything related to the http request besides the url. I hope future versions will allow sending headers in Bundle when you establish CustomTabSession or so.

Entire http call is managed in CustomTabActivity.

Edit:

As of recent updates of the library, you can now add Bundle and pass it to the CustomTabsIntent intent as extra with key Browser.EXTRA_HEADERS

Bundle headers = new Bundle();
headers.putString("header1", "value1");
headers.putString("header2", "value2");
customTabsIntent.intent.putExtra(Browser.EXTRA_HEADERS, headers);
like image 51
Nikola Despotoski Avatar answered Oct 16 '22 13:10

Nikola Despotoski


The above mentions solutions won't work for new version of ChromeTab.Please follow this link fix for work around.You can also study the medium post by Romain Piel which implicitly states the usage and the work around for adding headers.

like image 1
DRY Believer Avatar answered Oct 16 '22 13:10

DRY Believer