unofficial mirror of 
 help / color / mirror / Atom feed
From: "Dr. Arne Babenhauserheide" <>
Subject: bug#52434: [patch] [doc] add http-request example to web examples
Date: Sat, 11 Dec 2021 15:51:41 +0100	[thread overview]
Message-ID: <> (raw)

[-- Attachment #1.1: Type: text/plain, Size: 83 bytes --]


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

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1.2: 0001-doc-Provide-full-server-client-example.patch --]
[-- Type: text/x-patch, Size: 2126 bytes --]

From 7d41deec7a550a186fb5e653a7007ae38fd62dbd 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 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.
+(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 ""))
+                            (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

[-- Attachment #1.3: Type: text/plain, Size: 101 bytes --]

Best wishes,
Unpolitisch sein
heißt politisch sein,
ohne es zu merken.

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 1125 bytes --]

                 reply	other threads:[~2021-12-11 14:51 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:

  List information:

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \ \ \ \
    --subject='Re: bug#52434: [patch] [doc] add http-request example to web examples' \

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).