Public Member Functions | Public Attributes

URL Struct Reference

#include <sockets.h>

Collaboration diagram for URL:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 URL (const char *url)
bool parse_url (const char *str, const char *default_port="80")

Public Attributes

string _scheme
string _hostname
string _port
string _path

Detailed Description

Definition at line 38 of file sockets.h.


Constructor & Destructor Documentation

URL::URL ( const char *  url ) [inline]

Definition at line 40 of file sockets.h.

References parse_url().

    {
        parse_url(url);
    }

Here is the call graph for this function:


Member Function Documentation

bool URL::parse_url ( const char *  str,
const char *  default_port = "80" 
) [inline]

Definition at line 50 of file sockets.h.

References _hostname, _path, _port, and _scheme.

Referenced by URL().

    {
        if (!str || !*str)
            return false;

        const char* p1 = strstr(str, "://");

        if (p1) {
            _scheme.assign(str, p1-str);
            p1 += 3;
        } else
            p1 = str;

        const char* p2 = strchr(p1, ':');
        const char* p3 = p2? strchr(p2+1, '/'): p2;

        if (p2) {
            _hostname.assign(p1, p2-p1);
            _port.assign(p2+1, p3-(p2+1));
            _path = p3;
        } else {
            _hostname = p1;
            _port = default_port;
            _path.erase();
        }

        if (_path.empty())
            _path = "/";

        return true;
    }

Here is the caller graph for this function:


Member Data Documentation

Definition at line 46 of file sockets.h.

Referenced by parse_url(), and HttpServer::register_url().

string URL::_path

Definition at line 48 of file sockets.h.

Referenced by parse_url(), HttpServer::register_url(), and HttpServer::unregister_url().

string URL::_port

Definition at line 47 of file sockets.h.

Referenced by parse_url(), and HttpServer::register_url().

string URL::_scheme

Definition at line 45 of file sockets.h.

Referenced by parse_url().


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