-
-
Notifications
You must be signed in to change notification settings - Fork 9.5k
Unix domain sockets #2355
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
Unix domain sockets #2355
Conversation
adapted from some code from docker-py: * https://github.com/docker/docker-py/blob/master/docker/unixconn/unixconn.py
Probably if |
Very nice @msabramo |
These test the unix domain socket adapter by spinning up a multiprocessing.Process that uses waitress to serve a simple WSGI app on a unix domain socket.
dc6d0b3
to
1e36535
Compare
adapted from some code from docker-py: * https://github.com/docker/docker-py/blob/master/docker/unixconn/unixconn.py Also submitted this UnixAdapter code to requests as https://github.com/kennethreitz/requests/pull/2355 Fixes: httpieGH-209 (httpie#209)
So the fundamental thing to remember about requests is that it is an HTTP library which means we strive to be in compliance with RFC 7230, 7231, 7232, 7233, 7234, and 7235 and other RFCs that relate to how we have to transmit the data or communicate with the server (etc. etc. etc.). We primarily handle HTTP, we don't handle arbitrary URLs. That's a job for a library that will handle arbitrary URLs. (Hint: this was the point of urllib/urllib2) Note, while people use requests for If copying and pasting this code around is becoming a problem for projects (like httpie, docker-py, or whomever else) the solution is not to upstream the code here to be maintained by @Lukasa and me. The solution is to find people who care about maintaining it and make it its own library. If you think this code is too small for a library on its own, consider the fact that many of the auth libraries (kerberos, ntlm, etc.) are all similar in size to this code and are all packaged separately. tl;dr We have no interest in making this a feature of the project or maintaining this code when the maintainers will not use it actively enough to be comfortable maintaining it. |
adapted from some code from docker-py: * https://github.com/docker/docker-py/blob/master/docker/unixconn/unixconn.py Also submitted this UnixAdapter code to requests as https://github.com/kennethreitz/requests/pull/2355 Fixes: httpieGH-209 (httpie#209)
@sigmavirus24: Thanks for the detailed explanation! |
adapted from some code from docker-py: * https://github.com/docker/docker-py/blob/master/docker/unixconn/unixconn.py Also submitted this UnixAdapter code to requests as https://github.com/kennethreitz/requests/pull/2355 Fixes: httpieGH-209 (httpie#209)
adapted from some code from docker-py: * https://github.com/docker/docker-py/blob/master/docker/unixconn/unixconn.py Also submitted this UnixAdapter code to requests as https://github.com/kennethreitz/requests/pull/2355 Fixes: httpieGH-209 (httpie#209)
adapted from some code from docker-py: * https://github.com/docker/docker-py/blob/master/docker/unixconn/unixconn.py Also submitted this UnixAdapter code to requests as https://github.com/kennethreitz/requests/pull/2355 Fixes: httpieGH-209 (httpie#209)
adapted from some code from docker-py: * https://github.com/docker/docker-py/blob/master/docker/unixconn/unixconn.py Also submitted this UnixAdapter code to requests as https://github.com/kennethreitz/requests/pull/2355 Fixes: httpieGH-209 (httpie#209)
This adds support for unix domain sockets by using a slightly modified version of the unix domain socket adapter from the docker-py project:
https://github.com/docker/docker-py/blob/master/docker/unixconn/unixconn.py
The modifications are to make the adapter more usable in a greater variety of contexts by getting rid of the context of a
base_url
for the adapter and inventing a URL syntax that allows embedding the socket path into the URL. Basically the socket name goes in the netloc (host) part of the URL, but it's URL-encoded so that slashes become%2F
's so that the slashes don't interfere with separating the netloc and path parts of the URLs. This was roughly inspired by URL syntaxes that are mentioned in the following comments:So for example if I had a server listening on
/tmp/profilesvc.sock
:I can access it as follows:
In case you're curious about the motivation for adding unix domain socket support, it was inspired by:
httpie/cli#209
Cc: @shin-, @jakubroztocil, @monsanto, @np, @nuxlli, @matrixise, @remmelt