Wapp

Check-in [44f07d8804]
Login

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

Overview
Comment:Fix to [80f25418a1c32b8d] so that it works as CGI again. Also omit a parameter to wappInt-handle-request that is no longer used.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 44f07d88044facb064644c692f1a2beb8acf8a30008f931126045dc77ac67ec6
User & Date: drh 2019-07-31 14:30:10
Context
2019-08-01
16:46
Load all environment variables that start with an upper-case ASCII letter as wapp-param values in CGI mode, rather than only loading selected variables. check-in: 68331516e9 user: drh tags: trunk
2019-07-31
14:30
Fix to [80f25418a1c32b8d] so that it works as CGI again. Also omit a parameter to wappInt-handle-request that is no longer used. check-in: 44f07d8804 user: drh tags: trunk
14:24
If the $argv0 variable is not set, use "/" for SCRIPT_FILENAME and DOCUMENT_ROOT. Ticket [1d0112d75bfbffc8]. check-in: d52654e48f user: drh tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to wapp.tcl.

   493    493         }
   494    494         if {$len>0} {
   495    495           # Still need to read the query content
   496    496           dict set W .toread $len
   497    497         } else {
   498    498           # There is no query content, so handle the request immediately
   499    499           set wapp $W
   500         -        wappInt-handle-request $chan 0
          500  +        wappInt-handle-request $chan
   501    501         }
   502    502       }
   503    503     } else {
   504    504       # If .toread is set, that means we are reading the query content.
   505    505       # Continue reading until .toread reaches zero.
   506    506       set got [read $chan [dict get $W .toread]]
   507    507       dict append W CONTENT $got
   508    508       dict set W .toread [expr {[dict get $W .toread]-[string length $got]}]
   509    509       if {[dict get $W .toread]<=0} {
   510    510         # Handle the request as soon as all the query content is received
   511    511         set wapp $W
   512         -      wappInt-handle-request $chan 0
          512  +      wappInt-handle-request $chan
   513    513       }
   514    514     }
   515    515   }
   516    516   
   517    517   # Decode the HTTP request header.
   518    518   #
   519    519   # This routine is always running inside of a [catch], so if
................................................................................
   622    622   # instance finishes.  Yes, this means that WAPP IS SINGLE THREADED.  Only
   623    623   # a single page rendering instance my be running at a time.  There can
   624    624   # be multiple HTTP requests inbound at once, but only one my be processed
   625    625   # at a time once the request is full read and parsed.
   626    626   #
   627    627   set wappIntPending {}
   628    628   set wappIntLock 0
   629         -proc wappInt-handle-request {chan useCgi} {
          629  +proc wappInt-handle-request {chan} {
   630    630     global wappIntPending wappIntLock
   631    631     fileevent $chan readable {}
   632    632     if {$wappIntLock} {
   633    633       # Another instance of request is already running, so defer this one
   634         -    lappend wappIntPending [list wappInt-handle-request $chan $useCgi]
          634  +    lappend wappIntPending [list wappInt-handle-request $chan]
   635    635       return
   636    636     }
   637    637     set wappIntLock 1
   638         -  catch [list wappInt-handle-request-unsafe $chan $useCgi]
          638  +  catch [list wappInt-handle-request-unsafe $chan]
   639    639     set wappIntLock 0
   640    640     if {[llength $wappIntPending]>0} {
   641    641       # If there are deferred requests, then launch the oldest one
   642    642       after idle [lindex $wappIntPending 0]
   643    643       set wappIntPending [lrange $wappIntPending 1 end]
   644    644     }
   645    645   }
   646         -proc wappInt-handle-request-unsafe {chan useCgi} {
          646  +proc wappInt-handle-request-unsafe {chan} {
   647    647     global wapp
   648    648     dict set wapp .reply {}
   649    649     dict set wapp .mimetype {text/html; charset=utf-8}
   650    650     dict set wapp .reply-code {200 Ok}
   651    651     dict set wapp .csp {default-src 'self'}
   652    652   
   653    653     # Set up additional CGI environment values
................................................................................
   831    831     }
   832    832     if {$len>0} {
   833    833       fconfigure stdin -translation binary
   834    834       dict set wapp CONTENT [read stdin $len]
   835    835     }
   836    836     dict set wapp WAPP_MODE cgi
   837    837     fconfigure stdout -translation binary
   838         -  wappInt-handle-request stdout 1
          838  +  wappInt-handle-request-unsafe stdout
   839    839   }
   840    840   
   841    841   # Process new text received on an inbound SCGI request
   842    842   #
   843    843   proc wappInt-scgi-readable {chan} {
   844    844     if {[catch [list wappInt-scgi-readable-unsafe $chan] msg]} {
   845    845       puts stderr "$msg\n$::errorInfo"
................................................................................
   872    872       if {$len>0} {
   873    873         # Still need to read the query content
   874    874         dict set W .toread $len
   875    875       } else {
   876    876         # There is no query content, so handle the request immediately
   877    877         dict set W SERVER_ADDR [dict get $W .remove_addr]
   878    878         set wapp $W
   879         -      wappInt-handle-request $chan 0
          879  +      wappInt-handle-request $chan
   880    880       }
   881    881     } else {
   882    882       # If .toread is set, that means we are reading the query content.
   883    883       # Continue reading until .toread reaches zero.
   884    884       set got [read $chan [dict get $W .toread]]
   885    885       dict append W CONTENT $got
   886    886       dict set W .toread [expr {[dict get $W .toread]-[string length $got]}]
   887    887       if {[dict get $W .toread]<=0} {
   888    888         # Handle the request as soon as all the query content is received
   889    889         dict set W SERVER_ADDR [dict get $W .remove_addr]
   890    890         set wapp $W
   891         -      wappInt-handle-request $chan 0
          891  +      wappInt-handle-request $chan
   892    892       }
   893    893     }
   894    894   }
   895    895   
   896    896   # Start up the wapp framework.  Parameters are a list passed as the
   897    897   # single argument.
   898    898   #