Skip to content

Enable managerModifyRequest to modify redirectCount #208

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

Merged
merged 1 commit into from
Jul 9, 2016

Conversation

soenkehahn
Copy link
Contributor

This changes the behavior of httpRaw and httpRaw': They will not apply mModifyRequest on given requests. (Since they are only exported in Internal modules I hope this is ok.)

I'm not very happy with this code (apart from the test case). How the request is modified has gotten very confusing. This is also very visible in the confusing non-informative names for the requests (req0, req, req', req'' and now inputReq). I'm not very familiar with this code internally, so I'm not sure how to refactor things without breaking other features. I may look into this in the next days, but any pointers (or code) would be appreciated.

One more concrete question: Does it even makes sense that httpRaw' returns a Request if it doesn't apply mModifyRequest to it anymore?

@snoyberg
Copy link
Owner

snoyberg commented Jul 4, 2016

I'm currently halfway through a refactoring for http-client 0.5. It doesn't exactly simplify this bit of logic, but it does touch on it. Would you mind holding off until that refactoring is complete and then reapplying this PR to the new master?

@soenkehahn
Copy link
Contributor Author

Yes, sounds good.

@snoyberg
Copy link
Owner

snoyberg commented Jul 4, 2016

Alright, I've merged to master.

@soenkehahn soenkehahn force-pushed the modifyRedirectCount branch from a3bfc7b to 67e1252 Compare July 5, 2016 07:11
@soenkehahn
Copy link
Contributor Author

I've rebased my branch and changed it, adding some more tests and doing things slightly differently. I'd appreciate any feedback.

There's also a few questions where I don't know how we want http-client to behave. E.g.:

  • What if a Request wants to override the Manager with requestManagerOverride? But the Manager also wants to change the Request with managerModifyRequest, possibly changing requestManagerOverride? Who wins? (Maybe this can largely be ignored as a misuse of the library.)
  • Is managerModifyRequest meant to be executed once for every sent request if redirects are being followed? (This PR currently executes it twice for the first request unfortunately.)
  • Is it important whether mSetProxy is executed before or after managerModifyRequest? This PR changes the order.

cc: @snoyberg

@snoyberg
Copy link
Owner

snoyberg commented Jul 5, 2016

Looks OK to me. I agree that the competing features have made things a little convoluted here. How about taking a simplification pass like so:

  1. Define the expected behavior clearly. IMO, this would probably be something like "let the Request override the Manager first, then use the Manager to modify the Request, and then proceed".
  2. Capture this logic in a comment and a single function of type (something like) getModifiedRequestManager :: Request -> Manager -> IO (Request, Manager).
  3. Use that function in all relevant places instead of sprinkling it (as I have until now) between multiple functions

@soenkehahn soenkehahn force-pushed the modifyRedirectCount branch 2 times, most recently from 013f56b to 9116b86 Compare July 8, 2016 22:21
@soenkehahn
Copy link
Contributor Author

@snoyberg: I've tried to implement your suggestion and rebased on current master.

@soenkehahn soenkehahn force-pushed the modifyRedirectCount branch from 9116b86 to 11a9a62 Compare July 9, 2016 07:33
@soenkehahn
Copy link
Contributor Author

@snoyberg: Fixed the travis failures.

@snoyberg snoyberg merged commit 8fea941 into snoyberg:master Jul 9, 2016
@snoyberg
Copy link
Owner

snoyberg commented Jul 9, 2016

Thanks!

snoyberg added a commit that referenced this pull request Jul 9, 2016
@soenkehahn
Copy link
Contributor Author

Thanks for merging and the release!

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

Successfully merging this pull request may close these issues.

2 participants