GNU bug report logs -
#52434
[patch] [doc] add http-request example to web examples
Previous Next
To reply to this bug, email your comments to 52434 AT debbugs.gnu.org.
Toggle the display of automated, internal messages from the tracker.
Report forwarded
to
bug-guile <at> gnu.org
:
bug#52434
; Package
guile
.
(Sat, 11 Dec 2021 14:54:01 GMT)
Full text and
rfc822 format available.
Acknowledgement sent
to
"Dr. Arne Babenhauserheide" <arne_bab <at> web.de>
:
New bug report received and forwarded. Copy sent to
bug-guile <at> gnu.org
.
(Sat, 11 Dec 2021 14:54:01 GMT)
Full text and
rfc822 format available.
Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):
[Message part 1 (text/plain, inline)]
Hi,
the attached patch adds a client example that access the hello-world server.
[0001-doc-Provide-full-server-client-example.patch (text/x-patch, inline)]
From 7d41deec7a550a186fb5e653a7007ae38fd62dbd Mon Sep 17 00:00:00 2001
From: Arne Babenhauserheide <arne_bab <at> web.de>
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, responding to all
--
2.34.0
[Message part 3 (text/plain, inline)]
Best wishes,
Arne
--
Unpolitisch sein
heißt politisch sein,
ohne es zu merken.
draketo.de
[signature.asc (application/pgp-signature, inline)]
This bug report was last modified 3 years and 17 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.