Tcl Source Code

Hex Artifact Content
Login

Artifact cea8074a358af876d69cb0ac56346ece24e46702:

Attachment "httpd11.patch" to ticket [2762041fff] added by ferrieux 2010-02-12 07:02:53.
0000: 49 6e 64 65 78 3a 20 68 74 74 70 64 31 31 2e 74  Index: httpd11.t
0010: 63 6c 0a 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  cl.=============
0020: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
0030: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
0040: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
0050: 3d 3d 3d 3d 3d 3d 0a 52 43 53 20 66 69 6c 65 3a  ======.RCS file:
0060: 20 2f 63 76 73 72 6f 6f 74 2f 74 63 6c 2f 74 63   /cvsroot/tcl/tc
0070: 6c 2f 74 65 73 74 73 2f 68 74 74 70 64 31 31 2e  l/tests/httpd11.
0080: 74 63 6c 2c 76 0a 72 65 74 72 69 65 76 69 6e 67  tcl,v.retrieving
0090: 20 72 65 76 69 73 69 6f 6e 20 31 2e 32 0a 64 69   revision 1.2.di
00a0: 66 66 20 2d 75 20 2d 70 20 2d 72 31 2e 32 20 68  ff -u -p -r1.2 h
00b0: 74 74 70 64 31 31 2e 74 63 6c 0a 2d 2d 2d 20 68  ttpd11.tcl.--- h
00c0: 74 74 70 64 31 31 2e 74 63 6c 09 31 39 20 41 70  ttpd11.tcl.19 Ap
00d0: 72 20 32 30 30 39 20 31 38 3a 32 37 3a 35 39 20  r 2009 18:27:59 
00e0: 2d 30 30 30 30 09 31 2e 32 0a 2b 2b 2b 20 68 74  -0000.1.2.+++ ht
00f0: 74 70 64 31 31 2e 74 63 6c 09 31 32 20 46 65 62  tpd11.tcl.12 Feb
0100: 20 32 30 31 30 20 30 30 3a 30 31 3a 32 35 20 2d   2010 00:01:25 -
0110: 30 30 30 30 0a 40 40 20 2d 38 35 2c 31 35 20 2b  0000.@@ -85,15 +
0120: 38 35 2c 31 35 20 40 40 20 70 72 6f 63 20 6d 69  85,15 @@ proc mi
0130: 6d 65 2d 74 79 70 65 20 7b 66 69 6c 65 6e 61 6d  me-type {filenam
0140: 65 7d 20 7b 0a 20 70 72 6f 63 20 50 75 74 73 20  e} {. proc Puts 
0150: 7b 63 68 61 6e 20 73 7d 20 7b 70 75 74 73 20 24  {chan s} {puts $
0160: 63 68 61 6e 20 24 73 3b 20 70 75 74 73 20 24 73  chan $s; puts $s
0170: 7d 0a 20 0a 20 70 72 6f 63 20 53 65 72 76 69 63  }. . proc Servic
0180: 65 20 7b 63 68 61 6e 20 61 64 64 72 20 70 6f 72  e {chan addr por
0190: 74 7d 20 7b 0a 2d 20 20 20 20 63 68 61 6e 20 65  t} {.-    chan e
01a0: 76 65 6e 74 20 24 63 68 61 6e 20 72 65 61 64 61  vent $chan reada
01b0: 62 6c 65 20 5b 69 6e 66 6f 20 63 6f 72 6f 75 74  ble [info corout
01c0: 69 6e 65 5d 0a 2b 23 20 20 20 20 63 68 61 6e 20  ine].+#    chan 
01d0: 65 76 65 6e 74 20 24 63 68 61 6e 20 72 65 61 64  event $chan read
01e0: 61 62 6c 65 20 5b 69 6e 66 6f 20 63 6f 72 6f 75  able [info corou
01f0: 74 69 6e 65 5d 0a 20 20 20 20 20 77 68 69 6c 65  tine].     while
0200: 20 7b 31 7d 20 7b 0a 20 20 20 20 20 20 20 20 20   {1} {.         
0210: 73 65 74 20 6d 65 74 61 20 7b 7d 0a 20 20 20 20  set meta {}.    
0220: 20 20 20 20 20 63 68 61 6e 20 63 6f 6e 66 69 67       chan config
0230: 75 72 65 20 24 63 68 61 6e 20 2d 62 75 66 66 65  ure $chan -buffe
0240: 72 69 6e 67 20 6c 69 6e 65 20 2d 65 6e 63 6f 64  ring line -encod
0250: 69 6e 67 20 69 73 6f 38 38 35 39 2d 31 20 2d 74  ing iso8859-1 -t
0260: 72 61 6e 73 6c 61 74 69 6f 6e 20 63 72 6c 66 0a  ranslation crlf.
0270: 2d 20 20 20 20 20 20 20 20 63 68 61 6e 20 63 6f  -        chan co
0280: 6e 66 69 67 75 72 65 20 24 63 68 61 6e 20 2d 62  nfigure $chan -b
0290: 6c 6f 63 6b 69 6e 67 20 30 0a 2d 20 20 20 20 20  locking 0.-     
02a0: 20 20 20 79 69 65 6c 64 0a 2b 20 20 20 20 20 20     yield.+      
02b0: 20 20 63 68 61 6e 20 63 6f 6e 66 69 67 75 72 65    chan configure
02c0: 20 24 63 68 61 6e 20 2d 62 6c 6f 63 6b 69 6e 67   $chan -blocking
02d0: 20 31 0a 2b 20 23 20 20 20 20 20 20 20 79 69 65   1.+ #       yie
02e0: 6c 64 0a 20 20 20 20 20 20 20 20 20 77 68 69 6c  ld.         whil
02f0: 65 20 7b 5b 67 65 74 73 20 24 63 68 61 6e 20 6c  e {[gets $chan l
0300: 69 6e 65 5d 20 3c 20 30 7d 20 7b 0a 20 20 20 20  ine] < 0} {.    
0310: 20 20 20 20 20 20 20 20 20 69 66 20 7b 5b 65 6f           if {[eo
0320: 66 20 24 63 68 61 6e 5d 7d 20 7b 63 68 61 6e 20  f $chan]} {chan 
0330: 65 76 65 6e 74 20 24 63 68 61 6e 20 72 65 61 64  event $chan read
0340: 61 62 6c 65 20 7b 7d 3b 20 63 6c 6f 73 65 20 24  able {}; close $
0350: 63 68 61 6e 3b 20 72 65 74 75 72 6e 7d 0a 2d 20  chan; return}.- 
0360: 20 20 20 20 20 20 20 20 20 20 20 79 69 65 6c 64             yield
0370: 0a 2b 20 20 23 20 20 20 20 20 20 20 20 20 20 79  .+  #          y
0380: 69 65 6c 64 0a 20 20 20 20 20 20 20 20 20 7d 0a  ield.         }.
0390: 20 20 20 20 20 20 20 20 20 69 66 20 7b 5b 65 6f           if {[eo
03a0: 66 20 24 63 68 61 6e 5d 7d 20 7b 63 68 61 6e 20  f $chan]} {chan 
03b0: 65 76 65 6e 74 20 24 63 68 61 6e 20 72 65 61 64  event $chan read
03c0: 61 62 6c 65 20 7b 7d 3b 20 63 6c 6f 73 65 20 24  able {}; close $
03d0: 63 68 61 6e 3b 20 72 65 74 75 72 6e 7d 0a 20 20  chan; return}.  
03e0: 20 20 20 20 20 20 20 66 6f 72 65 61 63 68 20 7b         foreach {
03f0: 72 65 71 20 75 72 6c 20 70 72 6f 74 6f 63 6f 6c  req url protocol
0400: 7d 20 7b 47 45 54 20 7b 7d 20 48 54 54 50 2f 31  } {GET {} HTTP/1
0410: 2e 31 7d 20 62 72 65 61 6b 0a 40 40 20 2d 31 30  .1} break.@@ -10
0420: 35 2c 37 20 2b 31 30 35 2c 37 20 40 40 20 70 72  5,7 +105,7 @@ pr
0430: 6f 63 20 53 65 72 76 69 63 65 20 7b 63 68 61 6e  oc Service {chan
0440: 20 61 64 64 72 20 70 6f 72 74 7d 20 7b 0a 20 20   addr port} {.  
0450: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 70                 p
0460: 75 74 73 20 5b 6c 69 73 74 20 24 6b 65 79 20 5b  uts [list $key [
0470: 73 74 72 69 6e 67 20 74 72 69 6d 20 24 76 61 6c  string trim $val
0480: 5d 5d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20  ]].             
0490: 20 20 20 20 6c 61 70 70 65 6e 64 20 6d 65 74 61      lappend meta
04a0: 20 5b 73 74 72 69 6e 67 20 74 6f 6c 6f 77 65 72   [string tolower
04b0: 20 24 6b 65 79 5d 20 5b 73 74 72 69 6e 67 20 74   $key] [string t
04c0: 72 69 6d 20 24 76 61 6c 5d 0a 20 20 20 20 20 20  rim $val].      
04d0: 20 20 20 20 20 20 20 7d 0a 2d 20 20 20 20 20 20         }.-      
04e0: 20 20 20 20 20 20 79 69 65 6c 64 0a 2b 20 20 20        yield.+   
04f0: 20 23 20 20 20 20 20 20 20 20 79 69 65 6c 64 0a   #        yield.
0500: 20 20 20 20 20 20 20 20 20 7d 0a 20 0a 20 20 20           }. .   
0510: 20 20 20 20 20 20 73 65 74 20 65 6e 63 6f 64 69        set encodi
0520: 6e 67 20 69 64 65 6e 74 69 74 79 0a 40 40 20 2d  ng identity.@@ -
0530: 31 33 34 2c 36 20 2b 31 33 34 2c 37 20 40 40 20  134,6 +134,7 @@ 
0540: 70 72 6f 63 20 53 65 72 76 69 63 65 20 7b 63 68  proc Service {ch
0550: 61 6e 20 61 64 64 72 20 70 6f 72 74 7d 20 7b 0a  an addr port} {.
0560: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
0570: 20 20 20 20 20 7d 0a 20 20 20 20 20 20 20 20 20       }.         
0580: 20 20 20 20 20 20 20 20 20 20 20 20 23 20 43 68              # Ch
0590: 65 63 6b 20 66 6f 72 20 65 78 63 65 73 73 20 71  eck for excess q
05a0: 75 65 72 79 20 62 79 74 65 73 20 5b 42 75 67 20  uery bytes [Bug 
05b0: 32 37 31 35 34 32 31 5d 0a 20 20 20 20 20 20 20  2715421].       
05c0: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 69 66                if
05d0: 20 7b 5b 64 69 63 74 20 67 65 74 3f 20 24 6d 65   {[dict get? $me
05e0: 74 61 20 78 2d 63 68 65 63 6b 2d 71 75 65 72 79  ta x-check-query
05f0: 5d 20 65 71 20 22 79 65 73 22 7d 20 7b 0a 2b 09  ] eq "yes"} {.+.
0600: 09 09 65 72 72 6f 72 20 41 52 47 47 48 0a 20 20  ..error ARGGH.  
0610: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
0620: 20 20 20 20 20 20 20 63 68 61 6e 20 63 6f 6e 66         chan conf
0630: 69 67 75 72 65 20 24 63 68 61 6e 20 2d 62 6c 6f  igure $chan -blo
0640: 63 6b 69 6e 67 20 30 0a 20 20 20 20 20 20 20 20  cking 0.        
0650: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
0660: 20 61 70 70 65 6e 64 20 71 75 65 72 79 20 5b 72   append query [r
0670: 65 61 64 20 24 63 68 61 6e 5d 0a 20 20 20 20 20  ead $chan].     
0680: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
0690: 7d 0a 40 40 20 2d 32 30 34 2c 31 33 20 2b 32 30  }.@@ -204,13 +20
06a0: 35 2c 32 30 20 40 40 20 70 72 6f 63 20 53 65 72  5,20 @@ proc Ser
06b0: 76 69 63 65 20 7b 63 68 61 6e 20 61 64 64 72 20  vice {chan addr 
06c0: 70 6f 72 74 7d 20 7b 0a 20 20 20 20 20 20 20 20  port} {.        
06d0: 20 69 66 20 7b 24 74 72 61 6e 73 66 65 72 20 65   if {$transfer e
06e0: 71 20 22 63 68 75 6e 6b 65 64 22 7d 20 7b 0a 20  q "chunked"} {. 
06f0: 20 20 20 20 20 20 20 20 20 20 20 20 62 6c 6f 77              blow
0700: 2d 63 68 75 6e 6b 73 20 24 64 61 74 61 20 24 63  -chunks $data $c
0710: 68 61 6e 20 24 65 6e 63 6f 64 69 6e 67 0a 20 20  han $encoding.  
0720: 20 20 20 20 20 20 20 7d 20 65 6c 73 65 69 66 20         } elseif 
0730: 7b 24 65 6e 63 6f 64 69 6e 67 20 6e 65 20 22 69  {$encoding ne "i
0740: 64 65 6e 74 69 74 79 22 7d 20 7b 0a 2d 20 20 20  dentity"} {.-   
0750: 20 20 20 20 20 20 20 20 20 70 75 74 73 20 2d 6e           puts -n
0760: 6f 6e 65 77 6c 69 6e 65 20 24 63 68 61 6e 20 5b  onewline $chan [
0770: 7a 6c 69 62 20 24 65 6e 63 6f 64 69 6e 67 20 24  zlib $encoding $
0780: 64 61 74 61 5d 0a 2b 09 20 20 20 20 73 65 74 20  data].+.    set 
0790: 7a 20 5b 7a 6c 69 62 20 24 65 6e 63 6f 64 69 6e  z [zlib $encodin
07a0: 67 20 24 64 61 74 61 5d 0a 2b 20 20 20 20 20 20  g $data].+      
07b0: 20 20 20 20 20 20 70 75 74 73 20 2d 6e 6f 6e 65        puts -none
07c0: 77 6c 69 6e 65 20 24 63 68 61 6e 20 24 7a 0a 2b  wline $chan $z.+
07d0: 09 20 20 20 20 23 70 75 74 73 20 22 75 6c 65 6e  .    #puts "ulen
07e0: 3a 5b 73 74 72 69 6e 67 20 6c 65 6e 67 74 68 20  :[string length 
07f0: 24 64 61 74 61 5d 22 0a 2b 09 20 20 20 20 23 70  $data]".+.    #p
0800: 75 74 73 20 22 7a 6c 65 6e 3a 5b 73 74 72 69 6e  uts "zlen:[strin
0810: 67 20 6c 65 6e 67 74 68 20 24 7a 5d 22 0a 20 20  g length $z]".  
0820: 20 20 20 20 20 20 20 7d 20 65 6c 73 65 20 7b 0a         } else {.
0830: 20 20 20 20 20 20 20 20 20 20 20 20 20 70 75 74               put
0840: 73 20 2d 6e 6f 6e 65 77 6c 69 6e 65 20 24 63 68  s -nonewline $ch
0850: 61 6e 20 24 64 61 74 61 0a 20 20 20 20 20 20 20  an $data.       
0860: 20 20 7d 0a 20 20 20 20 20 20 20 20 20 0a 20 20    }.         .  
0870: 20 20 20 20 20 20 20 69 66 20 7b 24 63 6c 6f 73         if {$clos
0880: 65 7d 20 7b 0a 2d 20 20 20 20 20 20 20 20 20 20  e} {.-          
0890: 20 20 63 68 61 6e 20 65 76 65 6e 74 20 24 63 68    chan event $ch
08a0: 61 6e 20 72 65 61 64 61 62 6c 65 20 7b 7d 0a 2b  an readable {}.+
08b0: 20 20 20 20 20 20 20 20 20 20 20 20 23 63 68 61              #cha
08c0: 6e 20 65 76 65 6e 74 20 24 63 68 61 6e 20 72 65  n event $chan re
08d0: 61 64 61 62 6c 65 20 7b 7d 0a 2b 23 61 6c 65 78  adable {}.+#alex
08e0: 0a 2b 09 20 20 20 20 66 63 6f 6e 66 69 67 75 72  .+.    fconfigur
08f0: 65 20 24 63 68 61 6e 20 2d 62 6c 6f 63 6b 69 6e  e $chan -blockin
0900: 67 20 31 0a 2b 20 20 20 20 20 20 20 20 20 20 20  g 1.+           
0910: 20 23 70 75 74 73 20 22 66 6c 75 73 68 20 24 63   #puts "flush $c
0920: 68 61 6e 22 0a 2b 09 20 20 20 20 66 6c 75 73 68  han".+.    flush
0930: 20 24 63 68 61 6e 0a 20 20 20 20 20 20 20 20 20   $chan.         
0940: 20 20 20 20 63 6c 6f 73 65 20 24 63 68 61 6e 0a      close $chan.
0950: 20 20 20 20 20 20 20 20 20 20 20 20 20 70 75 74               put
0960: 73 20 22 63 6c 6f 73 65 20 24 63 68 61 6e 22 0a  s "close $chan".
0970: 20 20 20 20 20 20 20 20 20 20 20 20 20 72 65 74               ret
0980: 75 72 6e 0a 40 40 20 2d 32 32 32 2c 37 20 2b 32  urn.@@ -222,7 +2
0990: 33 30 2c 38 20 40 40 20 70 72 6f 63 20 53 65 72  30,8 @@ proc Ser
09a0: 76 69 63 65 20 7b 63 68 61 6e 20 61 64 64 72 20  vice {chan addr 
09b0: 70 6f 72 74 7d 20 7b 0a 20 7d 0a 20 0a 20 70 72  port} {. }. . pr
09c0: 6f 63 20 41 63 63 65 70 74 20 7b 63 68 61 6e 20  oc Accept {chan 
09d0: 61 64 64 72 20 70 6f 72 74 7d 20 7b 0a 2d 20 20  addr port} {.-  
09e0: 20 20 63 6f 72 6f 75 74 69 6e 65 20 63 6c 69 65    coroutine clie
09f0: 6e 74 24 63 68 61 6e 20 53 65 72 76 69 63 65 20  nt$chan Service 
0a00: 24 63 68 61 6e 20 24 61 64 64 72 20 24 70 6f 72  $chan $addr $por
0a10: 74 0a 2b 23 61 6c 65 78 20 20 20 20 63 6f 72 6f  t.+#alex    coro
0a20: 75 74 69 6e 65 20 63 6c 69 65 6e 74 24 63 68 61  utine client$cha
0a30: 6e 20 53 65 72 76 69 63 65 20 24 63 68 61 6e 20  n Service $chan 
0a40: 24 61 64 64 72 20 24 70 6f 72 74 0a 2b 20 20 20  $addr $port.+   
0a50: 20 53 65 72 76 69 63 65 20 24 63 68 61 6e 20 24   Service $chan $
0a60: 61 64 64 72 20 24 70 6f 72 74 0a 20 20 20 20 20  addr $port.     
0a70: 72 65 74 75 72 6e 0a 20 7d 0a 20 0a              return. }. .