summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIan Price <ianprice90@googlemail.com>2013-08-19 03:43:48 +0100
committerIan Price <ianprice90@googlemail.com>2013-08-19 10:43:02 +0100
commit20d28792b3781e2ca4fd31f4978fc7a0adfbab9a (patch)
tree065efb76a138df96aeb902104c4ec57ea34006c5
parent088cfb7d761b01a2620d78f10e8dbcaa07485a32 (diff)
downloadguile-20d28792b3781e2ca4fd31f4978fc7a0adfbab9a.tar.gz
`write-request-line' always prints a path component.
* module/web/http.scm (write-request-line): Always write "/" when path is empty, regardless of query. * test-suite/tests/web-http.test ("write-request-line"): Add test.
-rw-r--r--module/web/http.scm9
-rw-r--r--test-suite/tests/web-http.test4
2 files changed, 7 insertions, 6 deletions
diff --git a/module/web/http.scm b/module/web/http.scm
index 21d2964b4..af04259cc 100644
--- a/module/web/http.scm
+++ b/module/web/http.scm
@@ -1137,16 +1137,13 @@ three values: the method, the URI, and the version."
(display host-port port)))))
(let ((path (uri-path uri))
(query (uri-query uri)))
- (if (not (string-null? path))
+ (if (string-null? path)
+ (display "/" port)
(display path port))
(if query
(begin
(display "?" port)
- (display query port)))
- (if (and (string-null? path)
- (not query))
- ;; Make sure we display something.
- (display "/" port)))
+ (display query port))))
(display #\space port)
(write-http-version version port)
(display "\r\n" port))
diff --git a/test-suite/tests/web-http.test b/test-suite/tests/web-http.test
index b2c5c2c2b..e24a268ec 100644
--- a/test-suite/tests/web-http.test
+++ b/test-suite/tests/web-http.test
@@ -173,6 +173,10 @@
(build-uri 'http
#:path "/pub/WWW/TheProject.html")
(1 . 1))
+ (pass-if-write-request-line "GET /?foo HTTP/1.1"
+ GET
+ (build-uri 'http #:query "foo")
+ (1 . 1))
(pass-if-write-request-line "HEAD /etc/hosts?foo=bar HTTP/1.1"
HEAD
(build-uri 'http