Can I copy NSURLRequest and reuse it?
I am using api with oauth2, and need to refresh the access token when it expires. So I want to resent 开发者_StackOverflow中文版the request after the request is refreshed. I am concerning whether the NSURLConnection will change the http request object. Thanks in advance!
Have you checked out the URL loading guide? It has this in a box in the text:
When a client application initiates a connection or download using an instance of NSMutableURLRequest, a deep copy is made of the request. Changes made to the initiating request have no effect once a download has been initialized.
So you can reuse your request as much as you like without fear of modification. NSURLConnection
works with a copy of it.
精彩评论