[plt-dev] web-server redirect behavior and possible patch

From: YC (yinso.chen at gmail.com)
Date: Wed Mar 4 02:05:10 EST 2009

I just noticed that if empty string "" is passed into `(redirect-to)`, the
response will not include a Location header (even though the header object
exists in the response object generated by `(redirect-to)`.

While passing in empty string is a client bug, perhaps it's better to simply
stop the input in the first place?

If so - below is a plausible patch for web-server/http/redirect.ss

Thanks,
yc

--- /usr/local/plt/lib/plt/collects/web-server/http/redirect.ss 2008-11-16
11:34:46.000000000 -0800
+++ plt-scheme/web-server/http/redirect.ss      2009-03-03
23:00:10.000000000 -0800
@@ -24,7 +24,8 @@

 (provide/contract
  [redirect-to
-  (->* (string?) (redirection-status? #:headers (listof header?))
+  (->* ((and/c string? (lambda (s) (> (string-length s) 0))))
+       (redirection-status? #:headers (listof header?))
        response/full?)]
  [redirection-status? (any/c . -> . boolean?)]
  [permanently redirection-status?]
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.racket-lang.org/dev/archive/attachments/20090303/0fcd0f32/attachment.html>

Posted on the dev mailing list.