EddyVerbruggen / nativescript-webview-utils

🕸Add request headers to a NativeScript WebView. Perhaps more utils later.
Apache License 2.0
20 stars 17 forks source link

Additional page asset loads do not include custom headers #14

Closed lucastxsilva closed 5 years ago

lucastxsilva commented 5 years ago

Which platform(s) does your issue occur on?

Please, provide the following version numbers that your issue occurs with:

(using the provided demo app tagged in 3.0.1)

Please, tell us how to recreate the issue in as much detail as possible.

If I load a page (https://some.tld/index.html) as the target of the WebView and that page contains links to other assets (say img1.png and img2.png) the GET request for index.html correctly includes the custom headers but the requests for img1.png and img2.png do not include the custom headers. The User-Agent is correctly set in ALL 3 requests.

Is there any code involved?

Sample server header output from my example from above just redirecting the demo app target URL:

Host: some.tld X-Custom-Header: Set at 18:57:00 GMT-0600 (MDT) Accept: text/html,application/xhtml+xml,application/xml;q=0.9,/;q=0.8 User-Agent: My Awesome User-Agent! Accept-Language: en-us appname: Bar :P Accept-Encoding: br, gzip, deflate

127.0.0.1 - - [01/Jul/2019 18:57:02] "GET /index.html HTTP/1.1" 200 -

Host: some.tld Accept: image/png,image/svg+xml,image/;q=0.8,video/;q=0.8,/;q=0.5 User-Agent: My Awesome User-Agent! Accept-Language: en-us Referer: https://some.tld/index.html Accept-Encoding: br, gzip, deflate

127.0.0.1 - - [01/Jul/2019 18:57:02] "GET /img1.png HTTP/1.1" 200 -

Host: some.tld Accept: image/png,image/svg+xml,image/;q=0.8,video/;q=0.8,/;q=0.5 User-Agent: My Awesome User-Agent! Accept-Language: en-us Referer: https://some.tld/index.html Accept-Encoding: br, gzip, deflate

127.0.0.1 - - [01/Jul/2019 18:57:02] "GET /img2.png HTTP/1.1" 200 -

EddyVerbruggen commented 5 years ago

Can you please provide an example of a real tld where this behavior can be observed? And perhaps suggest a fix as well, because this one will not be at the top of my list for quiet some time unfortunately.

lucastxsilva commented 5 years ago

Any tld that loads assets would work however I should have done a bit more homework prior to filing this. Found this as I was trying to come up with a rough PR:

https://stackoverflow.com/questions/28984212/how-to-add-http-headers-in-request-globally-for-ios-in-swift/37474812

Indicates that it simply isn't possible with what Apple has provided in WKWebView. Unfortunate. At this point I'm not sure if you want to close this as "No Fix: Impossible".

EddyVerbruggen commented 5 years ago

Hmm that's a pity, but I'm inclined to believe those folks on the SO issue you linked to. Thanks for taking a deeper look, really appreciate it.