cordova-plugin-inappbrowser icon indicating copy to clipboard operation
cordova-plugin-inappbrowser copied to clipboard

feat(android,ios): add request headers support

Open al1lhomme opened this issue 6 years ago • 20 comments
trafficstars

Platforms affected

android, ios

What does this PR do?

add request headers support

What testing has been done on this change?

automated test still working test using headers in my app


closes #361 replaces #115

al1lhomme avatar Dec 04 '18 17:12 al1lhomme

Something is broken with the formatting:

npm run eslint
> [email protected] eslint /home/travis/build/apache/cordova-plugin-inappbrowser
> node node_modules/eslint/bin/eslint www && node node_modules/eslint/bin/eslint src && node node_modules/eslint/bin/eslint tests
/home/travis/build/apache/cordova-plugin-inappbrowser/www/inappbrowser.js
  118:1    error  Expected indentation of 8 spaces but found 2 tabs                             indent
  118:2    error  Unexpected tab character                                                      no-tabs
  118:29   error  Trailing spaces not allowed                                                   no-trailing-spaces
  119:1    error  Expected indentation of 8 spaces but found 2 tabs                             indent
  119:2    error  Unexpected tab character                                                      no-tabs
  120:1    error  Expected indentation of 12 spaces but found 3 tabs                            indent
  120:2    error  Unexpected tab character                                                      no-tabs
  121:1    error  Expected indentation of 16 spaces but found 4 tabs                            indent
  121:2    error  Unexpected tab character                                                      no-tabs
  121:51   error  A space is required after ','                                                 comma-spacing
  122:1    error  Expected indentation of 12 spaces but found 3 tabs                            indent
  122:2    error  Unexpected tab character                                                      no-tabs
  122:4    error  Closing curly brace does not appear on the same line as the subsequent block  brace-style
  123:1    error  Expected indentation of 12 spaces but found 3 tabs                            indent
  123:2    error  Unexpected tab character                                                      no-tabs
  124:1    error  Expected indentation of 16 spaces but found 4 tabs                            indent
  124:2    error  Unexpected tab character                                                      no-tabs
  124:22   error  Trailing spaces not allowed                                                   no-trailing-spaces
  125:1    error  Expected indentation of 16 spaces but found 4 tabs                            indent
  125:2    error  Unexpected tab character                                                      no-tabs
  126:1    error  Expected indentation of 20 spaces but found 5 tabs                            indent
  126:2    error  Unexpected tab character                                                      no-tabs
  127:1    error  Expected indentation of 24 spaces but found 6 tabs                            indent
  127:2    error  Unexpected tab character                                                      no-tabs
  127:32   error  A space is required after ','                                                 comma-spacing
  127:52   error  A space is required after ','                                                 comma-spacing
  127:72   error  A space is required after ','                                                 comma-spacing
  128:1    error  Expected indentation of 24 spaces but found 6 tabs                            indent
  128:2    error  Unexpected tab character                                                      no-tabs
  128:60   error  A space is required after ','                                                 comma-spacing
  128:80   error  A space is required after ','                                                 comma-spacing
  128:100  error  A space is required after ','                                                 comma-spacing
  129:1    error  Expected indentation of 24 spaces but found 6 tabs                            indent
  129:2    error  Unexpected tab character                                                      no-tabs
  130:1    error  Expected indentation of 28 spaces but found 7 tabs                            indent
  130:2    error  Unexpected tab character                                                      no-tabs
  131:1    error  Expected indentation of 24 spaces but found 6 tabs                            indent
  131:2    error  Unexpected tab character                                                      no-tabs
  131:15   error  Multiple spaces found before '{'                                              no-multi-spaces
  132:1    error  Expected indentation of 28 spaces but found 7 tabs                            indent
  132:2    error  Unexpected tab character                                                      no-tabs
  132:28   error  Strings must use singlequote                                                  quotes
  133:1    error  Expected indentation of 24 spaces but found 6 tabs                            indent
  133:2    error  Unexpected tab character                                                      no-tabs
  134:1    error  Expected indentation of 24 spaces but found 6 tabs                            indent
  134:2    error  Unexpected tab character                                                      no-tabs
  134:33   error  Strings must use singlequote                                                  quotes
  134:45   error  Trailing spaces not allowed                                                   no-trailing-spaces
  135:1    error  Expected indentation of 20 spaces but found 5 tabs                            indent
  135:2    error  Unexpected tab character                                                      no-tabs
  136:1    error  Expected indentation of 16 spaces but found 4 tabs                            indent
  136:2    error  Unexpected tab character                                                      no-tabs
  137:1    error  Expected indentation of 12 spaces but found 3 tabs                            indent
  137:2    error  Unexpected tab character                                                      no-tabs
  138:1    error  Expected indentation of 8 spaces but found 2 tabs                             indent
  138:2    error  Unexpected tab character                                                      no-tabs
✖ 56 problems (56 errors, 0 warnings)
  35 errors, 0 warnings potentially fixable with the `--fix` option.

Note the last line, use npm run eslint --fix to fix most of those, then run npm run eslint again and fix manually. Then commit and push the result.

janpio avatar Dec 04 '18 23:12 janpio

Looking for the same thing, will this become a feature in the short term?

ehorodyski avatar Jan 16 '19 19:01 ehorodyski

I would like this feature as well. Any ETAs on this?

virtualprodigy avatar Jan 16 '19 19:01 virtualprodigy

You can help by testing this locally (via the fork of @al1lhomme that contains these changes) and reporting back if it worked as expected.

janpio avatar Jan 16 '19 19:01 janpio

Could I ask for progress? This feature is all I need to download any type of files from my server with authentication Header.

metju312 avatar Feb 13 '19 09:02 metju312

@janpio Just merged this into our fork and it seems to be working. It sends headers on the first request and on page reload. Tested on iOS and Android. Did not test using IAB's WKWebView mode.

hvaughan3 avatar May 01 '19 16:05 hvaughan3

This seems the same as PR #115 - but 3 years newer with fewer conflicts.

timbru31 avatar Jul 07 '19 17:07 timbru31

If this feature will allow us to override the User-Agent header, it would fulfill our feature request #502

BrandOuellette avatar Jul 08 '19 07:07 BrandOuellette

Resolved the conflict.

janpio avatar Jul 08 '19 09:07 janpio

Have to test this for both platforms, and on iOS for both webview types.

Someone have a page handy that shows the headers that were used to call it? Then it should be pretty simple to create a test app.

We should probably also try to add this to the tests somehow.

janpio avatar Jul 08 '19 09:07 janpio

Someone have a page handy that shows the headers that were used to call it?

https://postman-echo.com/headers

BrandOuellette avatar Jul 08 '19 12:07 BrandOuellette

Any update on this? I really hope we're not waiting on @al1lhomme because it looks like he hasn't been on github for 9 months.

BrandOuellette avatar Jul 12 '19 14:07 BrandOuellette

We will have to find solutions to the comments that are open here. Some questions regarding the code, no new tests, no tested yet.

Anyone who wants to jump in and is not a contributor here (who can edit the fork directly) can just fork at https://github.com/al1lhomme/cordova-plugin-inappbrowser and then create a new PR to this repo and let us know here via a comment.

janpio avatar Jul 12 '19 15:07 janpio

how can i use the version with custom headers?

jplajpla23 avatar Nov 19 '19 14:11 jplajpla23

Hi, I have tested the PullRequest in Android and it works ok. I have to add a new header to inappbrowser due to the fact that Google will block Google Sign In on January 4, 2021 from embedded browser frameworks. https://developers.googleblog.com/2020/08/guidance-for-our-effort-to-block-less-secure-browser-and-apps.html

Surprisingly, adding the new header "Google-Accounts-Check-OAuth-Login:true", Google Sign seems to be working. I am using browserTarget: '_blank'

starnetdev0 avatar Nov 18 '20 22:11 starnetdev0

I have tested and used the PullRequest in Android and iOS. Headers are working.

BradCB avatar Nov 24 '20 19:11 BradCB

I have tested and used the PullRequest in Android and iOS. Headers are working.

Doesn't work for me. Tested with Cordova Android 9.0.0. Made all changes in InAppBrowser.java, inappbrowser.js and index.js By the way: I have 3 files with name InAppBrowser.java - which one should I edit?

trafficteam7 avatar Nov 25 '20 17:11 trafficteam7

Any news about this PR?

Aiuspaktyn avatar Jan 18 '21 11:01 Aiuspaktyn

Can confirm this works on Android 10, we did not try to patch iOS because our ionic wrapper uses SafariWebviewController and not InAppBrowser

thx @al1lhomme

laurentperez avatar Mar 17 '21 16:03 laurentperez

Helllo guys, any news on this PR? It's been pending since 2018... Being able to pass headers is quite important and useless for several cases...

karimaziz avatar May 28 '21 19:05 karimaziz