Created
September 14, 2013 04:30
-
-
Save NalaGinrut/6558837 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/test-suite/tests/web-client.test b/test-suite/tests/web-client.test | |
index 3133b73..6038398 100644 | |
--- a/test-suite/tests/web-client.test | |
+++ b/test-suite/tests/web-client.test | |
@@ -299,13 +299,28 @@ Content-Language: en | |
") | |
;; Unfortunately, POST to http://www.gnu.org/software/guile/ succeeds! | |
+(define post-request-headers-null:www.apache.org/ | |
+ "POST / HTTP/1.1 | |
+Content-Length: 0 | |
+Content-Type: text/plain;charset=utf-8 | |
+Host: www.apache.org | |
+Connection: close | |
+ | |
+") | |
+ | |
(define post-request-headers:www.apache.org/ | |
"POST / HTTP/1.1 | |
+Content-Length: 137 | |
+Content-Type: text/plain;charset=utf-8 | |
Host: www.apache.org | |
Connection: close | |
") | |
+(define post-request-body:www.apache.org/ | |
+ "GNU's Ubiquitous Intelligent Language for Extension, a library | |
+implementation of the Scheme language plus various convenient facilities.") | |
+ | |
(define post-response-headers:www.apache.org/ | |
"HTTP/1.1 405 Method Not Allowed | |
Date: Fri, 11 Jan 2013 11:04:34 GMT | |
@@ -329,13 +344,28 @@ Content-Type: text/html; charset=iso-8859-1 | |
</body></html> | |
") | |
+(define put-request-headers-null:www.apache.org/ | |
+ "PUT / HTTP/1.1 | |
+Content-Length: 0 | |
+Content-Type: text/plain;charset=utf-8 | |
+Host: www.apache.org | |
+Connection: close | |
+ | |
+") | |
+ | |
(define put-request-headers:www.apache.org/ | |
"PUT / HTTP/1.1 | |
+Content-Length: 137 | |
+Content-Type: text/plain;charset=utf-8 | |
Host: www.apache.org | |
Connection: close | |
") | |
+(define put-request-body:www.apache.org/ | |
+ "GNU's Ubiquitous Intelligent Language for Extension, a library | |
+implementation of the Scheme language plus various convenient facilities.") | |
+ | |
(define put-response-headers:www.apache.org/ | |
"HTTP/1.1 405 Method Not Allowed | |
Date: Fri, 11 Jan 2013 11:04:34 GMT | |
@@ -361,6 +391,8 @@ Content-Type: text/html; charset=iso-8859-1 | |
(define delete-request-headers:www.apache.org/ | |
"DELETE / HTTP/1.1 | |
+Content-Length: 0 | |
+Content-Type: text/plain;charset=utf-8 | |
Host: www.apache.org | |
Connection: close | |
@@ -393,6 +425,8 @@ Content-Type: text/html; charset=iso-8859-1 | |
(define options-request-headers:www.apache.org/ | |
"OPTIONS / HTTP/1.1 | |
+Content-Length: 0 | |
+Content-Type: text/plain;charset=utf-8 | |
Host: www.apache.org | |
Connection: close | |
@@ -444,6 +478,10 @@ Connection: close\r | |
") | |
(define (requests-equal? r1 r2) | |
+;; (format #t "METHOD- ~a : ~a~%" (request-method r1) (request-method r2)) | |
+;; (format #t "URI- ~a : ~a~%" (request-uri r1) (request-uri r2)) | |
+;; (format #t "VERSION- ~a : ~a~%" (request-version r1) (request-version r2)) | |
+;; (format #t "HEADERS- ~a : ~a~%" (request-headers r1) (request-headers r2)) | |
(and (equal? (request-method r1) (request-method r2)) | |
(equal? (request-uri r1) (request-uri r2)) | |
(equal? (request-version r1) (request-version r2)) | |
@@ -483,9 +521,11 @@ Connection: close\r | |
(call-with-input-string expected-request | |
read-request))) | |
(pass-if "request bodies equal" | |
- (equal? (or actual-body #vu8()) | |
- (string->bytevector expected-request-body | |
- request-body-encoding))))) | |
+ (if expected-request-body | |
+ (equal? (or actual-body #vu8()) | |
+ (string->bytevector expected-request-body | |
+ request-body-encoding)) | |
+ (not actual-body))))) | |
(define (get-char) | |
(unless reading? | |
(error "Port closed for reading")) | |
@@ -514,7 +554,7 @@ Connection: close\r | |
response-headers response-body response-body-encoding | |
(lambda (port) | |
(call-with-values (lambda () | |
- (proc uri #:port port)) | |
+ (proc uri #:port port #:body request-body)) | |
(lambda (response body) | |
(pass-if "response equal" | |
(responses-equal? | |
@@ -525,27 +565,45 @@ Connection: close\r | |
(check-transaction | |
"GET" "http://www.gnu.org/software/guile/" | |
- get-request-headers:www.gnu.org/software/guile/ "" "iso-8859-1" | |
+ get-request-headers:www.gnu.org/software/guile/ #f "iso-8859-1" | |
get-response-headers:www.gnu.org/software/guile/ | |
get-response-body:www.gnu.org/software/guile/ "iso-8859-1" | |
http-get) | |
(check-transaction | |
"HEAD" "http://www.gnu.org/software/guile/" | |
- head-request-headers:www.gnu.org/software/guile/ "" "iso-8859-1" | |
+ head-request-headers:www.gnu.org/software/guile/ #f "iso-8859-1" | |
head-response-headers:www.gnu.org/software/guile/ "" "iso-8859-1" | |
http-head) | |
+;; test POST with NULL entity | |
(check-transaction | |
"POST" "http://www.apache.org/" | |
- post-request-headers:www.apache.org/ "" "iso-8859-1" | |
+ post-request-headers-null:www.apache.org/ "" "iso-8859-1" | |
post-response-headers:www.apache.org/ | |
post-response-body:www.apache.org/ "iso-8859-1" | |
http-post) | |
(check-transaction | |
+ "POST" "http://www.apache.org/" | |
+ post-request-headers:www.apache.org/ | |
+ post-request-body:www.apache.org/ "iso-8859-1" | |
+ post-response-headers:www.apache.org/ | |
+ post-response-body:www.apache.org/ "iso-8859-1" | |
+ http-post) | |
+ | |
+;; test PUT with NULL entity | |
+(check-transaction | |
+ "PUT" "http://www.apache.org/" | |
+ put-request-headers-null:www.apache.org/ "" "iso-8859-1" | |
+ put-response-headers:www.apache.org/ | |
+ put-response-body:www.apache.org/ "iso-8859-1" | |
+ http-put) | |
+ | |
+(check-transaction | |
"PUT" "http://www.apache.org/" | |
- put-request-headers:www.apache.org/ "" "iso-8859-1" | |
+ put-request-headers:www.apache.org/ | |
+ put-request-body:www.apache.org/ "iso-8859-1" | |
put-response-headers:www.apache.org/ | |
put-response-body:www.apache.org/ "iso-8859-1" | |
http-put) | |
@@ -565,7 +623,7 @@ Connection: close\r | |
(check-transaction | |
"TRACE" "http://www.apache.org/" | |
- trace-request-headers:www.apache.org/ "" "iso-8859-1" | |
+ trace-request-headers:www.apache.org/ #f "iso-8859-1" | |
trace-response-headers:www.apache.org/ | |
trace-response-body:www.apache.org/ "iso-8859-1" | |
http-trace |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment