Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Some Requests are getting cancelled when Response Detective is enabled #67

Open
ran-helfer opened this issue Apr 13, 2022 · 2 comments
Open

Comments

@ran-helfer
Copy link

I am using a POST network call which does get cancelled for some unknown reason.

When i am not enabling responseDetective, i do get a response with code 200.

I am using pure URLSession. Not using any external libraries for the request.

When responseDetective is active the request is getting cancelled and on console log i do see:

 [Info] (NetworkLogger, output(requestRepresentation:), 23): [Network] Request id EFF99D2A-7E69-414D-B6C9-9C1D993D4BAD (POST) api/v0/somePath/other
 API MISUSE: NSURLSession delegate RDTURLProtocol: <RDTURLProtocol: 0x6000019f2c10> (0x6000019f2c10)
 API MISUSE: task:willPerformHTTPRedirection:newRequest:completionHandler: completion handler not called
 [Error] (NetworkLogger, output(errorRepresentation:), 47): [Network] Error id EFF99D2A-7E69-414D-B6C9-9C1D993D4BAD domain: NSURLErrorDomain code: -999 reason: cancelado
[Info] (NetworkLogger, output(requestRepresentation:), 23): [Network] Request id 82292D2C-05B7-4950-AC17-9B88516ABA1F (POST) api/v0/somePath/other/xxxxx

@ran-helfer
Copy link
Author

ran-helfer commented Apr 13, 2022

ok - seem like ResponseDetective is not calling completion at:

/// - SeeAlso: URLSessionTaskDelegate.urlSession(_:task:willPerformHTTPRedirection:newRequest:completionHandler:)
	internal func urlSession(_ session: URLSession, task: URLSessionTask, willPerformHTTPRedirection response: HTTPURLResponse, newRequest request: URLRequest, completionHandler: @escaping (URLRequest?) -> Void) {
		client?.urlProtocol(self, wasRedirectedTo: request, redirectResponse: response)
}

So all we need to do is to add a completionHandler() call to this method implementation

@ran-helfer
Copy link
Author

#68

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant