url-addr ( url -- addr ) (original) (raw)
url-addr ( url -- addr )
Furnace framework » URL objects
Prev: | set-query-param ( url value key -- url ) |
---|---|
Next: | URL encoding and decoding |
Vocabulary
urls
Inputs
url | an url |
---|
Outputs
addr | an address specifier |
---|
Word description
Outputs an address specifier for use with Connection-oriented networking.
Examples
USING: prettyprint urls ; URL" ftp://ftp.cdrom.com" url-addr .
T{ inet { host "ftp.cdrom.com" } { port 21 } }
USING: io.sockets.secure prettyprint urls ; URL" https://google.com/" url-addr .
T{ secure { addrspec T{ inet { host "google.com" } { port 443 } } } { hostname "google.com" } }
Definition
USING: accessors io.sockets io.sockets.secure kernel protocols
urls.private ;
: url-addr ( url -- addr )
[
[ host>> ipv6-host drop ] [ port>> ]
[ protocol>> lookup-protocol-port ] tri or
] [
dup protocol>> secure-protocol?
[ host>> ipv6-host drop ] [ drop ] if
] bi ;