URL: Uniform Resource Locator

https://en.m.wikipedia.org/wiki/URL

typedef Url URL

URI_SCHEME_MAP(XX)
XX(name, str, port)

Common URI scheme strings.

class Url
#include <Url.h>

Class to manage URL instance.

Note
The various URL components are stored in un-escaped format for ease of editing. Unless otherwise indicated, methods act on un-escaped text. Methods used to obtain escaped versions are clearly marked. Any attached fragment (marked bv ‘#’) in the URL is discarded

Public Functions

Url()
Url(const Url &url)
Url(const String &urlString)

Construct a URL object from a regular escaped string.

Parameters
  • urlString: Escaped URL

Url(const char *urlString)

Construct a URL object from a regular null-terminated escaped string.

Parameters
  • urlString: Escaped URL

Url(const String &scheme, const String &user, const String &password, const String &host, int port = 0, const String &path = nullptr, const String &query = nullptr, const String &fragment = nullptr)
Url &operator=(String urlString)

Copy assignment operator.

Note
urlString is modified by so no point in passing const reference
Parameters
  • urlString: Escaped URL

Url &operator=(const char *urlString)

Copy assignment operator, for C-style strings.

Parameters
  • urlString: Escaped URL

String toString() const

Get escaped URL.

Return Value

operator String() const
int getPort() const

Obtain the actual port number to be used.

Note
If not specified, the default scheme port is returned
Return Value
  • int:

String getHostWithPort() const

Get hostname+port part of URL string.

Note
Neither of these is subject to escaping
Return Value

String getRelativePath() const

Get path without leading separator.

Return Value

String getPathWithQuery() const

Get path with any query parameters attached.

Note
Both path and query values are escaped
Return Value

String getFileName() const

Obtain the filename part of the URL path.

Return Value

void debugPrintTo(Print &p) const

Printable output for debugging.

Parameters
  • p:

Public Members

String Scheme

without “:” and “//”

String User
String Password
String Host

hostname or IP address

int Port = 0

Undefined by default.

String Path

with leading “/”

HttpParams Query
String Fragment

Without ‘#’.

Public Static Functions

static int getDefaultPort(const String &scheme)

Obtain the default port for a given scheme.

Return Value
  • int: 0 if scheme is not recognised or has no standard port defined