unofficial mirror of guix-patches@gnu.org 
 help / color / mirror / code / Atom feed
From: Nicolas Graves via Guix-patches via <guix-patches@gnu.org>
To: 70308@debbugs.gnu.org
Cc: ngraves@ngraves.fr
Subject: [bug#70308] [PATCH] guix: http tests: Log bad requests.
Date: Tue,  9 Apr 2024 13:06:32 +0200	[thread overview]
Message-ID: <20240409110632.31710-1-ngraves@ngraves.fr> (raw)

* guix/test/http.scm (call-with-http-server): Log bad requests to make
debugging easier.

Change-Id: I2bb7231db1e5cd9a6e1c4cf76d256fa7c9e50776
---
 guix/tests/http.scm | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/guix/tests/http.scm b/guix/tests/http.scm
index 17485df9ef..e02f91923c 100644
--- a/guix/tests/http.scm
+++ b/guix/tests/http.scm
@@ -132,8 +132,10 @@ (define-server-impl stub-http-server
     http-write
     (@@ (web server http) http-close))
 
-  (define bad-request
-    (build-response #:code 400 #:reason-phrase "Unexpected request"))
+  (define (bad-request req)
+    (build-response
+     #:code 400
+     #:reason-phrase (string-append "Unexpected request: " req)))
 
   (define (server-body)
     (define (handle request body)
@@ -144,7 +146,7 @@ (define (handle request body)
         ((((? string?) response data) ...)
          (let ((path (uri-path (request-uri request))))
            (match (assoc path responses)
-             (#f (values bad-request ""))
+             (#f (values (bad-request path) ""))
              ((_ response data)
               (if (eq? 'GET (request-method request))
                   ;; Note: Use 'assoc-remove!' to remove only the first entry
@@ -153,7 +155,7 @@ (define (handle request body)
                   (let ((rest (assoc-remove! responses path)))
                     (set! responses rest)
                     (values response data))
-                  (values bad-request ""))))))))
+                  (values (bad-request path) ""))))))))
 
     (let-values (((socket port) (open-http-server-socket)))
       (set! %http-real-server-port port)
-- 
2.41.0





                 reply	other threads:[~2024-04-09 11:08 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:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://guix.gnu.org/

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

  git send-email \
    --in-reply-to=20240409110632.31710-1-ngraves@ngraves.fr \
    --to=guix-patches@gnu.org \
    --cc=70308@debbugs.gnu.org \
    --cc=ngraves@ngraves.fr \
    /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.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/guix.git

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).