http.client: throw if the proxy not empty and not valid
parent
cb3bbc8a40
commit
9cbf548340
|
@ -10,6 +10,9 @@ HELP: download-failed
|
|||
HELP: too-many-redirects
|
||||
{ $error-description "Thrown by " { $link http-request } " if the server returns a chain of than " { $link max-redirects } " redirections." } ;
|
||||
|
||||
HELP: invalid-proxy
|
||||
{ $error-description "Thrown by " { $link http-request } " if the proxy url is not valid." } ;
|
||||
|
||||
HELP: <get-request>
|
||||
{ $values { "url" { $or url string } } { "request" request } }
|
||||
{ $description "Constructs an HTTP GET request for retrieving the URL." }
|
||||
|
|
|
@ -202,3 +202,9 @@ CONSTANT: classic-proxy-settings H{
|
|||
"allprivate.google.com" "GET" <client-request> ?default-proxy proxy-url>>
|
||||
] with-variables
|
||||
] unit-test
|
||||
|
||||
[
|
||||
<url> 3128 >>port "http.proxy" [
|
||||
"http://www.google.com" "GET" <client-request> ?default-proxy
|
||||
] with-variable
|
||||
] [ invalid-proxy? ] must-fail-with
|
||||
|
|
|
@ -11,6 +11,7 @@ environment ;
|
|||
IN: http.client
|
||||
|
||||
ERROR: too-many-redirects ;
|
||||
ERROR: invalid-proxy proxy ;
|
||||
|
||||
: success? ( code -- ? ) 200 299 between? ;
|
||||
|
||||
|
@ -181,8 +182,15 @@ SYMBOL: redirects
|
|||
[ "." split no-proxy-match? ] with any?
|
||||
] [ drop f ] if* ;
|
||||
|
||||
: (check-proxy) ( proxy -- ? )
|
||||
{
|
||||
{ [ dup URL" " = ] [ drop f ] }
|
||||
{ [ dup host>> ] [ drop t ] }
|
||||
[ invalid-proxy ]
|
||||
} cond ;
|
||||
|
||||
: check-proxy ( request proxy -- request' )
|
||||
dup [ host>> ] [ f ] if*
|
||||
dup [ (check-proxy) ] [ f ] if*
|
||||
[ drop f ] unless [ clone ] dip >>proxy-url ;
|
||||
|
||||
: get-default-proxy ( request -- default-proxy )
|
||||
|
|
|
@ -204,7 +204,7 @@ ARTICLE: "http.proxy-variables" "HTTP(S) proxy variables"
|
|||
{ "HTTPS" { $snippet "\"https.proxy\"" } "https_proxy" "HTTPS_PROXY" }
|
||||
{ "no proxy" { $snippet "\"no_proxy\"" } "no_proxy" "NO_PROXY" }
|
||||
}
|
||||
"When making an http request, if the target host is not matched by the no_proxy list, the " { $vocab-link "http.client" } " will fill the missing components of the " { $slot "proxy-url" } " slot of the " { $link request } " from the value of these variables."
|
||||
"When making an http request, if the target host is not matched by the no_proxy list, the " { $vocab-link "http.client" } " will fill the missing components of the " { $slot "proxy-url" } " slot of the " { $link request } " from the value of these variables. If the filled result is not valid, an error is thrown."
|
||||
{ $notes "The dynamic variables are keyed by strings. This allows to use Factor's command line support to define them (see in the examples below)." }
|
||||
|
||||
{ $heading "no_proxy" }
|
||||
|
|
Loading…
Reference in New Issue