-
Notifications
You must be signed in to change notification settings - Fork 2
ARP HTTP Interceptor
Ferran Vilà Conesa edited this page Mar 12, 2015
·
2 revisions
The main purpose of this page is to explain the operation of intercepting http calls that occur from the web application to the native platform.
The following chart details this process:

Every http call has to be intercepted by the HTTP Interceptor. For example in Darwin Systems this is done by the NSURLProtocol. When a call is intercepted there are 6 options to handle it.
- GET https://adaptiveapp/*: This option is for web resources (html, css, js...) requested by the application. This requests have to been delegate to the App Packer API (retrieveWebResource). Response could be correct (200) or not found (404)
- POST https://adaptiveapp/*: This option is for Adaptive Native Requests produced by the web application. This requests have to been delegated to the Service Handler.
- The service handler has to obtain a ApiRequest
- Check the Adaptive API version from the ApiRequest apiVersion with the current Adaptive version of the native platform.
- Obtain the bridgeType with the method getBridge() from the AppRegistry
- Execute the api requested with the methodName inside the ApiRequest. This method has to be executed in the main queue (Synchronous methods) or in the background queue (Asynchronous methods). This difference could be done with the asyncId parameter from the ApiRequest. Even for the sync and async requests there's always a sync response for the application.
- Once the native platform have a response, this has to be encapsulated into a APIResponse
- ^data:(.)\/(.);base64,(.*): This regexp is for intercepting the javascript inline requests of the web application. This requests has to be forwarded again to the application.
- GET && whitelist(external resources): This method have to validate the request url with the external resources configured in the io-config.xml file.
- (GET || POST) && whitelist(external services): This method have to validate the request url with the registered services configured in the io-config.xml file.
- default: This is for all the other options. All of this requests has to return a 404 response to the web application.