summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorBilly Brown <druidofluhn@gmail.com>2023-12-21 17:07:00 +0000
committerPeter Bex <peter@more-magic.net>2024-01-11 13:59:39 +0100
commitb9683af2da882d542208a15d67d8040bab8fa5c2 (patch)
tree947497195eb439a0a22e4839f9adcb952c4b579c /tests
parentb2632661807a99fc7c3e610e8bd1b04c68b869c5 (diff)
downloadintarweb-b9683af2da882d542208a15d67d8040bab8fa5c2.tar.gz
Corrected Range and Content-Range header handling2.1.0
Corrected the handling of the Range request header and the Content- Range response header. They now have separate parsers, to match the standard, and the content-range unparser is now correctly named. The Range header can be in one of three forms: Range: bytes=<start>-<end> Range: bytes=<start>- Range: bytes=-<end> The Content-Range header can be in one of three forms: Content-Range: bytes <start>-<end>/<size> Content-Range: bytes <start>-<end>/* Content-Range: bytes */<size> The unit tests were updated to reflect the changes. Signed-off-by: Peter Bex <peter@more-magic.net>
Diffstat (limited to 'tests')
-rw-r--r--tests/run.scm42
1 files changed, 38 insertions, 4 deletions
diff --git a/tests/run.scm b/tests/run.scm
index d97f15d..95a3990 100644
--- a/tests/run.scm
+++ b/tests/run.scm
@@ -300,10 +300,34 @@
(header-value 'content-md5 headers))))
(test-group "range-parser"
- (let ((headers (test-read-headers "content-range: bytes 500-999/1234")))
- (test "Simple range"
- '(500 999 1234)
- (header-value 'content-range headers))))
+ (let ((headers (test-read-headers "range: bytes=500-999")))
+ (test "Simple range full"
+ '(500 999)
+ (header-value 'range headers)))
+ (let ((headers (test-read-headers "range: bytes=500-")))
+ (test "Simple range start"
+ '(500 #f)
+ (header-value 'range headers)))
+ (let ((headers (test-read-headers "range: bytes=-999")))
+ (test "Simple range end"
+ '(#f 999)
+ (header-value 'range headers)))
+ (let ((headers (test-read-headers "range: bytes 500-999/1234")))
+ (test "Content-range failure"
+ #f
+ (header-value 'range headers)))
+ (let ((headers (test-read-headers "range: bytes=-")))
+ (test "Numberless range failure"
+ #f
+ (header-value 'range headers)))
+ (let ((headers (test-read-headers "range: bytes 500-999")))
+ (test "Space failure"
+ #f
+ (header-value 'range headers)))
+ (let ((headers (test-read-headers "range: bits=500-999")))
+ (test "Wrong units failure"
+ #f
+ (header-value 'range headers))))
(test-group "content-disposition"
(let ((headers (test-read-headers "Content-Disposition: attachment; filename=dir/foo.jpg")))
@@ -645,6 +669,16 @@
(test-error* "Embedded newlines in raw headers also throw an error"
(exn http unencoded-header)
(test-unparse-headers `((foo #("bar\n\x01qux" raw))))))
+ (test-group "content-range unparser"
+ (test "Full content-range"
+ "Content-Range: bytes 500-999/1234\r\n"
+ (test-unparse-headers `((content-range (500 999 1234)))))
+ (test "Wildcard size content-range"
+ "Content-Range: bytes 500-999/*\r\n"
+ (test-unparse-headers `((content-range (500 999 #f)))))
+ (test "Wildcard range content-range"
+ "Content-Range: bytes */1234\r\n"
+ (test-unparse-headers `((content-range (#f #f 1234))))))
(test-group "etag unparser"
(test "Weak tag"
"Etag: W/\"blah\"\r\n"