diff --git a/extra/http/client/client-tests.factor b/extra/http/client/client-tests.factor index 9ad805b81b..db90f746ac 100755 --- a/extra/http/client/client-tests.factor +++ b/extra/http/client/client-tests.factor @@ -17,7 +17,7 @@ tuple-syntax namespaces ; path: "/index.html" version: "1.1" cookies: V{ } - header: H{ { "connection" "close" } } + header: H{ { "connection" "close" } { "user-agent" "Factor http.client vocabulary" } } } ] [ [ @@ -35,7 +35,7 @@ tuple-syntax namespaces ; path: "/index.html" version: "1.1" cookies: V{ } - header: H{ { "connection" "close" } } + header: H{ { "connection" "close" } { "user-agent" "Factor http.client vocabulary" } } } ] [ [ diff --git a/extra/http/client/client.factor b/extra/http/client/client.factor index cec1bb931a..c455c8c5f1 100755 --- a/extra/http/client/client.factor +++ b/extra/http/client/client.factor @@ -4,7 +4,7 @@ USING: assocs http kernel math math.parser namespaces sequences io io.sockets io.streams.string io.files io.timeouts strings splitting calendar continuations accessors vectors math.order io.encodings.8-bit io.encodings.binary io.streams.duplex -fry debugger inspector ; +fry debugger inspector ascii ; IN: http.client : max-redirects 10 ; @@ -37,8 +37,12 @@ SYMBOL: redirects PRIVATE> +: read-chunk-size ( -- n ) + read-crlf ";" split1 drop [ blank? ] right-trim + hex> [ "Bad chunk size" throw ] unless* ; + : read-chunks ( -- ) - read-crlf ";" split1 drop hex> dup { f 0 } member? + read-chunk-size dup zero? [ drop ] [ read % read-crlf "" assert= read-chunks ] if ; : read-response-body ( response -- response data ) diff --git a/extra/http/http.factor b/extra/http/http.factor index bc79424552..7587cb0fe9 100755 --- a/extra/http/http.factor +++ b/extra/http/http.factor @@ -256,7 +256,8 @@ cookies ; H{ } clone >>header H{ } clone >>query V{ } clone >>cookies - "close" "connection" set-header ; + "close" "connection" set-header + "Factor http.client vocabulary" "user-agent" set-header ; : query-param ( request key -- value ) swap query>> at ;