OpenAI icon indicating copy to clipboard operation
OpenAI copied to clipboard

Add SSLDelegateProtocol to StreamingSession

Open batanus opened this issue 1 year ago • 2 comments

What

Add SSLDelegateProtocol delegate to StreamingSession

Why

I've discovered that when initializing OpenAI class with URLSession, it isn't utilized if the request uses StreamingSession (which is logical). Consequently, if a client wishes to implement SSL Pinning in their application and passes their URLSession with a set delegate (which implements the didReceive challenge: URLAuthenticationChallenge method from URLSessionDelegate), URLSessionDelegate methods will be invoked only for requests that don't use StreamingSession and the streaming mechanism.

This PR introduces a mechanism that allows the user to pass their delegate inherited from SSLDelegateProtocol and manually handle didReceive challenge: URLAuthenticationChallenge.

Affected Areas

OpenAI and StreamingSession classes initializers

batanus avatar Apr 02 '24 14:04 batanus