From cb174f0db10bbf53831e499eaeab5da52c2e3919 Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Wed, 4 Feb 2009 04:17:24 -0600 Subject: [PATCH] Regression: HTTP server would fail to serve files with binary encoding after Dan's io.encodings.iana changes from earlier today --- basis/http/server/server-tests.factor | 17 ++++++++++++++++- basis/http/server/server.factor | 6 ++---- 2 files changed, 18 insertions(+), 5 deletions(-) diff --git a/basis/http/server/server-tests.factor b/basis/http/server/server-tests.factor index fdba9a63ef..171973fcd8 100644 --- a/basis/http/server/server-tests.factor +++ b/basis/http/server/server-tests.factor @@ -1,6 +1,21 @@ -USING: http http.server math sequences continuations tools.test ; +USING: http http.server math sequences continuations tools.test +io.encodings.utf8 io.encodings.binary accessors ; IN: http.server.tests [ t ] [ [ \ + first ] [ <500> ] recover response? ] unit-test \ make-http-error must-infer + +[ "text/plain; charset=UTF-8" ] [ + + "text/plain" >>content-type + utf8 >>content-charset + unparse-content-type +] unit-test + +[ "text/xml" ] [ + + "text/xml" >>content-type + binary >>content-charset + unparse-content-type +] unit-test \ No newline at end of file diff --git a/basis/http/server/server.factor b/basis/http/server/server.factor index 97c14a6457..b6ee70057b 100755 --- a/basis/http/server/server.factor +++ b/basis/http/server/server.factor @@ -97,10 +97,8 @@ GENERIC: write-full-response ( request response -- ) tri ; : unparse-content-type ( request -- content-type ) - [ content-type>> "application/octet-stream" or ] - [ content-charset>> encoding>name ] - bi - [ "; charset=" glue ] when* ; + [ content-type>> "application/octet-stream" or ] [ content-charset>> ] bi + dup binary eq? [ drop ] [ encoding>name "; charset=" glue ] if ; : ensure-domain ( cookie -- cookie ) [