http.client, request-url don't try to fix unfixable urls
Before, it would prepend http:// to anything and that would create bad urls like URL" http://http://". It's simpler to fix only what is fixablelocals-and-roots
parent
9cbf548340
commit
ed33bc7862
|
@ -208,3 +208,14 @@ CONSTANT: classic-proxy-settings H{
|
|||
"http://www.google.com" "GET" <client-request> ?default-proxy
|
||||
] with-variable
|
||||
] [ invalid-proxy? ] must-fail-with
|
||||
|
||||
! This url is misparsed bu request-url can fix it
|
||||
{ T{ url
|
||||
{ protocol "http" }
|
||||
{ host "www.google.com" }
|
||||
{ path "/" }
|
||||
{ port 80 }
|
||||
} } [ "www.google.com" request-url ] unit-test
|
||||
|
||||
! This one is not fixable, leave it as it is
|
||||
{ T{ url } } [ "" request-url ] unit-test
|
||||
|
|
|
@ -237,11 +237,15 @@ 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 protocol>> [ nip ] [
|
||||
dup >url dup misparsed-url? [
|
||||
drop dup url? [ present ] when
|
||||
"http://" prepend >url
|
||||
] if ensure-port ;
|
||||
] [ nip ] if ensure-port ;
|
||||
|
||||
: <client-request> ( url method -- request )
|
||||
<request>
|
||||
|
|
Loading…
Reference in New Issue