0 Replies
      Latest reply on Mar 25, 2020 6:30 AM by Swiftydev101
      Swiftydev101 Level 1 Level 1 (0 points)

        Hi all,

         

        first time poster and fairly new to Ios Development.

        I'm building a library for redirecting requests in a whitelist to a different host. There are several examples out there about how to do this so most of the the work on that front is finished. The library makes some modifications to the original request if it is in the whitelist, such as encryption, modifications to the body of the request and more. I'm now trying to integrate websocket redirection into the library as well, as the request for the websocket (if in the whitelist) needs to be modified and redirected. the idea is for all underlying tasks to be handled transparently, so the developer using the library doesnt have to handle any of the redirection.

        I am using URLprotocol which for normal HTTP requests works perfectly, where each request is passed to my URL protocols 'canInit' function where it is determined if it is in the whitelist or not, then either handled or not. however a websocket upgrade request is never seen by 'canInit', and so i cant modify the request.

        Is it possible to intercept a URLSessionWebSocketTask HTTP upgrade request? either using URLProtocol or another method?

        thanks to anyone for their response