Tcl Library Source Code

Check-in [c14446b881]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Httpd module: Removed a puts statement injected during debugging. Fixing a typo in logging
Timelines: family | ancestors | descendants | both | hypnotoad
Files: files | file ages | folders
SHA3-256:c14446b8814ad28a3b77a57fad115e9686930881a306480c359ff532669364bf
User & Date: hypnotoad 2018-09-11 17:18:46
Context
2018-09-11
18:19
Mime: Fixed a wrong version number on the package httpd: The example now uses the uri::direct method where appropriate. Fixed some typos and bugs in the uri::direct method. Fixed places in the code where error pages were asking for the html::header and html::footer methods. They haven't existed for a while. check-in: 05366363a0 user: hypnotoad tags: hypnotoad
17:18
Httpd module: Removed a puts statement injected during debugging. Fixing a typo in logging check-in: c14446b881 user: hypnotoad tags: hypnotoad
17:13
Modifications to the httpd module: httpd::reply object in order to simplify the code inside of httpd::server and give developers more rope to hang themselves. The httpd::reply method now uses one general purpose dispatch public method, with all of the application specific wulu magic now confined to a new private method Dispatch Folded the functions of the former reply::dispatch method into the new public dispatch method, and eliminated reply::dispatch. Replaced http::reply.scgi with a mixin that swaps that one function that is different between them. httpd::server no longer looks for an alternate reply class. It is now assumed that every reply will be httpd::reply, and that the dispatch method will be able to sort out what behaviors get mixed in. Simplified the implementation of ::httpd::plugin.dict_dispatch Added a new method to the Uri ensemble: uri::direct which automates the process of producing simple dynamic content cases. Formalized the arguments for uri::add Moved the headers parsing out of the body of Connect and into a dedicated method ServerHeaders. Added a call to Dispatch_Local to the default dispatch method. check-in: 7b4c25cd6e user: hypnotoad tags: hypnotoad
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to modules/httpd/build/reply.tcl.

51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
  method Log_Dispatched {} {
    my log Dispatched [dict create \
     REMOTE_ADDR [my request get REMOTE_ADDR] \
     REMOTE_HOST [my request get REMOTE_HOST] \
     COOKIE [my request get HTTP_COOKIE] \
     REFERER [my request get HTTP_REFERER] \
     USER_AGENT [my request get HTTP_USER_AGENT] \
     REQUEST_URI [my request get HTTP_REQUEST_URI] \
     HTTP_HOST [my request get HTTP_HOST] \
     SESSION [my request get SESSION] \
    ]
  }

  method dispatch {newsock datastate} {
    my variable chan request







|







51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
  method Log_Dispatched {} {
    my log Dispatched [dict create \
     REMOTE_ADDR [my request get REMOTE_ADDR] \
     REMOTE_HOST [my request get REMOTE_HOST] \
     COOKIE [my request get HTTP_COOKIE] \
     REFERER [my request get HTTP_REFERER] \
     USER_AGENT [my request get HTTP_USER_AGENT] \
     REQUEST_URI [my request get REQUEST_URI] \
     HTTP_HOST [my request get HTTP_HOST] \
     SESSION [my request get SESSION] \
    ]
  }

  method dispatch {newsock datastate} {
    my variable chan request

Changes to modules/httpd/httpd.tcl.

333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
...
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
  method Log_Dispatched {} {
    my log Dispatched [dict create \
     REMOTE_ADDR [my request get REMOTE_ADDR] \
     REMOTE_HOST [my request get REMOTE_HOST] \
     COOKIE [my request get HTTP_COOKIE] \
     REFERER [my request get HTTP_REFERER] \
     USER_AGENT [my request get HTTP_USER_AGENT] \
     REQUEST_URI [my request get HTTP_REQUEST_URI] \
     HTTP_HOST [my request get HTTP_HOST] \
     SESSION [my request get SESSION] \
    ]
  }

  method dispatch {newsock datastate} {
    my variable chan request
................................................................................
      dict set query UUID $uuid
      dict set query mimetxt $mimetxt
      dict set query mixin style [my clay get server/ style]
      dict set query http [my ServerHeaders $ip $http_request $mimetxt]
      my Headers_Process query
      set reply [my dispatch $query]
    } on error {err errdat} {
      puts [dict get $errdat -errorinfo]
      my debug [list uri: [dict getnull $query REQUEST_URI] ip: $ip error: $err errorinfo: [dict get $errdat -errorinfo]]
      my log BadRequest $uuid [list ip: $ip error: $err errorinfo: [dict get $errdat -errorinfo]]
      catch {chan puts $sock "HTTP/1.0 400 Bad Request (The data is invalid)"}
      catch {chan close $sock}
      return
    }
    if {[dict size $reply]==0} {







|







 







<







333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
...
859
860
861
862
863
864
865

866
867
868
869
870
871
872
  method Log_Dispatched {} {
    my log Dispatched [dict create \
     REMOTE_ADDR [my request get REMOTE_ADDR] \
     REMOTE_HOST [my request get REMOTE_HOST] \
     COOKIE [my request get HTTP_COOKIE] \
     REFERER [my request get HTTP_REFERER] \
     USER_AGENT [my request get HTTP_USER_AGENT] \
     REQUEST_URI [my request get REQUEST_URI] \
     HTTP_HOST [my request get HTTP_HOST] \
     SESSION [my request get SESSION] \
    ]
  }

  method dispatch {newsock datastate} {
    my variable chan request
................................................................................
      dict set query UUID $uuid
      dict set query mimetxt $mimetxt
      dict set query mixin style [my clay get server/ style]
      dict set query http [my ServerHeaders $ip $http_request $mimetxt]
      my Headers_Process query
      set reply [my dispatch $query]
    } on error {err errdat} {

      my debug [list uri: [dict getnull $query REQUEST_URI] ip: $ip error: $err errorinfo: [dict get $errdat -errorinfo]]
      my log BadRequest $uuid [list ip: $ip error: $err errorinfo: [dict get $errdat -errorinfo]]
      catch {chan puts $sock "HTTP/1.0 400 Bad Request (The data is invalid)"}
      catch {chan close $sock}
      return
    }
    if {[dict size $reply]==0} {