Fix chunked encoding to work with yahoo

db4
Slava Pestov 2008-05-20 18:24:32 -05:00
parent 2090789378
commit db314db570
3 changed files with 10 additions and 5 deletions

View File

@ -17,7 +17,7 @@ tuple-syntax namespaces ;
path: "/index.html" path: "/index.html"
version: "1.1" version: "1.1"
cookies: V{ } 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" path: "/index.html"
version: "1.1" version: "1.1"
cookies: V{ } cookies: V{ }
header: H{ { "connection" "close" } } header: H{ { "connection" "close" } { "user-agent" "Factor http.client vocabulary" } }
} }
] [ ] [
[ [

View File

@ -4,7 +4,7 @@ USING: assocs http kernel math math.parser namespaces sequences
io io.sockets io.streams.string io.files io.timeouts strings io io.sockets io.streams.string io.files io.timeouts strings
splitting calendar continuations accessors vectors math.order splitting calendar continuations accessors vectors math.order
io.encodings.8-bit io.encodings.binary io.streams.duplex io.encodings.8-bit io.encodings.binary io.streams.duplex
fry debugger inspector ; fry debugger inspector ascii ;
IN: http.client IN: http.client
: max-redirects 10 ; : max-redirects 10 ;
@ -37,8 +37,12 @@ SYMBOL: redirects
PRIVATE> PRIVATE>
: read-chunk-size ( -- n )
read-crlf ";" split1 drop [ blank? ] right-trim
hex> [ "Bad chunk size" throw ] unless* ;
: read-chunks ( -- ) : read-chunks ( -- )
read-crlf ";" split1 drop hex> dup { f 0 } member? read-chunk-size dup zero?
[ drop ] [ read % read-crlf "" assert= read-chunks ] if ; [ drop ] [ read % read-crlf "" assert= read-chunks ] if ;
: read-response-body ( response -- response data ) : read-response-body ( response -- response data )

View File

@ -256,7 +256,8 @@ cookies ;
H{ } clone >>header H{ } clone >>header
H{ } clone >>query H{ } clone >>query
V{ } clone >>cookies V{ } clone >>cookies
"close" "connection" set-header ; "close" "connection" set-header
"Factor http.client vocabulary" "user-agent" set-header ;
: query-param ( request key -- value ) : query-param ( request key -- value )
swap query>> at ; swap query>> at ;