http.client, proxy defaults to http protocol like for the target

locals-and-roots
Jon Harper 2016-03-31 13:15:39 +02:00 committed by John Benediktsson
parent ed33bc7862
commit 617a725ba5
2 changed files with 28 additions and 12 deletions

View File

@ -191,6 +191,22 @@ CONSTANT: classic-proxy-settings H{
] with-variables
] unit-test
{ URL" http://localhost:3128" } [
{ { "http.proxy" "localhost:3128" } } [
"google.com" "GET" <client-request> ?default-proxy proxy-url>>
] with-variables
] unit-test
{ URL" http://localhost:3128" } [
"google.com" "GET" <client-request>
URL" localhost:3128" >>proxy-url ?default-proxy proxy-url>>
] unit-test
{ URL" http://localhost:3128" } [
"google.com" "GET" <client-request>
"localhost:3128" >>proxy-url ?default-proxy proxy-url>>
] unit-test
{ URL" http://proxysec.private:3128" } [
classic-proxy-settings [
"https://google.com" "GET" <client-request> ?default-proxy proxy-url>>

View File

@ -204,10 +204,20 @@ SYMBOL: redirects
[ "HTTP_PROXY" os-env ] unless*
] if ;
: misparsed-url? ( url -- url' )
[ protocol>> not ] [ host>> not ] [ path>> ]
tri and and ;
: request-url ( url -- url' )
dup >url dup misparsed-url? [
drop dup url? [ present ] when
"http://" prepend >url
] [ nip ] if ensure-port ;
: ?default-proxy ( request -- request' )
dup get-default-proxy
over proxy-url>> 2dup and [
pick no-proxy? [ nip ] [ [ >url ] dip derive-url ] if
over proxy-url>> dup [ request-url ] when 2dup and [
pick no-proxy? [ nip ] [ [ request-url ] dip derive-url ] if
] [ nip ] if check-proxy ;
: (with-http-request) ( request quot: ( chunk -- ) -- response )
@ -237,16 +247,6 @@ SYMBOL: redirects
[ do-redirect ] [ nip ] if
] with-variable ; inline recursive
: misparsed-url? ( url -- url' )
[ protocol>> not ] [ host>> not ] [ path>> ]
tri and and ;
: request-url ( url -- url' )
dup >url dup misparsed-url? [
drop dup url? [ present ] when
"http://" prepend >url
] [ nip ] if ensure-port ;
: <client-request> ( url method -- request )
<request>
swap >>method