[Gauche-devel-jp] rfc.httpのredirectionのハンドリング

Back to archive index

TAKAHASHI, Kohske kohsk****@msc*****
2004年 9月 4日 (土) 09:53:56 JST


たかはしです.

サーバがlocation pathに相対パスを返した時に,rfc.httpで"host"/"location path"
としているので大体404になると思います(相対パスと絶対パスが一致する時以外).

サーバが相対パスを返すのって,rfc違反なんですかね?

一応対応したものを乗せておきますが,たいしてテストもしていないのであまり
信用しないでおいてください.

PHANTOM:/cygdrive/x/www/scj/wiki$ diff -u -p -b x:/arc/Gauche-0.8.1/lib/rfc/http.scm http.scm 
--- x:/arc/Gauche-0.8.1/lib/rfc/http.scm	2003-07-05 12:29:11.000000000 +0900
+++ http.scm	2004-09-04 09:54:32.000000000 +0900
@@ -129,7 +129,15 @@
                      ((and (string-prefix? "3" code)
                            (assoc "location" headers))
                       => (lambda (loc)
-                           (let1 uri (canonical-uri (cadr loc) host)
+                           (let1 uri (canonical-uri
+                                      (let1 loc (cadr loc)
+                                        (if (#/^\// loc) loc
+                                            (string-join (list
+                                                          (let1 ru (#/^(.*)\/.*$/ request-uri)
+                                                            (if ru (ru 1)
+                                                                ""))
+                                                          loc) "/")))
+                                      host)
                              (when (or (member uri history)
                                        (> (length history) 20))
                                (errorf "redirection is looping via ~a" uri))
--

TAKAHASHI, kohske
kohsk****@msc*****




Gauche-devel-jp メーリングリストの案内
Back to archive index