httpie / httpie-unixsocket

A UNIX socket plugin for HTTPie
Other
44 stars 11 forks source link

no such file or directory #7

Closed jessfraz closed 9 years ago

jessfraz commented 9 years ago
# 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"}
msabramo commented 9 years ago

Interesting. I'll take a look. I also didn't know curl could work with unix sockets so thanks for showing that!

jkbrzt commented 9 years ago

@msabramo It's actually curl-unix-socket which is a tool written in Go, not curl. Btw, I wonder if it would be possible to adopt this nicer URL syntax.

jessfraz commented 9 years ago

cool! thanks for looking into it.

On Thu, Mar 19, 2015 at 5:29 AM, Jakub Roztočil notifications@github.com wrote:

@msabramo https://github.com/msabramo It's actually curl-unix-socket https://github.com/Soulou/curl-unix-socket which is a tool written in Go, not curl. Btw, I wonder if it would be possible to adopt this nicer URL syntax.

— Reply to this email directly or view it on GitHub https://github.com/msabramo/httpie-unixsocket/issues/7#issuecomment-83536735 .

Jessie Frazelle 4096R / D4C4 DD60 0D66 F65A 8EFC 511E 18F3 685C 0022 BFF3 pgp.mit.edu http://pgp.mit.edu/pks/lookup?op=get&search=0x18F3685C0022BFF3

msabramo commented 9 years ago

BTW, I created https://github.com/msabramo/requests-unixsocket (which this is based on) with the thought that perhaps https://github.com/docker/docker-py might be able to use it, so if requests-unixsocket won't work with the docker socket, then I'd like to fix it.

msabramo commented 9 years ago

@jfrazelle: I think this is just a simple typo. You did:

http http+unix://%2Fvar%2Frun%sFdocker.sock/info

And I also got an error when I did that. When I replace the %sF with %2F, it works for me.

(httpie-unixsocket.venv)vagrant@vagrant-ubuntu-trusty-64:~$ http http+unix://%2Fvar%2Frun%2Fdocker.sock/info
HTTP/1.1 200 OK
Content-Length: 780
Content-Type: application/json
Date: Mon, 23 Mar 2015 16:21:21 GMT
Job-Name: info

{
    "Containers": 0,
    "Debug": 0,
    "DockerRootDir": "/var/lib/docker",
    "Driver": "aufs",
    "DriverStatus": [
        [
            "Root Dir",
            "/var/lib/docker/aufs"
        ],
        [
            "Backing Filesystem",
            "extfs"
        ],
        [
            "Dirs",
            "0"
        ]
    ],
    "ExecutionDriver": "native-0.2",
    "ID": "TJON:7OGO:YU6Z:LZ7J:VXUY:BHZK:CNI4:BBXR:ZTGC:V7A6:QB3M:L5K3",
    "IPv4Forwarding": 1,
    "Images": 0,
    "IndexServerAddress": "https://index.docker.io/v1/",
    "InitPath": "/usr/bin/docker",
    "InitSha1": "",
    "KernelVersion": "3.13.0-45-generic",
    "Labels": null,
    "MemTotal": 2099113984,
    "MemoryLimit": 1,
    "NCPU": 2,
    "NEventsListener": 0,
    "NFd": 10,
    "NGoroutines": 14,
    "Name": "vagrant-ubuntu-trusty-64",
    "OperatingSystem": "Ubuntu 14.04.1 LTS",
    "RegistryConfig": {
        "IndexConfigs": {
            "docker.io": {
                "Mirrors": null,
                "Name": "docker.io",
                "Official": true,
                "Secure": true
            }
        },
        "InsecureRegistryCIDRs": [
            "127.0.0.0/8"
        ]
    },
    "SwapLimit": 0
}

Does that solve the issue?

This perhaps points out though that perhaps this URL syntax is error-prone and I should look into adopting the nicer URL syntax that curl-unix-socket uses.

jessfraz commented 9 years ago

Wow so sorry!

On Monday, March 23, 2015, Marc Abramowitz notifications@github.com wrote:

@jfrazelle https://github.com/jfrazelle: I think this is just a simple typo. You did:

http http+unix://%2Fvar%2Frun%sFdocker.sock/info

And I also got an error when I did that. When I replace the %sF with %2F, it works for me.

(httpie-unixsocket.venv)vagrant@vagrant-ubuntu-trusty-64:~$ http http+unix://%2Fvar%2Frun%2Fdocker.sock/info HTTP/1.1 200 OK Content-Length: 780 Content-Type: application/json Date: Mon, 23 Mar 2015 16:21:21 GMT Job-Name: info

{ "Containers": 0, "Debug": 0, "DockerRootDir": "/var/lib/docker", "Driver": "aufs", "DriverStatus": [ [ "Root Dir", "/var/lib/docker/aufs" ], [ "Backing Filesystem", "extfs" ], [ "Dirs", "0" ] ], "ExecutionDriver": "native-0.2", "ID": "TJON:7OGO:YU6Z:LZ7J:VXUY:BHZK:CNI4:BBXR:ZTGC:V7A6:QB3M:L5K3", "IPv4Forwarding": 1, "Images": 0, "IndexServerAddress": "https://index.docker.io/v1/", "InitPath": "/usr/bin/docker", "InitSha1": "", "KernelVersion": "3.13.0-45-generic", "Labels": null, "MemTotal": 2099113984, "MemoryLimit": 1, "NCPU": 2, "NEventsListener": 0, "NFd": 10, "NGoroutines": 14, "Name": "vagrant-ubuntu-trusty-64", "OperatingSystem": "Ubuntu 14.04.1 LTS", "RegistryConfig": { "IndexConfigs": { "docker.io": { "Mirrors": null, "Name": "docker.io", "Official": true, "Secure": true } }, "InsecureRegistryCIDRs": [ "127.0.0.0/8" ] }, "SwapLimit": 0 }

Does that solve the issue?

— Reply to this email directly or view it on GitHub https://github.com/msabramo/httpie-unixsocket/issues/7#issuecomment-85082732 .

Jessie Frazelle 4096R / D4C4 DD60 0D66 F65A 8EFC 511E 18F3 685C 0022 BFF3 pgp.mit.edu http://pgp.mit.edu/pks/lookup?op=get&search=0x18F3685C0022BFF3

msabramo commented 9 years ago

@jakubroztocil: It looks like perhaps httpie needs to be modified a bit to support that nicer syntax?

(httpie-unixsocket.venv)vagrant@vagrant-ubuntu-trusty-64:~$ http http+unix:///var/run/docker.sock:/info

http: error: InvalidURL: Invalid URL u'http+unix:///var/run/docker.sock:/info': No host supplied

It's happier with two slashes instead of three (though it still fails because my library doesn't support the new syntax yet):

(httpie-unixsocket.venv)vagrant@vagrant-ubuntu-trusty-64:~$ http http+unix://var/run/docker.sock:/info

http: error: ConnectionError: ('Connection aborted.', error(2, 'No such file or directory'))
msabramo commented 9 years ago

@jfrazelle: No worries. I'm thinking that's a sign that the current syntax is too messy and we should try to have a nicer one like curl-unix-socket does. Interested in helping with that?

msabramo commented 9 years ago

@jakubroztocil: Re my earlier comment; it seems that it's requests that is emitting the No host supplied error:

❯ ag 'No host supplied' requests
requests/requests/models.py
364:            raise InvalidURL("Invalid URL %r: No host supplied" % url)

but maybe there is something that can be done in httpie to avoid hitting that?

msabramo commented 9 years ago

Here's what the stack trace looks like after I commented out the exception handling in httpie:

(httpie-unixsocket.venv)vagrant@vagrant-ubuntu-trusty-64:~/httpie$ http http+unix:///var/run/docker.sock:/info
Traceback (most recent call last):
  File "/home/vagrant/httpie-unixsocket.venv/bin/http", line 9, in <module>
    load_entry_point('httpie==1.0.0-dev', 'console_scripts', 'http')()
  File "/home/vagrant/httpie/httpie/core.py", line 112, in main
    response = get_response(args, config_dir=env.config.directory)
  File "/home/vagrant/httpie/httpie/client.py", line 41, in get_response
    response = requests_session.request(**kwargs)
  File "/home/vagrant/httpie-unixsocket.venv/local/lib/python2.7/site-packages/requests/sessions.py", line 450, in request
    prep = self.prepare_request(req)
  File "/home/vagrant/httpie-unixsocket.venv/local/lib/python2.7/site-packages/requests/sessions.py", line 381, in prepare_request
    hooks=merge_hooks(request.hooks, self.hooks),
  File "/home/vagrant/httpie-unixsocket.venv/local/lib/python2.7/site-packages/requests/models.py", line 304, in prepare
    self.prepare_url(url, params)
  File "/home/vagrant/httpie-unixsocket.venv/local/lib/python2.7/site-packages/requests/models.py", line 364, in prepare_url
    raise InvalidURL("Invalid URL %r: No host supplied" % url)
requests.exceptions.InvalidURL: Invalid URL u'http+unix:///var/run/docker.sock:/info': No host supplied