189
190
191
192
193
194
195
196
197
198
199
200
201
202
|
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
|
+
+
+
+
+
+
+
+
+
+
+
|
# Add extra entries to the reply header
#
proc wapp-reply-extra {name value} {
global wapp
dict lappend wapp .reply-extra $name $value
}
# Specifies how the web-page under construction should be cached.
# The argument should be one of:
#
# no-cache
# max-age=N (for some integer number of seconds, N)
# private,max-age=N
#
proc wapp-cache-control {x} {
wapp-reply-extra Cache-Control $x
}
# Redirect to a different web page
#
proc wapp-redirect {uri} {
wapp-reply-code {302 found}
wapp-reply-extra Location $uri
}
|
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
|
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
|
-
+
-
+
|
}
# Transmit the HTTP reply
#
if {$chan=="stdout"} {
puts $chan "Status: [dict get $wapp .reply-code]\r"
} else {
puts $chan "HTTP/1.0 [dict get $wapp .reply-code]\r"
puts $chan "HTTP/1.1 [dict get $wapp .reply-code]\r"
puts $chan "Server: wapp\r"
puts $chan "Content-Length: [string length [dict get $wapp .reply]]\r"
puts $chan "Connection: Closed\r"
puts $chan "Connection: close\r"
}
if {[dict exists $wapp .reply-extra]} {
foreach {name value} [dict get $wapp .reply-extra] {
puts $chan "$name: $value\r"
}
}
set mimetype [dict get $wapp .mimetype]
|