From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: Zelphir Kaltstahl Newsgroups: gmane.lisp.guile.user Subject: Re: Using UNIX sockets (Zelphir Kaltstahl) Date: Sun, 2 Jun 2019 16:01:53 +0200 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="112753"; mail-complaints-to="usenet@blaine.gmane.org" User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.7.0 To: guile-user@gnu.org Original-X-From: guile-user-bounces+guile-user=m.gmane.org@gnu.org Sun Jun 02 16:02:36 2019 Return-path: Envelope-to: guile-user@m.gmane.org Original-Received: from lists.gnu.org ([209.51.188.17]) by blaine.gmane.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hXR4F-000T5z-Et for guile-user@m.gmane.org; Sun, 02 Jun 2019 16:02:35 +0200 Original-Received: from localhost ([127.0.0.1]:49455 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hXR4E-0005YJ-Fm for guile-user@m.gmane.org; Sun, 02 Jun 2019 10:02:34 -0400 Original-Received: from eggs.gnu.org ([209.51.188.92]:53407) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hXR3e-0005X1-Q7 for guile-user@gnu.org; Sun, 02 Jun 2019 10:02:00 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hXR3d-0002fh-CF for guile-user@gnu.org; Sun, 02 Jun 2019 10:01:58 -0400 Original-Received: from mail-wr1-x435.google.com ([2a00:1450:4864:20::435]:40662) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hXR3d-0002eL-4o for guile-user@gnu.org; Sun, 02 Jun 2019 10:01:57 -0400 Original-Received: by mail-wr1-x435.google.com with SMTP id p11so4705493wre.7 for ; Sun, 02 Jun 2019 07:01:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:references:from:message-id:date:user-agent:mime-version :in-reply-to:content-language; bh=j1o+Caad5w1U/Dq3SBPARxhghTQ9WSUIgWD+DJ3eQPg=; b=ukPp2BwF5WGlTkcL/oZ/ZYZ1Rh0TePD9PG7sLPkj0jMGG/FBsQGkmbohPwhAfDwaVl jxla8okJ8DbN/vOtjx/8EklP8Ts+Vo4234JTrDZ7kPyPoc4JIeUT0zvOU4fC1hBvyJ9I 5YxVf+OSjzBXkytW5nv26JTRCWiSVowpfCSW1ombB3i6+Z9MfNCdlFxstFUN2Wjs98sm xnVCKuzdgc7jtAh2//rbBVLkzS1FP4u9I5D7OxZebbKDzd+4OHQjaVv0tqovA/vRegrm 7ssY3sTsX+gAJ/DVAJhsnxEfIHRTTcn9hL18gU0vS9kXcuEZH3inwRROFim1mLvPI13k HeWA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language; bh=j1o+Caad5w1U/Dq3SBPARxhghTQ9WSUIgWD+DJ3eQPg=; b=XOo+NSQzOjIbTiCkCUGic0D2O6b8n2SvX+roRiWyc3MHFamXu7hhmCzqD25Zngt06w itUqKEorklbu91b6rirCRqcZQQp3oELaQdWnIiqTJZsU57aY6qfpBblB2bTGIQIk4W3c nAb8NcPz+HkGkFM1kLNcu2XMLI1r8iHuldHzomCkEcrRA35fmU+017sntLX0m4VnGwp8 MDXgFKhkBSbZcDLxZnDvkMcg7o0fzSJmXevL1U1HncTo6dxJ5Jt5+iP7UNALqizYykkM kvl3bPcwv50NRDeGvjPYA9I7PI0NUt2wzv2p1R+V6+mK5SKLQskRqaKBnqcKC9e5w+QZ F80w== X-Gm-Message-State: APjAAAXDbkgApC5wlN+efo9W2KEp73MNCpefkB9m5NDnb2JY+AJs1Az5 rFh12+Wd3X5XShiEjxki2YSFO3J3 X-Google-Smtp-Source: APXvYqx2b4XRdBn5/Fj/6d72D5Yggigyro0AWeF5IOOKCZw96jEOWN/1lPfeOGCDuNIckwyHQCyJmg== X-Received: by 2002:adf:baca:: with SMTP id w10mr2253241wrg.230.1559484115356; Sun, 02 Jun 2019 07:01:55 -0700 (PDT) Original-Received: from [10.9.0.20] ([193.138.218.170]) by smtp.googlemail.com with ESMTPSA id h90sm36392224wrh.15.2019.06.02.07.01.53 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 02 Jun 2019 07:01:54 -0700 (PDT) In-Reply-To: Content-Language: en-US X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::435 X-Content-Filtered-By: Mailman/MimeDel 2.1.21 X-BeenThere: guile-user@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: General Guile related discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guile-user-bounces+guile-user=m.gmane.org@gnu.org Original-Sender: "guile-user" Xref: news.gmane.org gmane.lisp.guile.user:15514 Archived-At: Hi Guile Users! I think I've made some progress on how to communicate with dockerd over its UNIX socket. This is what I have now: (use-modules (web client) (ice-9 iconv)) (define* (connect-to-docker-socket #:key (socket-path "/var/run/docker.sock")) (let ([docker-sock-addr (make-socket-address AF_UNIX socket-path)] [docker-sock (socket PF_UNIX SOCK_STREAM 0)]) ;; socket options: ;; https://www.gnu.org/software/libc/manual/html_node/Socket_002dLevel-Options.html (setsockopt docker-sock SOL_SOCKET SO_REUSEADDR 1) ;; usage of connect: ;; https://www.gnu.org/software/guile/manual/html_node/Network-Sockets-and-Communication.html#Network-Sockets-and-Communication ;; server side would use `bind`, `accept` and `listen`. ;; client side uses `connect` and `close`. (connect docker-sock docker-sock-addr) docker-sock)) (let ([sock (connect-to-docker-socket)]) (call-with-values (lambda () (http-get "unix:/var/run/docker.sock/containers/json?all=true" #:port sock ;; dockerd uses HTTP 1.1 it seems. ;; other values will result in: "Bad Request: unsupported protocol version" #:version '(1 . 1) #:keep-alive? #f ;; Apparently the `host` header must be specified. ;; The `host` header in this case is ???. #:headers '((host . "localhost")) #:decode-body? #t #:streaming? #f)) (lambda (response response-text) (display response) (display response-text))) (close sock)) So I am trying to use `web client` to send HTTP requests to the socket and I thing that the socket is now created correctly (although I am not sure about it). Now I get the following error: web/request.scm:184:10: In procedure build-request: Bad request: Bad value for header host: "localhost" However, according to: https://github.com/request/request/issues/2327 any string should be fine as host, host header only being a required header for HTTP 1.1 requests. I am now unsure how to progress from here. What will be accepted as a not bad value for the host header instead? I also tried to use empty string and string of one space and such things, all with the same result. Initially it was also not clear how to write the symbol for host header, 'HOST, 'Host or 'host, but that seems to be figured out now. Regards, Zelphir