tufao
0.8.1
An asynchronous web framework for C++ built on top of Qt
|
This class provides a convenient interface for parsing URLs. More...
Public Member Functions | |
Url (const QString &url=QString()) | |
Constructs a Tufao::Url to extract information from url . | |
Url (const Url &url) | |
Constructs a url as a copy of url . | |
~Url () | |
Destroys the url. | |
Url & | operator= (const Url &url) |
Copies the url url and returns a reference to the copy. | |
QString | scheme () const |
The protocol. More... | |
QString | authority () const |
The authority. More... | |
QString | path () const |
The path. More... | |
QString | query () const |
The query string. More... | |
QString | fragment () const |
The fragment id, also know as hash. More... | |
QString | userinfo () const |
The userinfo. More... | |
QString | hostname () const |
The hostname. More... | |
QString | port () const |
The port. More... | |
QString | username () const |
The username. More... | |
QString | password () const |
The password. More... | |
Static Public Member Functions | |
static QByteArray | url (Tufao::HttpServerRequest *request) |
Returns the url likely used by the client to perform the request . More... | |
This class provides a convenient interface for parsing URLs.
Consider the following request coming from a user agent:
GET /search?q=foo&category=z HTTP/1.1 Host: example.com ...
The HttpServerRequest::url method will return the full url, making difficult to your application take the right decision with the object. This class will facilitate your job.
Some fields in URLs are optionals. If the optional fields are absent, the object will return empty strings for these fields, but if you try to use this class to parse an invalid url, you will get empty strings to all fields.
QString Tufao::Url::authority | ( | ) | const |
The authority.
The authority contains:
In the url "scheme://userinfo@hostname:port/path?query#fragment" the authority will be "userinfo@hostname:port".
Other examples:
QString Tufao::Url::fragment | ( | ) | const |
The fragment id, also know as hash.
In the url "scheme://userinfo@hostname:port/path?query#fragment" the hash will be "fragment".
Other examples:
QString Tufao::Url::hostname | ( | ) | const |
The hostname.
In the url "scheme://userinfo@hostname:port/path?query#fragment" the hostname will be "hostname"
Other examples:
QString Tufao::Url::password | ( | ) | const |
The password.
This password is extracted from the userinfo assuming that userinfo uses the format "username:password".
In the url "scheme://userinfo@hostname:port/path?query#fragment" the password will be "".
Other examples:
QString Tufao::Url::path | ( | ) | const |
The path.
In the url "scheme://userinfo@hostname:port/path?query#fragment" the path will be "/path".
Other examples:
QString Tufao::Url::port | ( | ) | const |
The port.
In the url "scheme://userinfo@hostname:port/path?query#fragment" the port will be "port".
Other examples:
QString Tufao::Url::query | ( | ) | const |
The query string.
In the url "scheme://userinfo@hostname:port/path?query#fragment" the query string will be "query".
Other examples:
QString Tufao::Url::scheme | ( | ) | const |
The protocol.
In the url "scheme://userinfo@hostname:port/path?query#fragment" the scheme will be "scheme".
Other examples:
|
static |
Returns the url likely used by the client to perform the request
.
QString Tufao::Url::userinfo | ( | ) | const |
The userinfo.
The userinfo contains the username and password.
In the url "scheme://userinfo@hostname:port/path?query#fragment" the userinfo will be "userinfo".
Other examples:
QString Tufao::Url::username | ( | ) | const |
The username.
This username is extracted from the userinfo assuming that userinfo uses the format "username:password".
In the url "scheme://userinfo@hostname:port/path?query#fragment" the username will be "userinfo".
Other examples: