Main Page | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Class Members | File Members | Related Pages

Uri Class Reference

Inheritance diagram for Uri:

IWritable MutableUri List of all members.

Public Member Functions

 this (char[] uri)
char[] getScheme ()
char[] getHost ()
int getPort ()
int getValidPort ()
char[] getUserInfo ()
char[] getPath ()
char[] getQuery ()
char[] getFragment ()
bool isGeneric ()
IBuffer write (IBuffer buf)
void write (IWriter writer)
char[] decode (char[] s)

Static Public Member Functions

static this ()
static final int getDefaultPort (char[] scheme)

Public Attributes

const int InvalidPort = -1

Private Types

enum  {
  ExcScheme = 0x01, ExcAuthority = 0x02, ExcPath = 0x04, ExcQuery = 0x08,
  IncUser = 0x10, IncPath = 0x20, IncQuery = 0x40, IncScheme = 0x80,
  IncGeneric = IncScheme | IncUser | IncPath | IncQuery
}

Private Member Functions

 this ()
void parse (char[] uri)
void parseAuthority (char[] auth)

Static Private Member Functions

static IBuffer encode (IBuffer buf, char[] s, int flags)
static char[] toLower (inout char[] src)

Private Attributes

int port
char[] host
char[] path
char[] query
char[] scheme
char[] userinfo
char[] fragment
HeapSlice decoded

Static Private Attributes

static ubyte map [256]
static short[char[]] genericSchemes
static const char[] hexDigits = "0123456789abcdef"
static IOException error
static const SchemePort[] schemePorts

Classes

struct  SchemePort

Detailed Description

Implements an RFC 2396 compliant URI specification. See this page for more information.

The implementation fails the spec on two counts: it doesn't insist on a scheme being present in the Uri, and it doesn't implement the "Relative References" support noted in section 5.2. Note that IRI support can be added by assuming each of userinfo, path, query, and fragment are UTF-8 encoded (see this page for further details).

Use the MutableUri derivative where you need to alter specific uri attributes.

Definition at line 74 of file Uri.d.


Member Enumeration Documentation

anonymous enum [private]
 

Enumeration values:
ExcScheme 
ExcAuthority 
ExcPath 
ExcQuery 
IncUser 
IncPath 
IncQuery 
IncScheme 
IncGeneric 

Definition at line 96 of file Uri.d.


Member Function Documentation

static this  )  [inline, static]
 

Initialize the Uri character maps and so on

Reimplemented in MutableUri.

Definition at line 155 of file Uri.d.

References error, ExcAuthority, ExcPath, ExcQuery, ExcScheme, genericSchemes, IncGeneric, IncPath, IncQuery, IncScheme, IncUser, map, and schemePorts.

this char[]  uri  )  [inline]
 

Reimplemented in MutableUri.

Definition at line 237 of file Uri.d.

References parse().

static final int getDefaultPort char[]  scheme  )  [inline, static]
 

Definition at line 251 of file Uri.d.

References genericSchemes, InvalidPort, and port.

Referenced by getValidPort(), and write().

char [] getScheme  )  [inline]
 

Definition at line 266 of file Uri.d.

References scheme.

Referenced by HttpRequest::getRequestUri().

char [] getHost  )  [inline]
 

Definition at line 278 of file Uri.d.

References host.

Referenced by HttpRequest::getExplicitUri(), HttpRequest::getHost(), HttpClient::open(), and HttpClient::this().

int getPort  )  [inline]
 

Definition at line 290 of file Uri.d.

References port.

Referenced by HttpRequest::getHost().

int getValidPort  )  [inline]
 

Definition at line 302 of file Uri.d.

References getDefaultPort(), InvalidPort, port, and scheme.

Referenced by HttpClient::this().

char [] getUserInfo  )  [inline]
 

Definition at line 316 of file Uri.d.

References userinfo.

char [] getPath  )  [inline]
 

Definition at line 328 of file Uri.d.

References path.

Referenced by HttpClient::open(), and ServletProvider::service().

char [] getQuery  )  [inline]
 

Definition at line 340 of file Uri.d.

References query.

Referenced by HttpRequest::getInputParameters().

char [] getFragment  )  [inline]
 

Definition at line 352 of file Uri.d.

References fragment.

bool isGeneric  )  [inline]
 

Definition at line 363 of file Uri.d.

References genericSchemes, and scheme.

IBuffer write IBuffer  buf  )  [inline]
 

Definition at line 375 of file Uri.d.

References IBuffer::append(), encode(), fragment, getDefaultPort(), host, IncPath, IncQuery, IncUser, Integer, InvalidPort, path, port, query, scheme, and userinfo.

Referenced by write().

void write IWriter  writer  )  [inline]
 

Reimplemented from IWritable.

Definition at line 423 of file Uri.d.

References IWriter::getBuffer(), and write().

char [] decode char[]  s  )  [inline]
 

Definition at line 436 of file Uri.d.

References decoded, HeapSlice::expand(), memchr(), and HeapSlice::slice().

Referenced by HttpRequest::getInputParameters(), parse(), and parseAuthority().

static IBuffer encode IBuffer  buf,
char[]  s,
int  flags
[inline, static, private]
 

Encode uri characters into an output buffer, such that reserved chars are converted into their hex version.

Definition at line 489 of file Uri.d.

References IBuffer::append(), hexDigits, and map.

Referenced by write().

this  )  [inline, private]
 

This should not be exposed outside of this module!

Reimplemented in MutableUri.

Definition at line 521 of file Uri.d.

References decoded, HeapSlice, InvalidPort, and port.

void parse char[]  uri  )  [inline, private]
 

Parsing is performed according to RFC 2396

                  ^(([^:/?#]+):)?(//([^/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?
                   12            3  4          5       6  7        8 9
                    
                2 isolates scheme
                4 isolates authority
                5 isolates path
                7 isolates query
                9 isolates fragment

This was originally a state-machine; it turned out to be a lot faster (~40%) when unwound like this instead.

Reimplemented in MutableUri.

Definition at line 547 of file Uri.d.

References decode(), ExcAuthority, ExcPath, ExcScheme, fragment, map, parseAuthority(), path, query, scheme, and toLower().

Referenced by this().

void parseAuthority char[]  auth  )  [inline, private]
 

Authority is the section after the scheme, but before the path, query or fragment; it typically represents a host.

                    ^(([^@]*)@?)([^:]*)?(:(.*))?
                     12         3       4 5
                  
                2 isolates userinfo
                3 isolates host
                5 isolates port

Definition at line 605 of file Uri.d.

References decode(), host, Integer, port, and userinfo.

Referenced by parse().

static char [] toLower inout char[]  src  )  [inline, static, private]
 

in-place conversion to lowercase

Definition at line 638 of file Uri.d.

Referenced by parse().


Member Data Documentation

const int InvalidPort = -1
 

Definition at line 76 of file Uri.d.

Referenced by getDefaultPort(), HttpRequest::getHost(), getValidPort(), this(), and write().

int port [private]
 

Definition at line 78 of file Uri.d.

Referenced by getDefaultPort(), getPort(), getValidPort(), parseAuthority(), this(), and write().

char [] host [private]
 

Definition at line 79 of file Uri.d.

Referenced by getHost(), parseAuthority(), and write().

char [] path [private]
 

Definition at line 79 of file Uri.d.

Referenced by getPath(), parse(), and write().

char [] query [private]
 

Definition at line 79 of file Uri.d.

Referenced by getQuery(), parse(), and write().

char [] scheme [private]
 

Definition at line 79 of file Uri.d.

Referenced by getScheme(), getValidPort(), isGeneric(), parse(), and write().

char [] userinfo [private]
 

Definition at line 79 of file Uri.d.

Referenced by getUserInfo(), parseAuthority(), and write().

char [] fragment [private]
 

Definition at line 79 of file Uri.d.

Referenced by getFragment(), parse(), and write().

HeapSlice decoded [private]
 

Definition at line 85 of file Uri.d.

Referenced by decode(), and this().

ubyte map[256] [static, private]
 

Definition at line 87 of file Uri.d.

Referenced by encode(), parse(), and this().

short [char[]] genericSchemes [static, private]
 

Definition at line 90 of file Uri.d.

Referenced by getDefaultPort(), isGeneric(), and this().

const char [] hexDigits = "0123456789abcdef" [static, private]
 

Definition at line 92 of file Uri.d.

Referenced by encode().

IOException error [static, private]
 

Definition at line 94 of file Uri.d.

Referenced by this().

const SchemePort [] schemePorts [static, private]
 

Initial value:

                        [
                        {"coffee",      80}

Definition at line 114 of file Uri.d.

Referenced by this().


The documentation for this class was generated from the following file:
Generated on Sat Dec 24 17:28:43 2005 for Mango by  doxygen 1.4.0