-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Factor out HTTP(S)Connection -> ConnectionCls, and cleanup. #254
Conversation
Also removed the need to None-ify global `ssl` module in tests.
Thanks for the super quick reaction! This will definitely make my life easier, just wondering how people using Since this functionality is mainly going to be used to modify the socket options it might be better served by more specific code (hook to configure socket/nodelay flag) built on top of this code but still part of urllib3. Thanks again and let me know if there is anything I can help with. |
While I agree that in this scenario a hook registry would be the most convenient, I'm reluctant to introduce hooks within urllib3 for two reasons:
And then the other consideration is making those socket opts being default. Do you have any argument for why that should be done in urllib3 but not in the Python stdlib? |
You are absolutely right that hook registry makes little sense. I was just thinking out loud, not trying to push for any particular solution, because I feel that this should be a common usecase (httplib2 does this as default) and should be either on by default or very easy to just enable everywhere. Also this is a very low-level feature that would be very hard to do without explicit support from urllib3 - this change is definitely a step in the right direction. I'd just personally like to see more complete solution - for example have not just the option of passing in your own connection class but also have a connection class implementation ready that does enable nodelay and maybe even a flag that would use this class. That's my personal opinion however and I am not pushing for it too hard, I will be happy with any support you can give me. After all I chose urllib3 because I liked the design so I obivously trust your opinion on these things. My only reason for trying to get it to urllib3 instead of stdlib is time - I do believe this would make sense in stdlib (in httplib at least) but that would mean a huge delay before it's usable. |
Hrm the fact that httplib2 already hardcodes these options and you believe that it would be reasonable for the stdlib to use them as default is fairly compelling. Can you think of any scenarios that we need to be aware of where having these options as default would have an undesired effect?
I completely agree. My long-term desire is to completely drop our dependency on the httplib stdlib by including our own http spec state machine (that can be swapped for any other protocol) and working with sockets directly within our more-generic connection pools. This will allow for much more configurability. While I'm convinced that we can do this in a fraction of the size of the current httplib, it's still a fairly big undertaking that no one has volunteered for. :) Btw when do you need this merged? I wouldn't mind waiting for @kevinburke to comment on the tests part in a couple of days, but I can merge earlier if you need this urgently. |
According to W3C:
There seems to be no adverse effects to disabling Nagle's algorithm and the positive effect can be quite profound (200ms is a long time). I am in no hurry to implement and merge this in urllib3, I can always just ship the ugly work around, it's only in one place for me so it shouldn't hurt. It can definitely wait a couple days no problem, especially if I can get |
@t-8ch Any insight on whether making |
No idea. Looks harmless. As we are sending data in larger chunks this sounds reasonable. |
removed deprecated BaseException
if not self.ConnectionCls or self.ConnectionCls is DummyConnection: | ||
# Platform-specific: Python without ssl | ||
raise SSLError("Can't connect to HTTPS URL because the SSL " | ||
"module is not available.") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I know this was the error message originally, but is there any resource we can/would want to point the user to if they hit this error?
This looks good to me. Sorry @shazow for the delay in getting back to you. |
Also removed the need to None-ify global `ssl` module in tests.
…nto factorout-connectioncls
I always regret rebasing PR's... dunno why I do it. |
Factor out HTTP(S)Connection -> ConnectionCls, and cleanup.
I'm actually convinced that disabling Nagle by default is a Good Idea. If anyone wants to attempt it, I started a branch at #259 but I don't think I'll have time to finish it. Feel free to take a crack at it. |
Also removed the need to None-ify global
ssl
module in tests.This should address #253 for now. @honzakral, thoughts?
Also, @kevinburke, can you comment on the lines I commented out in
test/with_dummyserver/test_https.py
? Ctrl+f "kevinburke". :)