Sending concurrent NSURLConnection requests

Is it possible to simultaneously execute two requests in parallel to the same server using NSURLConnection?

I am trying to do this, and it looks like the second request does not start until the first completes.

+3
source share
3 answers

If you are using the NSURLConnection sync version

+ (NSData *)sendSynchronousRequest:(NSURLRequest *)request returningResponse:(NSURLResponse **)response error:(NSError **)error

you need to start two threads to get the desired behavior, you can do this by moving the load according to your own method and calling this:

- (void)performSelectorInBackground:(SEL)aSelector withObject:(id)arg

Another way would be to use the asynchronous version of NSURLConnection, see the document .

+2
source

NSURLConnection.

+1

The second request seems to wait for the first if cookies exist. I believe that this is done to send the actual cookies in the second request, because they can be changed in response to the first request.

You can turn off cookie processing by setting the HTTPShouldHandleCookies property to NO.

+1
source

Source: https://habr.com/ru/post/1706020/


All Articles