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

Add a mechanism to allow direct manipulation of the final URLRequest #47

Open
lilyball opened this issue Nov 12, 2018 · 0 comments
Open

Comments

@lilyball
Copy link
Collaborator

We should probably have a way to attach a block to a request that can be used to customize the final URLRequest immediately prior to handing it to URLSession. This would primarily be used for allowing clients to use new URLSession features before PMHTTP has implemented them.

This should be configurable per-request, but also have a global default. A few alternatives for the global default, not sure yet which way is best:

  1. A block that's used as the default for all requests, but is overridden per-request.
  2. A block that is used as the default for all requests, in addition to the per-request block. The global block would run first, then the per-request block.
  3. A block that is used as the default for environmental requests, but is overridden per-request.

I'm tempted to go with option 2, so that way the global block can also be used to implement other features, such as tracking every single time we send a network request. If we pass the HTTPManager and HTTPManagerRequest objects to the block as well then the block can manually implement the other behaviors (e.g. by bailing if there's a per-request block, or bailing if the URL doesn't belong to the environment).

We could also go ahead and implement all 3 behaviors and have it be configurable, though I'd rather not do this.

If the request is retried, this block would also run on each retry.

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

No branches or pull requests

1 participant