fix httpd
parent
7985d315f8
commit
ddfadea21e
|
@ -9,9 +9,9 @@ io strings ;
|
||||||
|
|
||||||
: file-response ( mime-type length -- )
|
: file-response ( mime-type length -- )
|
||||||
[
|
[
|
||||||
number>string "Content-Length" swons ,
|
number>string "Content-Length" set
|
||||||
"Content-Type" swons ,
|
"Content-Type" set
|
||||||
] [ ] make "200 OK" response terpri ;
|
] make-hash "200 OK" response terpri ;
|
||||||
|
|
||||||
: serve-static ( filename mime-type -- )
|
: serve-static ( filename mime-type -- )
|
||||||
over file-length file-response "method" get "head" = [
|
over file-length file-response "method" get "head" = [
|
||||||
|
|
|
@ -19,7 +19,7 @@ sequences io strings ;
|
||||||
" " split1 drop string>number ;
|
" " split1 drop string>number ;
|
||||||
|
|
||||||
: read-response ( -- code header )
|
: read-response ( -- code header )
|
||||||
#! After sending a GET oR POST we read a response line and
|
#! After sending a GET or POST we read a response line and
|
||||||
#! header.
|
#! header.
|
||||||
flush readln parse-response read-header ;
|
flush readln parse-response read-header ;
|
||||||
|
|
||||||
|
|
|
@ -9,7 +9,7 @@ SYMBOL: vhosts
|
||||||
SYMBOL: responders
|
SYMBOL: responders
|
||||||
|
|
||||||
: print-header ( alist -- )
|
: print-header ( alist -- )
|
||||||
[ unswons write ": " write url-encode print ] each ;
|
[ swap write ": " write url-encode print ] hash-each ;
|
||||||
|
|
||||||
: response ( header msg -- )
|
: response ( header msg -- )
|
||||||
"HTTP/1.0 " write print print-header ;
|
"HTTP/1.0 " write print print-header ;
|
||||||
|
@ -34,7 +34,7 @@ SYMBOL: responders
|
||||||
] with-scope ;
|
] with-scope ;
|
||||||
|
|
||||||
: serving-content ( mime -- )
|
: serving-content ( mime -- )
|
||||||
"Content-Type" swons unit
|
"Content-Type" associate
|
||||||
"200 Document follows" response terpri ;
|
"200 Document follows" response terpri ;
|
||||||
|
|
||||||
: serving-html "text/html" serving-content ;
|
: serving-html "text/html" serving-content ;
|
||||||
|
@ -42,7 +42,7 @@ SYMBOL: responders
|
||||||
: serving-text "text/plain" serving-content ;
|
: serving-text "text/plain" serving-content ;
|
||||||
|
|
||||||
: redirect ( to -- )
|
: redirect ( to -- )
|
||||||
"Location" swons unit
|
"Location" associate
|
||||||
"301 Moved Permanently" response terpri ;
|
"301 Moved Permanently" response terpri ;
|
||||||
|
|
||||||
: directory-no/ ( -- )
|
: directory-no/ ( -- )
|
||||||
|
|
Loading…
Reference in New Issue