This one's about as annoying as the content-length bug (a lot) and
about as difficult to work around (quite easy, actually).
Basically, if you don't explicitely clear headers after you serve a
request, *and* the client actually uses the same connection (i.e.
curl does this), the headers never get cleared, which leads to
surprising behaviour, such as a normal page serving a redirect
because the last page was a redirect.
This is also true for the response code, which is just as bad, if
not worse.
Code and output attached.
-Robin
--
Lojban Reason #17: http://en.wikipedia.org/wiki/Buffalo_buffalo
Proud Supporter of the Singularity Institute - http://singinst.org/
http://www.digitalkingdom.org/~rlpowell/ *** http://www.lojban.org/
(use hart)
(use riaxpander)
(use spiffy)
(use caketext)
; I don't know what this is supposed to do in its original form in
; http-server.scm, but right now it just breaks our tests
(http:content-parser 'application/x-www-form-urlencoded (lambda (a b c) (values
#f #f)))
(spiffy-debug-mode #t)
(spiffy-tcp-port 7623)
(http:add-resource
"/redir1.scm"
(lambda (request get-args)
(current-request request)
(current-urlencoded-arguments get-args)
(set-header! "Content-length: 0")
(redirect "/data.scm")
(write-response-header)))
(http:add-resource
"/redir2.scm"
(lambda (request get-args)
(current-request request)
(current-urlencoded-arguments get-args)
(set-header! "Content-length: 0")
(redirect "/data.scm")
(write-response-header)
(current-response-headers '())))
(http:add-resource
"/data.scm"
(lambda (request get-args)
(current-request request)
(current-urlencoded-arguments get-args)
(set-header! "Content-length: 5")
(write-response-header)
(display "data\n")))
(start-server location: (get-host-name) init: noop)
$ curl -L -D - 'http://chain.teddyb.org:7623/redir1.scm'
HTTP/1.1 302 Found
Server: spiffy No. 3 (Release 8) on Chicken 3.1.2
Location: /data.scm
Content-length: 0
HTTP/1.1 302 Found
Server: spiffy No. 3 (Release 8) on Chicken 3.1.2
Location: /data.scm
Content-length: 5
HTTP/1.1 302 Found
Server: spiffy No. 3 (Release 8) on Chicken 3.1.2
Location: /data.scm
Content-length: 5
HTTP/1.1 302 Found
Server: spiffy No. 3 (Release 8) on Chicken 3.1.2
Location: /data.scm
Content-length: 5
HTTP/1.1 302 Found
Server: spiffy No. 3 (Release 8) on Chicken 3.1.2
Location: /data.scm
Content-length: 5
HTTP/1.1 302 Found
Server: spiffy No. 3 (Release 8) on Chicken 3.1.2
Location: /data.scm
Content-length: 5
HTTP/1.1 302 Found
Server: spiffy No. 3 (Release 8) on Chicken 3.1.2
Location: /data.scm
Content-length: 5
HTTP/1.1 302 Found
Server: spiffy No. 3 (Release 8) on Chicken 3.1.2
Location: /data.scm
Content-length: 5
HTTP/1.1 302 Found
Server: spiffy No. 3 (Release 8) on Chicken 3.1.2
Location: /data.scm
Content-length: 5
HTTP/1.1 302 Found
Server: spiffy No. 3 (Release 8) on Chicken 3.1.2
Location: /data.scm
Content-length: 5
HTTP/1.1 302 Found
Server: spiffy No. 3 (Release 8) on Chicken 3.1.2
Location: /data.scm
Content-length: 5
HTTP/1.1 302 Found
Server: spiffy No. 3 (Release 8) on Chicken 3.1.2
Location: /data.scm
Content-length: 5
HTTP/1.1 302 Found
Server: spiffy No. 3 (Release 8) on Chicken 3.1.2
Location: /data.scm
Content-length: 5
HTTP/1.1 302 Found
Server: spiffy No. 3 (Release 8) on Chicken 3.1.2
Location: /data.scm
Content-length: 5
HTTP/1.1 302 Found
Server: spiffy No. 3 (Release 8) on Chicken 3.1.2
Location: /data.scm
Content-length: 5
HTTP/1.1 302 Found
Server: spiffy No. 3 (Release 8) on Chicken 3.1.2
Location: /data.scm
Content-length: 5
HTTP/1.1 302 Found
Server: spiffy No. 3 (Release 8) on Chicken 3.1.2
Location: /data.scm
Content-length: 5
HTTP/1.1 302 Found
Server: spiffy No. 3 (Release 8) on Chicken 3.1.2
Location: /data.scm
Content-length: 5
HTTP/1.1 302 Found
Server: spiffy No. 3 (Release 8) on Chicken 3.1.2
Location: /data.scm
Content-length: 5
HTTP/1.1 302 Found
Server: spiffy No. 3 (Release 8) on Chicken 3.1.2
Location: /data.scm
Content-length: 5
HTTP/1.1 302 Found
Server: spiffy No. 3 (Release 8) on Chicken 3.1.2
Location: /data.scm
Content-length: 5
HTTP/1.1 302 Found
Server: spiffy No. 3 (Release 8) on Chicken 3.1.2
Location: /data.scm
Content-length: 5
HTTP/1.1 302 Found
Server: spiffy No. 3 (Release 8) on Chicken 3.1.2
Location: /data.scm
Content-length: 5
HTTP/1.1 302 Found
Server: spiffy No. 3 (Release 8) on Chicken 3.1.2
Location: /data.scm
Content-length: 5
HTTP/1.1 302 Found
Server: spiffy No. 3 (Release 8) on Chicken 3.1.2
Location: /data.scm
Content-length: 5
HTTP/1.1 302 Found
Server: spiffy No. 3 (Release 8) on Chicken 3.1.2
Location: /data.scm
Content-length: 5
HTTP/1.1 302 Found
Server: spiffy No. 3 (Release 8) on Chicken 3.1.2
Location: /data.scm
Content-length: 5
HTTP/1.1 302 Found
Server: spiffy No. 3 (Release 8) on Chicken 3.1.2
Location: /data.scm
Content-length: 5
HTTP/1.1 302 Found
Server: spiffy No. 3 (Release 8) on Chicken 3.1.2
Location: /data.scm
Content-length: 5
HTTP/1.1 302 Found
Server: spiffy No. 3 (Release 8) on Chicken 3.1.2
Location: /data.scm
Content-length: 5
HTTP/1.1 302 Found
Server: spiffy No. 3 (Release 8) on Chicken 3.1.2
Location: /data.scm
Content-length: 5
HTTP/1.1 302 Found
Server: spiffy No. 3 (Release 8) on Chicken 3.1.2
Location: /data.scm
Content-length: 5
HTTP/1.1 302 Found
Server: spiffy No. 3 (Release 8) on Chicken 3.1.2
Location: /data.scm
Content-length: 5
HTTP/1.1 302 Found
Server: spiffy No. 3 (Release 8) on Chicken 3.1.2
Location: /data.scm
Content-length: 5
HTTP/1.1 302 Found
Server: spiffy No. 3 (Release 8) on Chicken 3.1.2
Location: /data.scm
Content-length: 5
HTTP/1.1 302 Found
Server: spiffy No. 3 (Release 8) on Chicken 3.1.2
Location: /data.scm
Content-length: 5
HTTP/1.1 302 Found
Server: spiffy No. 3 (Release 8) on Chicken 3.1.2
Location: /data.scm
Content-length: 5
HTTP/1.1 302 Found
Server: spiffy No. 3 (Release 8) on Chicken 3.1.2
Location: /data.scm
Content-length: 5
HTTP/1.1 302 Found
Server: spiffy No. 3 (Release 8) on Chicken 3.1.2
Location: /data.scm
Content-length: 5
HTTP/1.1 302 Found
Server: spiffy No. 3 (Release 8) on Chicken 3.1.2
Location: /data.scm
Content-length: 5
HTTP/1.1 302 Found
Server: spiffy No. 3 (Release 8) on Chicken 3.1.2
Location: /data.scm
Content-length: 5
HTTP/1.1 302 Found
Server: spiffy No. 3 (Release 8) on Chicken 3.1.2
Location: /data.scm
Content-length: 5
HTTP/1.1 302 Found
Server: spiffy No. 3 (Release 8) on Chicken 3.1.2
Location: /data.scm
Content-length: 5
HTTP/1.1 302 Found
Server: spiffy No. 3 (Release 8) on Chicken 3.1.2
Location: /data.scm
Content-length: 5
HTTP/1.1 302 Found
Server: spiffy No. 3 (Release 8) on Chicken 3.1.2
Location: /data.scm
Content-length: 5
HTTP/1.1 302 Found
Server: spiffy No. 3 (Release 8) on Chicken 3.1.2
Location: /data.scm
Content-length: 5
HTTP/1.1 302 Found
Server: spiffy No. 3 (Release 8) on Chicken 3.1.2
Location: /data.scm
Content-length: 5
HTTP/1.1 302 Found
Server: spiffy No. 3 (Release 8) on Chicken 3.1.2
Location: /data.scm
Content-length: 5
HTTP/1.1 302 Found
Server: spiffy No. 3 (Release 8) on Chicken 3.1.2
Location: /data.scm
Content-length: 5
HTTP/1.1 302 Found
Server: spiffy No. 3 (Release 8) on Chicken 3.1.2
Location: /data.scm
Content-length: 5
HTTP/1.1 302 Found
Server: spiffy No. 3 (Release 8) on Chicken 3.1.2
Location: /data.scm
Content-length: 5
curl: (47) Maximum (50) redirects followed
$ curl -L -D - 'http://chain.teddyb.org:7623/redir2.scm'
HTTP/1.1 302 Found
Server: spiffy No. 3 (Release 8) on Chicken 3.1.2
Location: /data.scm
Content-length: 0
HTTP/1.1 302 Found
Server: spiffy No. 3 (Release 8) on Chicken 3.1.2
Content-length: 5
data
_______________________________________________
Chicken-users mailing list
[email protected]
http://lists.nongnu.org/mailman/listinfo/chicken-users