unofficial mirror of guix-patches@gnu.org 
 help / color / mirror / code / Atom feed
* [bug#70308] [PATCH] guix: http tests: Log bad requests.
@ 2024-04-09 11:06 Nicolas Graves via Guix-patches via
  0 siblings, 0 replies; only message in thread
From: Nicolas Graves via Guix-patches via @ 2024-04-09 11:06 UTC (permalink / raw)
  To: 70308; +Cc: ngraves

* 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





^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2024-04-09 11:08 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-04-09 11:06 [bug#70308] [PATCH] guix: http tests: Log bad requests Nicolas Graves via Guix-patches via

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