From: "Aleix Conchillo Flaqué" <aconchillo@gmail.com>
To: guile-devel@gnu.org
Cc: "Aleix Conchillo Flaqué" <aconchillo@gmail.com>
Subject: [PATCH] web: default to INADDR_ANY instead of INADDR_LOOPBACK
Date: Wed, 2 Feb 2022 16:26:38 -0800 [thread overview]
Message-ID: <20220203002638.34504-1-aconchillo@gmail.com> (raw)
Using INADDR_ANY instead of INADDR_LOOPBACK makes it convenient when
starting the web server inside containers without the need to having to
specify INADDR_ANY all the time. This is the default in most libraries
and languages.
This doesn't break backwards compatibility since INADDR_LOOPBACK is also
included in INADDR_ANY.
* doc/ref/web.texi (Web Server): update INADDR_LOOPBACK to INADDR_ANY
and related text.
* module/web/server/http.scm (http-open): default to INADDR_ANY for the
web server.
---
doc/ref/web.texi | 10 +++++-----
module/web/server/http.scm | 4 ++--
2 files changed, 7 insertions(+), 7 deletions(-)
diff --git a/doc/ref/web.texi b/doc/ref/web.texi
index 93cd0214f..6b42b8ff6 100644
--- a/doc/ref/web.texi
+++ b/doc/ref/web.texi
@@ -1807,7 +1807,7 @@ socket, listening for request on that port.
@deffn {HTTP Implementation} http [#:host=#f] @
[#:family=AF_INET] @
- [#:addr=INADDR_LOOPBACK] @
+ [#:addr=INADDR_ANY] @
[#:port 8080] [#:socket]
The default HTTP implementation. We document it as a function with
keyword arguments, because that is precisely the way that it is -- all
@@ -1815,7 +1815,7 @@ of the @var{open-params} to @code{run-server} get passed to the
implementation's open function.
@example
-;; The defaults: localhost:8080
+;; The defaults: any local IP on port 8080
(run-server handler)
;; Same thing
(run-server handler 'http '())
@@ -1866,9 +1866,9 @@ handler:
(run-server hello-world-handler)
@end example
-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!
+By default, the web server listens for requests on port @code{8080}.
+Visit @code{http://localhost:8080} in your web browser to test. If you
+see the string, @code{Hello World!}, sweet!
@subsubsection Inspecting the Request
diff --git a/module/web/server/http.scm b/module/web/server/http.scm
index 05bf46bf0..91354021c 100644
--- a/module/web/server/http.scm
+++ b/module/web/server/http.scm
@@ -1,6 +1,6 @@
;;; Web I/O: HTTP
-;; Copyright (C) 2010, 2011, 2012, 2015 Free Software Foundation, Inc.
+;; Copyright (C) 2010, 2011, 2012, 2015, 2022 Free Software Foundation, Inc.
;; This library is free software; you can redistribute it and/or
;; modify it under the terms of the GNU Lesser General Public
@@ -61,7 +61,7 @@
(family AF_INET)
(addr (if host
(inet-pton family host)
- INADDR_LOOPBACK))
+ INADDR_ANY))
(port 8080)
(socket (make-default-socket family addr port)))
(listen socket 128)
--
2.35.1
next reply other threads:[~2022-02-03 0:26 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-02-03 0:26 Aleix Conchillo Flaqué [this message]
2022-02-03 7:25 ` [PATCH] web: default to INADDR_ANY instead of INADDR_LOOPBACK Dr. Arne Babenhauserheide
2022-07-22 0:44 ` Aleix Conchillo Flaqué
2022-07-22 9:44 ` Maxime Devos
2022-07-22 17:14 ` Aleix Conchillo Flaqué
2022-07-22 11:45 ` Greg Troxel
2022-07-22 17:16 ` Aleix Conchillo Flaqué
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:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/guile/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220203002638.34504-1-aconchillo@gmail.com \
--to=aconchillo@gmail.com \
--cc=guile-devel@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).