URL
classin packageklyn.net
public class URL extends Object:
Parsed URL value inspired by Java's `URL`.
Supported schemes for `toHttpRequest()` are `http` and `https`.
import klyn.net
url = URL("https://example.com:8443/api?q=1#frag")
print(url.protocol)
print(url.host)
print(url.effectivePort)
Fields
| Modifier and Type |
Member |
Description |
| public |
toHttpRequest(methodtoHttpRequest(method as String = "GET", |
Builds an HTTP request targeting this URL. |
Properties
| Modifier and Type |
Member |
Description |
| public readonly property |
authority |
Authority component as written in the URL. |
| public readonly property |
defaultPort |
Returns the default port for the current scheme. |
| public readonly property |
effectivePort |
Returns the explicit port or the scheme default port. |
| public readonly property |
file |
Returns the file component (`path` plus optional query string). |
| public readonly property |
fragment |
Fragment component without `#`. |
| public readonly property |
host |
Host or bracketed IPv6 literal. |
| public readonly property |
isHttps |
Returns true for `https` URLs. |
| public readonly property |
path |
Path component, defaulting to `/`. |
| public readonly property |
port |
Explicit port or `-1` when omitted. |
| public readonly property |
protocol |
Lower-case URL scheme. |
| public readonly property |
query |
Query component without `?`. |
Constructors
| Modifier and Type |
Member |
Description |
| public |
URL |
Parses a URL string. |
Methods
| Modifier and Type |
Member |
Description |
| public static |
fromObject |
Converts an object to `URL`. |
| public |
toExternalForm |
Alias of `toString()`. |
| public override |
toString |
No summary. |