UNIX socket transport plugin for HTTPie.
$ pip install httpie-unixsocket
To query Docker for info, using /var/run/docker.sock
:
$ http http+unix://%2Fvar%2Frun%2Fdocker.sock/info
A UNIX socket plugin for HTTPie
License: Other
UNIX socket transport plugin for HTTPie.
$ pip install httpie-unixsocket
To query Docker for info, using /var/run/docker.sock
:
$ http http+unix://%2Fvar%2Frun%2Fdocker.sock/info
http http+unix://%2Fvar%2Frun%2Fdocker.sock/info
returns:
"http: error: InvalidURL: URL has an invalid label."
Any ideas on what I'm doing wrong?
... or change the misleading installation instructions, please.
@msabramo thanks for the module but unfortunately, it's not working:
Versions:
httpie==0.9.2
httpie-unixsocket==0.0.0
Python 2.7.6
Log:
#> http http+unix:///var/run/docker.sock:/info
http: error: InvalidURL: Invalid URL u'http+unix:///var/run/docker.sock:/info': No host supplied
``
Any ideas?
Transfer https://github.com/msabramo/httpie-unixsocket to the httpie
org (as @jkbrzt had suggested).
Cc: @jkbrzt
Inspired by issue #7, as I think the current syntax is ugly and too error-prone.
root@db2722aaf51d:/# curl-unix-socket unix:///var/run/docker.sock:/info
{"Containers":2,"Debug":1,"DockerRootDir":"/var/lib/docker","Driver":"btrfs","DriverStatus":[],"ExecutionDriver":"native-0.2","ID":"EXI6:MA6J:YU45:24S3:CA6L:37PQ:JLKG:WPWI:5NFP:L3XW:WECP:HWK3","IPv4Forwarding":1,"Images":86,"IndexServerAddress":"https://index.docker.io/v1/","InitPath":"/usr/bin/docker","InitSha1":"","KernelVersion":"4.0.0-rc3","Labels":null,"MemTotal":33343193088,"MemoryLimit":1,"NCPU":8,"NEventsListener":0,"NFd":24,"NGoroutines":53,"Name":"debian","OperatingSystem":"Debian GNU/Linux 8 (jessie)","RegistryConfig":{"IndexConfigs":{"docker.io":{"Mirrors":null,"Name":"docker.io","Official":true,"Secure":true}},"InsecureRegistryCIDRs":["127.0.0.0/8"]},"SwapLimit":1,"SystemTime":"2015-03-18T12:00:18.261465223-07:00"}
Cc: @jakubroztocil, @jfrazelle
# proof the file is there
root@db2722aaf51d:/# ls /var/run/
docker.sock lock utmp
# when i try w httpie
root@db2722aaf51d:/# http http+unix://%2Fvar%2Frun%sFdocker.sock/info
http: error: ConnectionError: ('Connection aborted.', error(2, 'No such file or directory'))
# when i try w curl
root@db2722aaf51d:/# curl-unix-socket unix:///var/run/docker.sock:/info
{"Containers":2,"Debug":1,"DockerRootDir":"/var/lib/docker","Driver":"btrfs","DriverStatus":[],"ExecutionDriver":"native-0.2","ID":"EXI6:MA6J:YU45:24S3:CA6L:37PQ:JLKG:WPWI:5NFP:L3XW:WECP:HWK3","IPv4Forwarding":1,"Images":86,"IndexServerAddress":"https://index.docker.io/v1/","InitPath":"/usr/bin/docker","InitSha1":"","KernelVersion":"4.0.0-rc3","Labels":null,"MemTotal":33343193088,"MemoryLimit":1,"NCPU":8,"NEventsListener":0,"NFd":24,"NGoroutines":53,"Name":"debian","OperatingSystem":"Debian GNU/Linux 8 (jessie)","RegistryConfig":{"IndexConfigs":{"docker.io":{"Mirrors":null,"Name":"docker.io","Official":true,"Secure":true}},"InsecureRegistryCIDRs":["127.0.0.0/8"]},"SwapLimit":1,"SystemTime":"2015-03-18T12:00:18.261465223-07:00"}
Downloading/unpacking git+https://github.com/msabramo/httpie-unixsocket.git
Cloning https://github.com/msabramo/httpie-unixsocket.git to /tmp/pip-J2zDhW-build
Running setup.py (path:/tmp/pip-J2zDhW-build/setup.py) egg_info for package from git+https://github.com/msabramo/httpie-unixsocket.git
Downloading/unpacking httpie>=0.7.0 from https://pypi.python.org/packages/2.7/h/httpie/httpie-0.9.0-py2.py3-none-any.whl#md5=76c94093b32e5257c097b15519f2b64a (from httpie-unixsocket==1.0.2)
Downloading/unpacking requests-unixsocket (from httpie-unixsocket==1.0.2)
Downloading requests-unixsocket-0.1.4.tar.gz
Running setup.py (path:/tmp/pip_build_root/requests-unixsocket/setup.py) egg_info for package requests-unixsocket
Installed /tmp/pip_build_root/requests-unixsocket/pbr-0.10.7-py2.7.egg
[pbr] Processing SOURCES.txt
warning: LocalManifestMaker: standard file '-c' not found
warning: no previously-included files found matching '.gitignore'
warning: no previously-included files found matching '.gitreview'
warning: no previously-included files matching '*.pyc' found anywhere in distribution
Downloading/unpacking requests>=2.3.0 from https://pypi.python.org/packages/py2.py3/r/requests/requests-2.5.1-py2.py3-none-any.whl#md5=11dc91bc96c5c5e0b566ce8f9c9644ab (from httpie>=0.7.0->httpie-unixsocket==1.0.2)
Downloading/unpacking Pygments>=1.5 from https://pypi.python.org/packages/2.7/P/Pygments/Pygments-2.0.2-py2-none-any.whl#md5=98f29db02f4b22f58a2d3f60646e1e1f (from httpie>=0.7.0->httpie-unixsocket==1.0.2)
Installing collected packages: httpie, requests-unixsocket, httpie-unixsocket, requests, Pygments
Found existing installation: httpie 0.8.0
Uninstalling httpie:
Successfully uninstalled httpie
Running setup.py install for requests-unixsocket
[pbr] Reusing existing SOURCES.txt
Running setup.py install for httpie-unixsocket
Found existing installation: requests 2.3.0
Uninstalling requests:
Successfully uninstalled requests
Found existing installation: Pygments 1.6
Uninstalling Pygments:
Successfully uninstalled Pygments
Successfully installed httpie requests-unixsocket httpie-unixsocket requests Pygments
Cleaning up...
Traceback (most recent call last):
File "/usr/bin/pip", line 9, in <module>
load_entry_point('pip==1.5.6', 'console_scripts', 'pip')()
File "/usr/lib/python2.7/dist-packages/pkg_resources.py", line 356, in load_entry_point
return get_distribution(dist).load_entry_point(group, name)
File "/usr/lib/python2.7/dist-packages/pkg_resources.py", line 2476, in load_entry_point
return ep.load()
File "/usr/lib/python2.7/dist-packages/pkg_resources.py", line 2190, in load
['__name__'])
File "/usr/lib/python2.7/dist-packages/pip/__init__.py", line 61, in <module>
from pip.vcs import git, mercurial, subversion, bazaar # noqa
File "/usr/lib/python2.7/dist-packages/pip/vcs/mercurial.py", line 9, in <module>
from pip.download import path_to_url
File "/usr/lib/python2.7/dist-packages/pip/download.py", line 25, in <module>
from requests.compat import IncompleteRead
ImportError: cannot import name IncompleteRead
When trying to use httpie with a unix socket, I'm getting the mentioned error with the following traceback:
$ httpie/bin/http --debug http+unix://%2Fsome%2Fsocket/path
HTTPie 3.2.2
Requests 2.31.0
Pygments 2.15.1
Python 3.11.2 (main, May 30 2023, 17:45:26) [GCC 12.2.0]
/home/ack/Desktop/httpie/bin/python3
Linux 6.2.0-20-generic
<Environment {'apply_warnings_filter': <function Environment.apply_warnings_filter at 0x7ff70d8b0680>,
'args': Namespace(),
'as_silent': <function Environment.as_silent at 0x7ff70d8b0540>,
'colors': 256,
'config': {'default_options': []},
'config_dir': PosixPath('/home/ack/.config/httpie'),
'devnull': <property object at 0x7ff70d895ee0>,
'is_windows': False,
'log_error': <function Environment.log_error at 0x7ff70d8b05e0>,
'program_name': 'http',
'quiet': 0,
'rich_console': <functools.cached_property object at 0x7ff70d89eed0>,
'rich_error_console': <functools.cached_property object at 0x7ff70d89f5d0>,
'show_displays': True,
'stderr': <_io.TextIOWrapper name='<stderr>' mode='w' encoding='utf-8'>,
'stderr_isatty': True,
'stdin': <_io.TextIOWrapper name='<stdin>' mode='r' encoding='utf-8'>,
'stdin_encoding': 'utf-8',
'stdin_isatty': True,
'stdout': <_io.TextIOWrapper name='<stdout>' mode='w' encoding='utf-8'>,
'stdout_encoding': 'utf-8',
'stdout_isatty': True}>
<PluginManager {'adapters': [<class 'httpie_unixsocket.UnixSocketTransportPlugin'>],
'auth': [<class 'httpie.plugins.builtin.BasicAuthPlugin'>,
<class 'httpie.plugins.builtin.DigestAuthPlugin'>,
<class 'httpie.plugins.builtin.BearerAuthPlugin'>],
'converters': [],
'formatters': [<class 'httpie.output.formatters.headers.HeadersFormatter'>,
<class 'httpie.output.formatters.json.JSONFormatter'>,
<class 'httpie.output.formatters.xml.XMLFormatter'>,
<class 'httpie.output.formatters.colors.ColorFormatter'>]}>
>>> requests.request(**{'auth': None,
'data': RequestJSONDataDict(),
'headers': <HTTPHeadersDict('User-Agent': b'HTTPie/3.2.2')>,
'method': 'get',
'params': <generator object MultiValueOrderedDict.items at 0x7ff70d39f840>,
'url': 'http+unix://%2Fsome%2Fsocket/path'})
http: error: TypeError: HTTPConnection.request() got an unexpected keyword argument 'chunked'
Traceback (most recent call last):
File "/home/ack/Desktop/httpie/bin/http", line 8, in <module>
sys.exit(main())
^^^^^^
File "/home/ack/Desktop/httpie/lib/python3.11/site-packages/httpie/__main__.py", line 9, in main
exit_status = main()
^^^^^^
File "/home/ack/Desktop/httpie/lib/python3.11/site-packages/httpie/core.py", line 162, in main
return raw_main(
^^^^^^^^^
File "/home/ack/Desktop/httpie/lib/python3.11/site-packages/httpie/core.py", line 140, in raw_main
handle_generic_error(e)
File "/home/ack/Desktop/httpie/lib/python3.11/site-packages/httpie/core.py", line 100, in raw_main
exit_status = main_program(
^^^^^^^^^^^^^
File "/home/ack/Desktop/httpie/lib/python3.11/site-packages/httpie/core.py", line 213, in program
for message in messages:
File "/home/ack/Desktop/httpie/lib/python3.11/site-packages/httpie/client.py", line 113, in collect_messages
response = requests_session.send(
^^^^^^^^^^^^^^^^^^^^^^
File "/home/ack/Desktop/httpie/lib/python3.11/site-packages/requests/sessions.py", line 703, in send
r = adapter.send(request, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/ack/Desktop/httpie/lib/python3.11/site-packages/requests/adapters.py", line 486, in send
resp = conn.urlopen(
^^^^^^^^^^^^^
File "/home/ack/Desktop/httpie/lib/python3.11/site-packages/urllib3/connectionpool.py", line 790, in urlopen
response = self._make_request(
^^^^^^^^^^^^^^^^^^^
File "/home/ack/Desktop/httpie/lib/python3.11/site-packages/urllib3/connectionpool.py", line 496, in _make_request
conn.request(
TypeError: HTTPConnection.request() got an unexpected keyword argument 'chunked'
These are the versions I'm using:
$ httpie/bin/pip freeze
certifi==2023.5.7
charset-normalizer==3.1.0
defusedxml==0.7.1
httpie==3.2.2
httpie-unixsocket==0.0.0
idna==3.4
markdown-it-py==3.0.0
mdurl==0.1.2
multidict==6.0.4
Pygments==2.15.1
PySocks==1.7.1
requests==2.31.0
requests-toolbelt==1.0.0
requests-unixsocket==0.3.0
rich==13.4.2
urllib3==2.0.3
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.