From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: "Dr. Arne Babenhauserheide" Newsgroups: gmane.lisp.guile.bugs Subject: bug#52434: [patch] [doc] add http-request example to web examples Date: Sat, 11 Dec 2021 15:51:41 +0100 Message-ID: <87lf0rry60.fsf@web.de> Mime-Version: 1.0 Content-Type: multipart/signed; boundary="==-=-="; micalg=pgp-sha256; protocol="application/pgp-signature" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="911"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: mu4e 1.6.10; emacs 27.2 To: 52434@debbugs.gnu.org Original-X-From: bug-guile-bounces+guile-bugs=m.gmane-mx.org@gnu.org Sat Dec 11 15:54:09 2021 Return-path: Envelope-to: guile-bugs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mw3lJ-000AeC-5V for guile-bugs@m.gmane-mx.org; Sat, 11 Dec 2021 15:54:09 +0100 Original-Received: from localhost ([::1]:35352 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mw3lH-0008IA-DQ for guile-bugs@m.gmane-mx.org; Sat, 11 Dec 2021 09:54:07 -0500 Original-Received: from eggs.gnu.org ([209.51.188.92]:60498) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mw3lC-0008I2-9x for bug-guile@gnu.org; Sat, 11 Dec 2021 09:54:02 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]:37351) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mw3lC-0001og-1I for bug-guile@gnu.org; Sat, 11 Dec 2021 09:54:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1mw3lB-00079G-Uo for bug-guile@gnu.org; Sat, 11 Dec 2021 09:54:01 -0500 X-Loop: help-debbugs@gnu.org Resent-From: "Dr. Arne Babenhauserheide" Original-Sender: "Debbugs-submit" Resent-CC: bug-guile@gnu.org Resent-Date: Sat, 11 Dec 2021 14:54:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 52434 X-GNU-PR-Package: guile X-GNU-PR-Keywords: patch X-Debbugs-Original-To: bug-guile@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.163923438627414 (code B ref -1); Sat, 11 Dec 2021 14:54:01 +0000 Original-Received: (at submit) by debbugs.gnu.org; 11 Dec 2021 14:53:06 +0000 Original-Received: from localhost ([127.0.0.1]:48897 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mw3kI-000786-HI for submit@debbugs.gnu.org; Sat, 11 Dec 2021 09:53:06 -0500 Original-Received: from lists.gnu.org ([209.51.188.17]:36472) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mw3kE-00077w-UT for submit@debbugs.gnu.org; Sat, 11 Dec 2021 09:53:05 -0500 Original-Received: from eggs.gnu.org ([209.51.188.92]:60276) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mw3kE-0007tp-N6 for bug-guile@gnu.org; Sat, 11 Dec 2021 09:53:02 -0500 Original-Received: from mout.web.de ([217.72.192.78]:37315) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mw3kC-0001iQ-Rm for bug-guile@gnu.org; Sat, 11 Dec 2021 09:53:02 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=web.de; s=dbaedf251592; t=1639234379; bh=pZff4Osd7+NtpZmCVm4igxuVP+pPJjsaptZiaPSb4V0=; h=X-UI-Sender-Class:From:To:Subject:Date; b=IWIzr8jRIELexMqKt2Cq+pdqxKnb5RuY3HlNSFPgBvgq0bg4Cax6ya+DfFJcmaiIt hXuwushW7w5DFvtrRXqvD5zD942PthtMdE53NAdYXASH2NDVhAWq9643ArTLHBCBY/ iKXZTgssQVfL9U8zEvKAOiRRY7208yvCHuaYd2wQ= X-UI-Sender-Class: c548c8c5-30a9-4db5-a2e7-cb6cb037b8f9 Original-Received: from fluss ([80.136.27.113]) by smtp.web.de (mrweb106 [213.165.67.124]) with ESMTPSA (Nemesis) id 1Mmymz-1mDcK53QM3-00jw89; Sat, 11 Dec 2021 15:52:58 +0100 X-Provags-ID: V03:K1:pEBwFPwlCCNnh9ofv/EUn4vtcuKNF0L/ih2aiBYD9yBaGS3uElw iPJkcb9+8QMDoOT1VSiEbGDI6IUNsYvdjTRnQIsbdSs92p/tZZSThnTlIwRmGtxtxD0jVu3 oIBeMduchZJ0mtLGR67oQ7S9pX4mnpXG52g3M0nY5cq558VH2bxC36PXx953HmfIa2UQIFL ZhcvTdw2ArS/yKNoZTlDg== X-UI-Out-Filterresults: notjunk:1;V03:K0:E4DEx0f4LZw=:sncm1g1d53L7gV92ktt52N ztOy6gVxT9uO+adRz1ymfCnw1dGLbDvKslKCa3D2RBwOypVKSG/7VLBLEAu4+25gXFoMcDJzL kHOcyliR9pps4J0iOF/ntLoOmPMyVVPKYK/JCN026NJ2XgousV7IN/yb6Dm7uAXHjv15FKSQu Hz7o5UyLt0vT/hLn5jQAIEPAIwJJ5SMSWm0DpHYM6XoFNBvvcbkWxVB+KFlA0wqb/BbhrJW+l 6jUlb0w+uZVFVVTgADnrv5TmuRAmarOhrYQ5PP3SMfcKYu0EbM2/Kuih0XC0hfgiruH/BYF4C bLQ0FFGJ8kMTnKaHxn1m+IiYg5s8+PI8Xg2bXi76IgrnIRdMaq/gVru/kd5vfEz0yPB0EIYmi 7GGYDfneEvtr+eiUCU1K3Oo57WT7dhM9Q2l3XbVSIO7xFZ1UNnbhi0L2nMb1iGf2lYq7RRyrj ysyAi+KQeqrdFTy0/fMht9ux3ieNsQcODgBMDLdQ3npPZxORXi/iHImksOEPxJjTBycdIwJmc p+rIkxhRF2NpTKcaBu9eJ6XNSMNYx1MXE4RhRm3Esg6FILnOv2XZFvKY7ySZog9ulH3Gssaf9 Ce1HsD+yjWyz2AtQirzh743vfBlWI9jD8N2lR+9ZahOwuN4QGYHjDyUC2bVk58VVhsOpTzRIs VkZ4PW05OuuZK8bgGG9XceEIS4nbtX4waAtiqs+rWu644l6vzUemA77T20cmzuOHdY3KE097R tIJC+3Iy3PkpyBCyHPl/jOaenKmpzIO8jEU9vwoqHcjMSbK5uavgiXWhRyM8r8SI/+MqERoT Received-SPF: pass client-ip=217.72.192.78; envelope-from=arne_bab@web.de; helo=mout.web.de X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-guile@gnu.org List-Id: "Bug reports for GUILE, GNU's Ubiquitous Extension Language" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-guile-bounces+guile-bugs=m.gmane-mx.org@gnu.org Original-Sender: "bug-guile" Xref: news.gmane.io gmane.lisp.guile.bugs:10222 Archived-At: --==-=-= Content-Type: multipart/mixed; boundary="=-=-=" --=-=-= Content-Type: text/plain Hi, the attached patch adds a client example that access the hello-world server. --=-=-= Content-Type: text/x-patch Content-Disposition: inline; filename=0001-doc-Provide-full-server-client-example.patch Content-Transfer-Encoding: quoted-printable From=207d41deec7a550a186fb5e653a7007ae38fd62dbd Mon Sep 17 00:00:00 2001 From: Arne Babenhauserheide Date: Sat, 11 Dec 2021 15:43:21 +0100 Subject: [PATCH] doc: Provide full server<->client example * doc/ref/web.texi: (Server: Hello, World!): Add Server:-Prefix to subsubse= ction * doc/ref/web.texi: (Client: Visit the server): Example to access the defined header. =2D-- doc/ref/web.texi | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/doc/ref/web.texi b/doc/ref/web.texi index 93cd0214f..7d54a8f42 100644 =2D-- a/doc/ref/web.texi +++ b/doc/ref/web.texi @@ -1833,7 +1833,7 @@ implementation's open function. =20 Well, enough about the tedious internals. Let's make a web application! =20 =2D@subsubsection Hello, World! +@subsubsection Server: Hello, World! =20 The first program we have to write, of course, is ``Hello, World!''. This means that we have to implement a web handler that does what we @@ -1870,6 +1870,30 @@ By default, the web server listens for requests on @code{localhost:8080}. Visit that address in your web browser to test. If you see the string, @code{Hello World!}, sweet! =20 +@subsubsection Client: Visit the server + +The second program talks to our server. + +@example +(use-modules (web client) + (web http) + (web uri) + (ice-9 receive)) +(receive (response-status response-body)=20 + (http-request "http://localhost:8080" + #:method 'GET + #:headers `((content-encoding . (gzip deflate)) + (user-agent . "guile web client") + (referer . ,(string->uri "http://www.gnu.org")) + (accept (*/*)) + (content-type . (application/json))) + #:streaming? #f + #:decode-body? #t + #:body #f) + (display response-body)) +@end example + + @subsubsection Inspecting the Request =20 The Hello World program above is a general greeter, responding to all =2D-=20 2.34.0 --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Best wishes, Arne =2D-=20 Unpolitisch sein hei=C3=9Ft politisch sein, ohne es zu merken. draketo.de --=-=-=-- --==-=-= Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQJEBAEBCAAuFiEE801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