Static responder now works when the root is a file rather than a directory
parent
5b5acf165c
commit
2c1f7b9293
|
@ -1,8 +1,8 @@
|
||||||
USING: http http.server http.client http.client.private tools.test multiline
|
USING: http http.server http.client http.client.private tools.test
|
||||||
io.streams.string io.encodings.utf8 io.encodings.8-bit
|
multiline io.streams.string io.encodings.utf8 io.encodings.8-bit
|
||||||
io.encodings.binary io.encodings.string kernel arrays splitting
|
io.encodings.binary io.encodings.string io.encodings.ascii kernel
|
||||||
sequences assocs io.sockets db db.sqlite continuations urls
|
arrays splitting sequences assocs io.sockets db db.sqlite
|
||||||
hashtables accessors namespaces xml.data ;
|
continuations urls hashtables accessors namespaces xml.data ;
|
||||||
IN: http.tests
|
IN: http.tests
|
||||||
|
|
||||||
[ "text/plain" latin1 ] [ "text/plain" parse-content-type ] unit-test
|
[ "text/plain" latin1 ] [ "text/plain" parse-content-type ] unit-test
|
||||||
|
@ -359,4 +359,17 @@ SYMBOL: a
|
||||||
! Test basic auth
|
! Test basic auth
|
||||||
[ "Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==" ] [ <request> "Aladdin" "open sesame" set-basic-auth "Authorization" header ] unit-test
|
[ "Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==" ] [ <request> "Aladdin" "open sesame" set-basic-auth "Authorization" header ] unit-test
|
||||||
|
|
||||||
|
! Test a corner case with static responder
|
||||||
|
[ ] [
|
||||||
|
<dispatcher>
|
||||||
|
add-quit-action
|
||||||
|
"vocab:http/test/foo.html" <static> >>default
|
||||||
|
test-httpd
|
||||||
|
] unit-test
|
||||||
|
|
||||||
|
[ t ] [
|
||||||
|
"http://localhost/" add-port http-get nip
|
||||||
|
"vocab:http/test/foo.html" ascii file-contents =
|
||||||
|
] unit-test
|
||||||
|
|
||||||
|
[ ] [ "http://localhost/quit" add-port http-get 2drop ] unit-test
|
|
@ -47,8 +47,8 @@ TUPLE: file-responder root hook special allow-listings ;
|
||||||
if ;
|
if ;
|
||||||
|
|
||||||
: serving-path ( filename -- filename )
|
: serving-path ( filename -- filename )
|
||||||
[ file-responder get root>> trim-tail-separators "/" ] dip
|
[ file-responder get root>> trim-tail-separators ] dip
|
||||||
"" or trim-head-separators 3append ;
|
[ "/" swap trim-head-separators 3append ] unless-empty ;
|
||||||
|
|
||||||
: serve-file ( filename -- response )
|
: serve-file ( filename -- response )
|
||||||
dup mime-type
|
dup mime-type
|
||||||
|
|
Loading…
Reference in New Issue