bug#52434: [patch] [doc] add http-request example to web examples

"Dr. Arne Babenhauserheide" <[email protected]>
Newsgroups gmane.lisp.guile.bugs
Message-ID <[email protected]>
Hi,

the attached patch adds a client example that access the hello-world server.


Best wishes,
Arne
-- 
Unpolitisch sein
heißt politisch sein,
ohne es zu merken.
draketo.de
0001-doc-Provide-full-server-client-example.patch (text/x-patch, 2 KB)
From 7d41deec7a550a186fb5e653a7007ae38fd62dbd Mon Sep 17 00:00:00 2001
From: Arne Babenhauserheide <[email protected]>
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 subsubsection

* doc/ref/web.texi: (Client: Visit the server): Example to access the
defined header.
---
 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
--- a/doc/ref/web.texi
+++ b/doc/ref/web.texi
@@ -1833,7 +1833,7 @@ implementation's open function.
 
 Well, enough about the tedious internals.  Let's make a web application!
 
-@subsubsection Hello, World!
+@subsubsection Server: Hello, World!
 
 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!
 
+@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) 
+  (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
 
 The Hello World program above is a general greeter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KSiLUS7NxDXPB1TNNSN2YkvcOFW
u7Icx0otm4yRGnrNvQ==
=OoTB
-----END PGP SIGNATURE-----
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.