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

How to set/get the timeout on a connection? #11

Open
mattchukabam opened this issue Feb 13, 2013 · 2 comments
Open

How to set/get the timeout on a connection? #11

mattchukabam opened this issue Feb 13, 2013 · 2 comments

Comments

@mattchukabam
Copy link

Is there a default value? I skimmed the source, but couldn't find any instance of "timeout".

@gwk
Copy link
Contributor

gwk commented Feb 13, 2013

Currently it just uses the default value for NSURLConnection. FSNConnection does not expose the NSMutableURLRequest on which you would set the timeout, as well as cache policy and some other potentially useful variables. This should probably be enhanced.

I haven't thought about the design in very much detail, but there are two ways i can see accomplishing this:

1: just add more properties to NSURLConnection that get passed on to the internal NSMutableURLRequest. The advantages are:

  • simplicity of interface, easy to implement;
  • we could potentially enforce a "no property mutations after connection starts" rule (using custom setters for those properties) that might help catch programmer errors.

2: add an NSMutableURLRequest urlRequest property to FSNConnection, and then refactor the +(id)with… constructor so that by default it creates a request with the argument url.

  • maintainers would not have to be responsible for providing public properties to expose all the features (including future ones) that NSMutableURLRequest provides.
  • there are potentially more ways to get unexpected behavior, e.g. setting a property on the request object that then gets silently overwritten in makeNSURLRequest (which would probably deserve to be renamed under this approach).

Thoughts?

@mattchukabam
Copy link
Author

My vote would be for option 1, more properties. There's already a bunch of time-related properties (startTime, challengeInterval, etc), so it doesn't feel incongruous to add more. Also, +(id)withUrl... takes enough params as it is. Lastly, I didn't even have to know there's a NSMutableURLRequest underneath, and so far the only knob I've felt the need to tweak was the timeout, so all the other request properties and options are distracting.

My 2 cents.

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

2 participants