Thread: [tclwebtest] Problems with void redirection
Status: Abandoned
Brought to you by:
tils
From: Grzegorz A. H. <gr...@ef...> - 2003-01-30 16:54:18
|
Hi. I'm testing a script against our server, but redirection fails. In order to track down the problem (which I supposed involved cookie handling) I added a new parameter to do_request, so that it can be told to not follow the redirection, but return the new location url. Patch attached (no_redirection_patch.gz). Now, after applying that patch I tested this code: do_request http://www.efaber.net/ log [cookies all] log "Trying to change language now" set url [link get_url Euskaraz] set url [do_request -noredirect $url] log "We were pointed at '$url'" log [cookies all] set url [do_request -noredirect $url] log "We were pointed at '$url'" log [cookies all] set url [do_request -noredirect $url] log "We were pointed at '$url'" log [cookies all] log "Now trying to do all automatically" do_request http://www.efaber.net/ link follow {English} The script does a manual redirection displaying the cookies' values at each individual step. But then I discovered that it's not a cookie problem. Attached is the log of the script (no_redirection_problem_log.gz), it shows how the manual do_request do well, accepting the cookies and setting their values. The last automatic "link follow" command fails after the second redirection, because it tries to follow a void url. Just to verify that the http headers were correct (they send a void Location field), I also attach the results of telnetting manually to the server. It returns a manual redirection, also with a blank value (no_redirection_problem_http_logs.gz). 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? PD: It would be cool if link follow also understood the switches of do_request, but I understand this is a little difficult because it first calls link find. -- 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) |
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) |