Class to manage URL instance. More...

#include <Url.h>

Collaboration diagram for Url:
[legend]

Public Member Functions

 Url ()=default
 
 Url (const Url &url)=default
 
 Url (const String &urlString)
 Construct a URL object from a regular escaped string. More...
 
 Url (const char *urlString)
 Construct a URL object from a regular null-terminated escaped string. More...
 
 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)
 
Urloperator= (String urlString)
 Copy assignment operator. More...
 
Urloperator= (const char *urlString)
 Copy assignment operator, for C-style strings. More...
 
String toString () const
 Get escaped URL. More...
 
 operator String () const
 
int getPort () const
 Obtain the actual port number to be used. More...
 
String getHostWithPort () const
 Get hostname+port part of URL string. More...
 
String getRelativePath () const
 Get path without leading separator. More...
 
String getPathWithQuery () const
 Get path with any query parameters attached. More...
 
String getFileName () const
 Obtain the filename part of the URL path. More...
 
void debugPrintTo (Print &p) const
 Printable output for debugging. More...
 

Static Public Member Functions

static int getDefaultPort (const String &scheme)
 Obtain the default port for a given scheme. More...
 

Public Attributes

String Scheme
 without ":" and "//" More...
 
String User
 
String Password
 
String Host
 hostname or IP address More...
 
int Port = 0
 Undefined by default. More...
 
String Path
 with leading "/" More...
 
HttpParams Query
 
String Fragment
 Without '#'. More...
 

Detailed Description

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

Constructor & Destructor Documentation

◆ Url() [1/5]

Url::Url ( )
default

◆ Url() [2/5]

Url::Url ( const Url url)
default

◆ Url() [3/5]

Url::Url ( const String urlString)
inline

Construct a URL object from a regular escaped string.

Parameters
urlStringEscaped URL

◆ Url() [4/5]

Url::Url ( const char *  urlString)
inline

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

Parameters
urlStringEscaped URL

◆ Url() [5/5]

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 
)
inline

Member Function Documentation

◆ debugPrintTo()

void Url::debugPrintTo ( Print p) const

Printable output for debugging.

Parameters
p

◆ getDefaultPort()

static int Url::getDefaultPort ( const String scheme)
static

Obtain the default port for a given scheme.

Return values
int0 if scheme is not recognised or has no standard port defined

◆ getFileName()

String Url::getFileName ( ) const

Obtain the filename part of the URL path.

Return values
String

◆ getHostWithPort()

String Url::getHostWithPort ( ) const

Get hostname+port part of URL string.

Return values
String
Note
Neither of these is subject to escaping

◆ getPathWithQuery()

String Url::getPathWithQuery ( ) const

Get path with any query parameters attached.

Return values
String
Note
Both path and query values are escaped

◆ getPort()

int Url::getPort ( ) const
inline

Obtain the actual port number to be used.

Return values
int
Note
If not specified, the default scheme port is returned

◆ getRelativePath()

String Url::getRelativePath ( ) const
inline

Get path without leading separator.

Return values
String

◆ operator String()

Url::operator String ( ) const
inline

◆ operator=() [1/2]

Url& Url::operator= ( String  urlString)

Copy assignment operator.

Parameters
urlStringEscaped URL
Note
urlString is modified by so no point in passing const reference

◆ operator=() [2/2]

Url& Url::operator= ( const char *  urlString)
inline

Copy assignment operator, for C-style strings.

Parameters
urlStringEscaped URL

◆ toString()

String Url::toString ( ) const

Get escaped URL.

Return values
String

Member Data Documentation

◆ Fragment

String Url::Fragment

Without '#'.

◆ Host

String Url::Host

hostname or IP address

◆ Password

String Url::Password

◆ Path

String Url::Path

with leading "/"

◆ Port

int Url::Port = 0

Undefined by default.

◆ Query

HttpParams Url::Query

◆ Scheme

String Url::Scheme

without ":" and "//"

◆ User

String Url::User

The documentation for this class was generated from the following file: