Re: [tclwebtest] Problems with void redirection
Status: Abandoned
Brought to you by:
tils
From: Grzegorz A. H. <gr...@ef...> - 2003-02-11 17:41:20
|
On Thu, Jan 30, 2003 at 05:51:24PM +0100, Grzegorz Adam Hankiewicz wrote: > How should I deal with this? I presume this blank redirection > AOLServer sends means that the browser should return to the > original url before the redirections started, but looks a very > awkward behaviour. Maybe this would require a "history" variable > in tclwebtest? Looks like it doesn't. Again, here's a script which fails due to null redirection: > do_request http://www.efaber.net/prensa > link follow {English} And here's the output > ----- START: ../cusfalla1.txt at [11/feb/2003:18:33:10] ----- > --- do_request for http://www.efaber.net/prensa > http status: >>200<< > --- do_request for http://www.efaber.net/language-prefs.tcl?language_preference=en > http status: >>302<< > following a redirect to: http://www.efaber.net/cookie-chain.tcl?cookie_name=language_preference&cookie_value=en&final_page=&expire_state=p > --- do_request for http://www.efaber.net/cookie-chain.tcl?cookie_name=language_preference&cookie_value=en&final_page=&expire_state=p > http status: >>302<< > following a redirect to: > > No value specified for argument url > while executing > "do_request__arg_parser" > blah blah blah I tested the same page with elinks simulating tclwebtest after desactivating elinks' referer http feature: > CONNECTION: www.efaber.net > GET /prensa HTTP/1.1 > HTTP/1.0 200 OK > > GET /language-prefs.tcl?language_preference=es HTTP/1.1 > HTTP/1.0 302 Found > Location: http://www.efaber.net/cookie-chain.tcl?cookie_name=language_preference&cookie_value=es&final_page=&expire_state=p > > GET /cookie-chain.tcl?cookie_name=language_preference&cookie_value=es&final_page=&expire_state=p HTTP/1.1 > HTTP/1.0 302 Found > Set-Cookie: language_preference=es; path=/; expires=Fri, 01-Jan-2010 01:00:00 GMT > Location: > > GET / HTTP/1.1 > Cookie: language_preference=es > HTTP/1.0 200 OK Which could mean that after a null redirection the browser has to get the root directory. However, I tested this also against another page doing this trick: > do_request http://borja.casa-sotomayor.net/ > link follow {text-only} Output: > ----- START: ../cusfalla2.txt at [11/feb/2003:18:36:17] ----- > --- do_request for http://borja.casa-sotomayor.net/ > http status: >>200<< > Enlaces modo gráfico 63 > --- do_request for http://borja.casa-sotomayor.net/methods/setMode?mode=text > http status: >>302<< > following a redirect to: > > No value specified for argument url > while executing > "do_request__arg_parser" > blah blah Surprisingly this is elink's behaviour: > CONNECTION: borja.casa-sotomayor.net > GET / HTTP/1.1 > ... > HTTP/1.1 200 OK > > GET /methods/setMode?mode=text HTTP/1.1 > HTTP/1.1 302 Moved Temporarily > Location: > Set-Cookie: BORJANET_MODE="text"; Path=/ > > GET /methods/ HTTP/1.1 > Cookie: BORJANET_MODE="text" > HTTP/1.1 302 Moved Temporarily > Location: / This means that whenever a null location is sent to the browser with a 302 redirection, the browser then requests the same path without file component. Hence, this patch makes all the above tested web pages work, because after all the redirections the cookie has been set and all is ok: Index: lib/tclwebtest.tcl =================================================================== RCS file: /cvsroot/tclwebtest/tclwebtest/lib/tclwebtest.tcl,v retrieving revision 1.17 diff -u -r1.17 tclwebtest.tcl --- lib/tclwebtest.tcl 10 Feb 2003 09:26:46 -0000 1.17 +++ lib/tclwebtest.tcl 11 Feb 2003 17:23:40 -0000 @@ -1797,9 +1797,13 @@ if { $http_status == "302" || $http_status == "301" } { for { set i 0 } { $i < [llength $meta] } { incr i 2 } { if { [string match -nocase [lindex $meta $i] "location"] } { - set location [lindex $meta [expr $i+1]] + set location [string trim [lindex $meta [expr $i+1]]] break } + } + if { $location == "" } { + # when location is null after redirection, get relative directory + set location "./" } if { $http_status == "301" } { if $nocomplain_p { Patch commited, because it fixes the infinite loop problem I was facing. Improved output example (which replicates elinks behaviour): ----- START: ../cusfalla2.txt at [11/feb/2003:18:42:00] ----- --- do_request for http://borja.casa-sotomayor.net/ http status: >>200<< --- do_request for http://borja.casa-sotomayor.net/methods/setMode?mode=text http status: >>302<< following a redirect to: ./ --- do_request for http://borja.casa-sotomayor.net/methods/./ http status: >>302<< following a redirect to: / --- do_request for http://borja.casa-sotomayor.net/ http status: >>200<< ----- SUCCESS: ../cusfalla2.txt (took 15s) ----- PD: While this is good and nice for me (because these webs start to work), it would be nice if you could check some "official" page describing the correct browser behaviour in such cases. Unluckily I didn't google anything useful. -- Grzegorz Adam Hankiewicz, gr...@ef.... Tel: +34-94-472 35 89. eFaber SL, Maria Diaz de Haro, 68, 2 http://www.efaber.net/ 48920 Portugalete, Bizkaia (SPAIN) |