summaryrefslogtreecommitdiff
path: root/module/web
diff options
context:
space:
mode:
authorAndy Wingo <wingo@pobox.com>2014-01-18 21:08:52 +0100
committerAndy Wingo <wingo@pobox.com>2014-01-18 21:08:52 +0100
commit97461d739bb6b71f221fde580f29fdfeb33b624f (patch)
tree5768b8918b99a04612a046d222e36dd6fe35784c /module/web
parent69dc8268c278e0693b8240bf09a92e575dd1017b (diff)
downloadguile-97461d739bb6b71f221fde580f29fdfeb33b624f.tar.gz
Add support for content-disposition
* module/web/http.scm ("Content-Disposition"): Add a parser and serializer. Defined in RFC2616 section 19.5.1. * test-suite/tests/web-http.test ("entity headers"): New test case.
Diffstat (limited to 'module/web')
-rw-r--r--module/web/http.scm26
1 files changed, 25 insertions, 1 deletions
diff --git a/module/web/http.scm b/module/web/http.scm
index 6c9ab9523..d22c70c6e 100644
--- a/module/web/http.scm
+++ b/module/web/http.scm
@@ -1,6 +1,6 @@
;;; HTTP messages
-;; Copyright (C) 2010, 2011, 2012, 2013 Free Software Foundation, Inc.
+;; Copyright (C) 2010, 2011, 2012, 2013, 2014 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
@@ -1483,6 +1483,30 @@ treated specially, and is just returned as a plain string."
;;
(declare-symbol-list-header! "Allow")
+;; Content-Disposition = disposition-type *( ";" disposition-parm )
+;; disposition-type = "attachment" | disp-extension-token
+;; disposition-parm = filename-parm | disp-extension-parm
+;; filename-parm = "filename" "=" quoted-string
+;; disp-extension-token = token
+;; disp-extension-parm = token "=" ( token | quoted-string )
+;;
+(declare-header! "Content-Disposition"
+ (lambda (str)
+ (let ((disposition (parse-param-list str default-val-parser)))
+ ;; Lazily reuse the param list parser.
+ (unless (and (pair? disposition)
+ (null? (cdr disposition)))
+ (bad-header-component 'content-disposition str))
+ (car disposition)))
+ (lambda (val)
+ (and (pair? val)
+ (symbol? (car val))
+ (list-of? (cdr val)
+ (lambda (x)
+ (and (pair? x) (symbol? (car x)) (string? (cdr x)))))))
+ (lambda (val port)
+ (write-param-list (list val) port)))
+
;; Content-Encoding = 1#content-coding
;;
(declare-symbol-list-header! "Content-Encoding")