Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | Adjust the REQUEST_URI query parameter such that it includes the QUERY_STRING if any. In other words, REQUEST_URI should be the second field of the first line of the original HTTP request. This is how Apache and Nginx both work. |
---|---|
Downloads: | Tarball | ZIP archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA3-256: |
3028f8c9eac095ee4d0f29b25cc9ba63 |
User & Date: | drh 2022-02-13 19:39:07.903 |
Context
2022-07-27
| ||
20:46 | Fix documentation for the wapp-param-list command. (check-in: d739a6767c user: drh tags: trunk) | |
2022-02-13
| ||
19:39 | Adjust the REQUEST_URI query parameter such that it includes the QUERY_STRING if any. In other words, REQUEST_URI should be the second field of the first line of the original HTTP request. This is how Apache and Nginx both work. (check-in: 3028f8c9ea user: drh tags: trunk) | |
2021-11-26
| ||
12:27 | Update the built-in SQLite to the latest 3.37.0 beta. (check-in: 66bdd66cee user: drh tags: trunk) | |
Changes
Changes to docs/params.md.
︙ | ︙ | |||
196 197 198 199 200 201 202 | + **REQUEST\_METHOD** "GET" or "HEAD" or "POST" + **REQUEST\_URI** The URL for the inbound request, without the initial "http://" or "https://" and without the HTTP\_HOST. This variable is the same as | | > > > | 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 | + **REQUEST\_METHOD** "GET" or "HEAD" or "POST" + **REQUEST\_URI** The URL for the inbound request, without the initial "http://" or "https://" and without the HTTP\_HOST. This variable is the same as the concatenation of $SCRIPT\_NAME and $PATH\_INFO if $QUERY\_STRING is blank, or $SCRIPT\NAME/$PATH\_INFO?$QUERY\_STRING if $QUERY\_STRING is non-empty. $REQUEST\_URI is the second field of the first line of the HTTP request. + **SCRIPT\_FILENAME** The full pathname on the server for the Wapp script. This parameter is usually undefined for SCGI. + **SCRIPT\_NAME** In CGI mode, this is the name of the CGI script in the URL. In other |
︙ | ︙ | |||
273 274 275 276 277 278 279 280 281 282 283 284 | + **PATH\_TAIL** → "extra/path" The first five elements of the example above, HTTP\_HOST through QUERY\_STRING, are standard CGI. The final four elements are Wapp extensions. The following is the same information show in a diagram: > http://example.com/cgi-bin/script/method/extra/path?q1=5 \_________/\_____________/\________________/ \__/ | | | | HTTP_HOST SCRIPT_NAME PATH_INFO `-- QUERY_STRING | > > > < < < < < < | 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 | + **PATH\_TAIL** → "extra/path" The first five elements of the example above, HTTP\_HOST through QUERY\_STRING, are standard CGI. The final four elements are Wapp extensions. The following is the same information show in a diagram: > REQUEST_URI __________________|_________________ / \ http://example.com/cgi-bin/script/method/extra/path?q1=5 \_________/\_____________/\________________/ \__/ | | | | HTTP_HOST SCRIPT_NAME PATH_INFO `-- QUERY_STRING > http://example.com/cgi-bin/script/method/extra/path?q1=5 \_______________________________/ \____/ \________/ | | | BASE_URL PATH_HEAD PATH_TAIL |
︙ | ︙ |
Changes to wapp.tcl.
︙ | ︙ | |||
525 526 527 528 529 530 531 532 533 534 535 536 | if {$hdr==""} {return 1} set req [lindex $hdr 0] dict set W REQUEST_METHOD [set method [lindex $req 0]] if {[lsearch {GET HEAD POST} $method]<0} { error "unsupported request method: \"[dict get $W REQUEST_METHOD]\"" } set uri [lindex $req 1] set split_uri [split $uri ?] set uri0 [lindex $split_uri 0] if {![regexp {^/[-.a-z0-9_/]*$} $uri0]} { error "invalid request uri: \"$uri0\"" } | > < | 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 | if {$hdr==""} {return 1} set req [lindex $hdr 0] dict set W REQUEST_METHOD [set method [lindex $req 0]] if {[lsearch {GET HEAD POST} $method]<0} { error "unsupported request method: \"[dict get $W REQUEST_METHOD]\"" } set uri [lindex $req 1] dict set W REQUEST_URI $uri set split_uri [split $uri ?] set uri0 [lindex $split_uri 0] if {![regexp {^/[-.a-z0-9_/]*$} $uri0]} { error "invalid request uri: \"$uri0\"" } dict set W PATH_INFO $uri0 set uri1 [lindex $split_uri 1] dict set W QUERY_STRING $uri1 set n [llength $hdr] for {set i 1} {$i<$n} {incr i} { set x [lindex $hdr $i] if {![regexp {^(.+): +(.*)$} $x all name value]} { |
︙ | ︙ | |||
659 660 661 662 663 664 665 | } elseif {[dict exists $wapp HTTPS]} { dict set wapp BASE_URL https://[dict get $wapp HTTP_HOST] } else { dict set wapp BASE_URL http://[dict get $wapp HTTP_HOST] } if {![dict exists $wapp REQUEST_URI]} { dict set wapp REQUEST_URI / | < < < < > | 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 | } elseif {[dict exists $wapp HTTPS]} { dict set wapp BASE_URL https://[dict get $wapp HTTP_HOST] } else { dict set wapp BASE_URL http://[dict get $wapp HTTP_HOST] } if {![dict exists $wapp REQUEST_URI]} { dict set wapp REQUEST_URI / } if {[dict exists $wapp SCRIPT_NAME]} { dict append wapp BASE_URL [dict get $wapp SCRIPT_NAME] } else { dict set wapp SCRIPT_NAME {} } if {![dict exists $wapp PATH_INFO]} { # If PATH_INFO is missing (ex: nginx) then construct it set URI [dict get $wapp REQUEST_URI] regsub {\?.*} $URI {} URI set skip [string length [dict get $wapp SCRIPT_NAME]] dict set wapp PATH_INFO [string range $URI $skip end] } if {[regexp {^/([^/]+)(.*)$} [dict get $wapp PATH_INFO] all head tail]} { dict set wapp PATH_HEAD $head dict set wapp PATH_TAIL [string trimleft $tail /] } else { |
︙ | ︙ |