Sming Framework API
Sming - Open Source framework for high efficiency WiFi SoC ESP8266 native development with C++ language.
Url Class Reference

Class to manage URL instance. More...

#include <Url.h>

Public Member Functions

 Url (const Url &url)=default
 
 Url (const String &urlString)
 Construct a URL object from a regular escaped string Escaped URL. More...
 
 Url (const char *urlString)
 Construct a URL object from a regular null-terminated escaped string Escaped URL. 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::Url ( const String urlString)
inline

Construct a URL object from a regular escaped string Escaped URL.

Url::Url ( const char *  urlString)
inline

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

Member Function Documentation

void Url::debugPrintTo ( Print p) const

Printable output for debugging.

Parameters
p
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
String Url::getFileName ( ) const

Obtain the filename part of the URL path.

Return values
String
String Url::getHostWithPort ( ) const

Get hostname+port part of URL string.

Return values
String
Note
Neither of these is subject to escaping
String Url::getPathWithQuery ( ) const

Get path with any query parameters attached.

Return values
String
Note
Both path and query values are escaped
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
String Url::getRelativePath ( ) const
inline

Get path without leading separator.

Return values
String
Url& Url::operator= ( String  urlString)

Copy assignment operator.

Parameters
urlStringEscaped URL
Note
urlString is modified by so no point in passing const reference
Url& Url::operator= ( const char *  urlString)
inline

Copy assignment operator, for C-style strings.

Parameters
urlStringEscaped URL
String Url::toString ( ) const

Get escaped URL.

Return values
String

Member Data Documentation

String Url::Fragment

Without '#'.

String Url::Host

hostname or IP address

String Url::Path

with leading "/"

int Url::Port = 0

Undefined by default.

String Url::Scheme

without ":" and "//"