diff options
author | Andy Wingo <wingo@pobox.com> | 2011-12-22 08:18:05 -0500 |
---|---|---|
committer | Andy Wingo <wingo@pobox.com> | 2011-12-22 08:18:05 -0500 |
commit | 61fe8eafc236e2f76259e987d66f43e97fc1eed4 (patch) | |
tree | 6ce00bd3e000ad10b0dd16376fe0bd2f8c4beef2 | |
parent | 321770b2a3d7b43a7f24e5a1b3ed8bb36c411ffe (diff) | |
download | guile-61fe8eafc236e2f76259e987d66f43e97fc1eed4.tar.gz |
HTTP: Fix qstring writing of cache-extension values
* module/web/http.scm ("Cache-Control"): Write string values using the
default val writer, to get quoting correct.
* test-suite/tests/web-http.test (pass-if-round-trip): New helper.
("general headers"): Check that cache-extensions round trip properly.
-rw-r--r-- | module/web/http.scm | 2 | ||||
-rw-r--r-- | test-suite/tests/web-http.test | 16 |
2 files changed, 17 insertions, 1 deletions
diff --git a/module/web/http.scm b/module/web/http.scm index 20ea2aa6b..afe70a7fd 100644 --- a/module/web/http.scm +++ b/module/web/http.scm @@ -1261,7 +1261,7 @@ phrase\"." (or (not v) (string? v))))) (lambda (k v port) (cond - ((string? v) (display v port)) + ((string? v) (default-val-writer k v port)) ((pair? v) (display #\" port) (write-header-list v port) diff --git a/test-suite/tests/web-http.test b/test-suite/tests/web-http.test index b5247ab5c..79845653e 100644 --- a/test-suite/tests/web-http.test +++ b/test-suite/tests/web-http.test @@ -45,6 +45,18 @@ val) (valid-header? 'sym val)))))) +(define-syntax pass-if-round-trip + (syntax-rules () + ((_ str) + (pass-if (format #f "~s round trip" str) + (equal? (call-with-output-string + (lambda (port) + (call-with-values + (lambda () (read-header (open-input-string str))) + (lambda (sym val) + (write-header sym val port))))) + str))))) + (define-syntax pass-if-any-error (syntax-rules () ((_ sym str) @@ -85,6 +97,10 @@ '(no-cache (max-age . 10))) (pass-if-parse cache-control "max-stale" '(max-stale)) (pass-if-parse cache-control "max-stale=10" '((max-stale . 10))) + (pass-if-round-trip "Cache-Control: acme-cache-extension\r\n") + (pass-if-round-trip "Cache-Control: acme-cache-extension=20\r\n") + (pass-if-round-trip "Cache-Control: acme-cache-extension=100 quux\r\n") + (pass-if-round-trip "Cache-Control: acme-cache-extension=\"100, quux\"\r\n") (pass-if-parse connection "close" '(close)) (pass-if-parse connection "Content-Encoding" '(content-encoding)) |