diff --git a/collects/tests/web-server/dispatchers/dispatch-files-test.rkt b/collects/tests/web-server/dispatchers/dispatch-files-test.rkt index 59dbacb8f5..a42f645af2 100644 --- a/collects/tests/web-server/dispatchers/dispatch-files-test.rkt +++ b/collects/tests/web-server/dispatchers/dispatch-files-test.rkt @@ -39,12 +39,6 @@ (define dir-url (string->url "http://test.com/foo/")) (define (req d? meth heads) (make-request meth (if d? dir-url file-url) heads (delay empty) #"" "host" 80 "client")) - -(define (bytes-sort bs) - (sort - (with-input-from-bytes bs - (λ () (port->bytes-lines #:line-mode 'return-linefeed))) - bytesbytes i-port)) - (if redact? (redact bs) bs)) + (bytes-sort (if redact? (redact bs) bs))) (test (write-response (response/xexpr '(a ([href "#"]) "link"))) => - #"HTTP/1.1 200 Okay\r\nDate: REDACTED GMT\r\nLast-Modified: REDACTED GMT\r\nServer: Racket\r\nContent-Type: text/html; charset=utf-8\r\nConnection: close\r\n\r\nlink" + (bytes-sort + #"HTTP/1.1 200 Okay\r\nDate: REDACTED GMT\r\nLast-Modified: REDACTED GMT\r\nServer: Racket\r\nContent-Type: text/html; charset=utf-8\r\nConnection: close\r\n\r\nlink") (write-response (response/xexpr '(a ([href "#"]) "link") - #:code 404)) + #:code 404)) => - #"HTTP/1.1 404 Okay\r\nDate: REDACTED GMT\r\nLast-Modified: REDACTED GMT\r\nServer: Racket\r\nContent-Type: text/html; charset=utf-8\r\nConnection: close\r\n\r\nlink" + (bytes-sort + #"HTTP/1.1 404 Okay\r\nDate: REDACTED GMT\r\nLast-Modified: REDACTED GMT\r\nServer: Racket\r\nContent-Type: text/html; charset=utf-8\r\nConnection: close\r\n\r\nlink") (write-response (response/xexpr '(a ([href "#"]) "link") - #:message #"Bad request")) + #:message #"Bad request")) => - #"HTTP/1.1 200 Bad request\r\nDate: REDACTED GMT\r\nLast-Modified: REDACTED GMT\r\nServer: Racket\r\nContent-Type: text/html; charset=utf-8\r\nConnection: close\r\n\r\nlink" + (bytes-sort + #"HTTP/1.1 200 Bad request\r\nDate: REDACTED GMT\r\nLast-Modified: REDACTED GMT\r\nServer: Racket\r\nContent-Type: text/html; charset=utf-8\r\nConnection: close\r\n\r\nlink") - (regexp-replace - #"Date: [a-zA-Z0-9:, ]+ GMT\r\n" + (map + (λ (b) (regexp-replace + #"Date: [a-zA-Z0-9:, ]+ GMT" + b + #"Date: REDACTED GMT")) (write-response (response/xexpr '(a ([href "#"]) "link") - #:seconds 0) - #f) - #"Date: REDACTED GMT\r\n") + #:seconds 0) + #f)) => - #"HTTP/1.1 200 Okay\r\nDate: REDACTED GMT\r\nLast-Modified: Thu, 01 Jan 1970 00:00:00 GMT\r\nServer: Racket\r\nContent-Type: text/html; charset=utf-8\r\nConnection: close\r\n\r\nlink" + (bytes-sort + #"HTTP/1.1 200 Okay\r\nDate: REDACTED GMT\r\nLast-Modified: Thu, 01 Jan 1970 00:00:00 GMT\r\nServer: Racket\r\nContent-Type: text/html; charset=utf-8\r\nConnection: close\r\n\r\nlink") (write-response (response/xexpr '(a ([href "#"]) "link") #:mime-type #"application/xml")) => - #"HTTP/1.1 200 Okay\r\nDate: REDACTED GMT\r\nLast-Modified: REDACTED GMT\r\nServer: Racket\r\nContent-Type: application/xml\r\nConnection: close\r\n\r\nlink" + (bytes-sort + #"HTTP/1.1 200 Okay\r\nDate: REDACTED GMT\r\nLast-Modified: REDACTED GMT\r\nServer: Racket\r\nContent-Type: application/xml\r\nConnection: close\r\n\r\nlink") (write-response (response/xexpr '(a ([href "#"]) "link") #:headers (list (header #"head" #"value")))) => - #"HTTP/1.1 200 Okay\r\nDate: REDACTED GMT\r\nLast-Modified: REDACTED GMT\r\nServer: Racket\r\nContent-Type: text/html; charset=utf-8\r\nConnection: close\r\nhead: value\r\n\r\nlink" + (bytes-sort + #"HTTP/1.1 200 Okay\r\nDate: REDACTED GMT\r\nLast-Modified: REDACTED GMT\r\nServer: Racket\r\nContent-Type: text/html; charset=utf-8\r\nConnection: close\r\nhead: value\r\n\r\nlink") (write-response (response/xexpr '(a ([href "#"]) "link") #:cookies (list (make-cookie "head" "value")))) => - #"HTTP/1.1 200 Okay\r\nDate: REDACTED GMT\r\nLast-Modified: REDACTED GMT\r\nServer: Racket\r\nContent-Type: text/html; charset=utf-8\r\nConnection: close\r\nSet-Cookie: head=value; Version=1\r\n\r\nlink" + (bytes-sort + #"HTTP/1.1 200 Okay\r\nDate: REDACTED GMT\r\nLast-Modified: REDACTED GMT\r\nServer: Racket\r\nContent-Type: text/html; charset=utf-8\r\nConnection: close\r\nSet-Cookie: head=value; Version=1\r\n\r\nlink") (write-response (response/xexpr '(a ([href "#"]) "link") #:preamble #"<>")) => - #"HTTP/1.1 200 Okay\r\nDate: REDACTED GMT\r\nLast-Modified: REDACTED GMT\r\nServer: Racket\r\nContent-Type: text/html; charset=utf-8\r\nConnection: close\r\n\r\n<>link") \ No newline at end of file + (bytes-sort + #"HTTP/1.1 200 Okay\r\nDate: REDACTED GMT\r\nLast-Modified: REDACTED GMT\r\nServer: Racket\r\nContent-Type: text/html; charset=utf-8\r\nConnection: close\r\n\r\n<>link")) \ No newline at end of file diff --git a/collects/tests/web-server/util.rkt b/collects/tests/web-server/util.rkt index 6777900aab..93586e59db 100644 --- a/collects/tests/web-server/util.rkt +++ b/collects/tests/web-server/util.rkt @@ -15,7 +15,14 @@ redact collect htxml - call) + call + bytes-sort) + +(define (bytes-sort bs) + (sort + (with-input-from-bytes bs + (λ () (port->bytes-lines #:line-mode 'return-linefeed))) + bytessymbol (compose string->symbol keyword->string)) (define (simple-xpath/xexpr p x)