[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] 108/119: test chunked/gzipped transfer/content encodings
From: |
Eric Schulte |
Subject: |
[elpa] 108/119: test chunked/gzipped transfer/content encodings |
Date: |
Mon, 10 Mar 2014 16:57:55 +0000 |
eschulte pushed a commit to branch master
in repository elpa.
commit b5e45f7d1438a705db3ae85f502fab08725b548a
Author: Eric Schulte <address@hidden>
Date: Wed Feb 12 16:38:18 2014 -0700
test chunked/gzipped transfer/content encodings
---
web-server-test.el | 32 ++++++++++++++++++++++++++++++--
1 files changed, 30 insertions(+), 2 deletions(-)
diff --git a/web-server-test.el b/web-server-test.el
index 5c03720..0af26e9 100644
--- a/web-server-test.el
+++ b/web-server-test.el
@@ -13,10 +13,11 @@
(defvar ws-test-port 8999)
-(defun ws-test-curl-to-string (url &optional get-params post-params)
+(defun ws-test-curl-to-string (url &optional get-params post-params curl-flags)
"Curl URL with optional parameters."
(async-shell-command
- (format "curl -m 4 %s %s localhost:%s/%s"
+ (format "curl -m 4 %s %s %s localhost:%s/%s"
+ (or curl-flags "")
(if get-params
(mapconcat (lambda (p) (format "-d '%s=%s'" (car p) (cdr p)))
get-params " ")
@@ -248,4 +249,31 @@ Content-Type: application/octet-stream
(should (string= (ws-web-socket-handshake "dGhlIHNhbXBsZSBub25jZQ==")
"s3pPLMBiTxaQ9kYGzzhZRbK+xOo=")))
+(ert-deftest ws/simple-chunked ()
+ "Test a simple server using chunked transfer encoding."
+ (ws-test-with
+ (lambda (request)
+ (with-slots (process) request
+ (ws-response-header process 200
+ '("Content-type" . "text/plain")
+ '("Transfer-Encoding" . "chunked"))
+ (ws-send process "I am chunked")))
+ (should (string= (ws-test-curl-to-string "") "I am chunked"))))
+
+(ert-deftest ws/simple-gzip ()
+ "Test a simple server using gzip content/transfer encoding."
+ (cl-macrolet ((gzipper (header)
+ `(ws-test-with
+ (lambda (request)
+ (with-slots (process) request
+ (ws-response-header process 200
+ '("Content-type" . "text/plain")
+ '(,header . "gzip"))
+ (ws-send process "I am zipped")))
+ (should (string= (ws-test-curl-to-string
+ "" nil nil "--compressed")
+ "I am zipped")))))
+ (gzipper "Content-Encoding")
+ (gzipper "Transfer-Encoding")))
+
(provide 'web-server-test)
- [elpa] 98/119: TODO chunked encoding, (continued)
- [elpa] 98/119: TODO chunked encoding, Eric Schulte, 2014/03/10
- [elpa] 99/119: serve files with htmlize Emacs fontification, Eric Schulte, 2014/03/10
- [elpa] 97/119: added ws-stop-all convenience function, Eric Schulte, 2014/03/10
- [elpa] 89/119: authorization helper, Eric Schulte, 2014/03/10
- [elpa] 92/119: simpler handler in example, Eric Schulte, 2014/03/10
- [elpa] 102/119: updated content- transfer-encoding notes, Eric Schulte, 2014/03/10
- [elpa] 103/119: set Content-length when serving files, Eric Schulte, 2014/03/10
- [elpa] 95/119: better ws-send-directory-list, Eric Schulte, 2014/03/10
- [elpa] 106/119: TODO Content and Transfer encodings, Eric Schulte, 2014/03/10
- [elpa] 104/119: tweak notes, Eric Schulte, 2014/03/10
- [elpa] 108/119: test chunked/gzipped transfer/content encodings,
Eric Schulte <=
- [elpa] 100/119: manual application of x-gzip content encoding, Eric Schulte, 2014/03/10
- [elpa] 101/119: manual application of chunked transfer encoding, Eric Schulte, 2014/03/10
- [elpa] 107/119: support for content and transfer encodings, Eric Schulte, 2014/03/10
- [elpa] 109/119: doc for new content/transfer encoding helpers, Eric Schulte, 2014/03/10
- [elpa] 110/119: automatically generate dir file w/install-info, Eric Schulte, 2014/03/10
- [elpa] 113/119: Fix WebSocket varint length encoding, Eric Schulte, 2014/03/10
- [elpa] 117/119: adding .elpaignore to keep extra file from package, Eric Schulte, 2014/03/10
- [elpa] 115/119: gnu elpa wants a "Maintainer:" pseudo-header, Eric Schulte, 2014/03/10
- [elpa] 114/119: dangerous example; web-socket comint shell buffer, Eric Schulte, 2014/03/10
- [elpa] 105/119: mention `make check' in README, Eric Schulte, 2014/03/10