Avoiding repetitive use of tidy

Grzegorz Adam Hankiewicz <[email protected]> Tue, 23 Sep 2003 17:23:49 +0200
Newsgroups gmane.comp.web.tclwebtest
Message-ID <[email protected]>
I've commited the following patch. It avoids running tidy multiple
times after following a few 30x redirections or an error. Maybe
this should be expanded for other cases as well?

Index: lib/tclwebtest.tcl
===================================================================
RCS file: /cvsroot/tclwebtest/tclwebtest/lib/tclwebtest.tcl,v
retrieving revision 1.49
diff -u -r1.49 tclwebtest.tcl
--- lib/tclwebtest.tcl  16 Sep 2003 11:01:03 -0000      1.49
+++ lib/tclwebtest.tcl  23 Sep 2003 15:04:57 -0000
@@ -2284,8 +2284,10 @@
             log \"Bad http answer ignored due to -nocomplain\"
         }"
 
+    set avoid_tidy_p 0
     # is it a redirect ?
     if { $http_status == "302" || $http_status == "301" } {
+        set avoid_tidy_p 1
         for { set i 0 } { $i < [llength $meta] } { incr i 2 } {
             if { [string match -nocase [lindex $meta $i] "location"] } {
                 set location [translate_entities [string trim [lindex $meta [expr $i+1]]]]
@@ -2369,12 +2371,15 @@
             eval $failure_treatement
         }
     } elseif { $http_status != "200" } {
+        set avoid_tidy_p 1
         eval $failure_treatement
     }
     
     [http_namespace]::cleanup $token
 
-    maybe_tidy
+    if { !$avoid_tidy_p } {
+        maybe_tidy
+    }
 
     return $final_url
 }

-- 
 Grzegorz Adam Hankiewicz, [email protected] Tel: +34-94-472 35 89.
 eFaber SL, Maria Diaz de Haro, 68, 2         http://www.efaber.net/
 48920 Portugalete, Bizkaia (SPAIN)


-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf