[TIMOB-17467] iOS/Android: Expose request-headers for WebView
GitHub Issue | n/a |
---|---|
Type | New Feature |
Priority | Medium |
Status | Closed |
Resolution | Fixed |
Resolution Date | 2016-08-29T21:34:59.000+0000 |
Affected Version/s | Release 3.3.0 |
Fix Version/s | Release 6.1.0 |
Components | Android, iOS |
Labels | TCSupport |
Reporter | Tomasz Krzywda |
Assignee | Hans Knöchel |
Created | 2014-07-30T10:37:07.000+0000 |
Updated | 2017-02-11T13:39:01.000+0000 |
Description
Steps to Reproduce
The concept is simple, to let user add custom headers to web view requests. Example:
var webView = Ti.UI.createWebView();
webView.setHeaders({header1: 'Hello', header2: 'World'});
or directly during creation:
var webView = Ti.UI.createWebView({
headers: {header1: 'Hello', header2: 'World'}
});
Actual Result
No acces to web view headers, except for user-agent.Expected Result
Can add custom header to request.Attachments
File | Date | Size |
---|---|---|
IMG_0486.JPG | 2016-11-21T18:54:00.000+0000 | 2409773 |
Thanks for your report. The priority will be set by the Platform team.
Any update? There is any possibility to pass a custom referrer URL, like: https//:app.foo.com ? Thanks
Sorry, unfortunately I am not working on that project anymore and I can't set up test env.
Started a fork: https://github.com/m1ga/titanium_mobile/commit/9555725b2fe532bd7f7c46a59fc911da9df6b6da you can use it like this:
still work in progress but my first tests are working
+1 for this feature. https://github.com/mano-mykingdom/titanium_mobile/commit/091149c94550acaac8acd1241db558fa3db2ce4b
Cleaned Android PR version: https://github.com/appcelerator/titanium_mobile/pull/8230
Parity-PR for iOS: https://github.com/appcelerator/titanium_mobile/pull/8239
Assigning the review to Ash for Android. After merged, please re-assign the reviewer to [~apetkov] to review and merge the iOS-part. I will update the docs when everything is tested and merged. Demo for QE (should work cross-platform, [~michael] to confirm):
Android PR https://github.com/appcelerator/titanium_mobile/pull/8230 merged. [~hansknoechel]
[~apetkov] to review the iOS-PR.
[~hansknoechel]Attached is a screenshot on a device. Is this what is expected to be seen? !IMG_0486.JPG|thumbnail!
Yes
Thanks, Hans. So I did verify that the feature works as expected with the following environment: NPM Version: 2.15.9 Node Version: 4.5.0 Mac OS: 10.12.1 Appc CLI: 6.0.0 Appc CLI NPM: 4.2.8 Titanium SDK version: 6.1.0.v20161122053743 Appcelerator Studio, build: 4.8.0.201611121409 Xcode 8.1 GM iOS Device: iOS 10.1.1 Android Device: 6.0.1 I tried the extended demo code provided by Michael G, and tried all three test scenarios. The following tests performed as expected on both the Android and iOS devices: 1. requestHeaders property are set during creation 2. custom headers survive a reload (press button reload, output stays the same) 3. header can be changed with change header + reload to display the output
Hi I had several issues with the iOS implementation.
*A second POST request to the same address*: Because of the second loadUrlRequest call it could not send a second POST request. I mean the call
in the implementation. I made a fix for that see TIMOB-24329 But still this fix does not solve all request cycles propberly which can happen in a WebView itself.
*Own Request-Headers and Basic-Authentication-Headers*: I had a strange behaviour with including Basic Authentication and my own Request-Headers. It was difficult to determine the error but in the end I removed the second [self loadURLRequest:newRequest]; by setting the headers and Basic Authentication in the loadURLRequest itself. See at https://github.com/chreck/titanium_mobile/commit/4d67118bebe74e9c9f008df1e40327ffb44feb8e
Best regards ChristophHi I made a Jira about this issue. AC-4786 Best regards Christoph