Carapace

URL - Uniform Resource Locator Class

The most common type of URL on the Web is one that identifies a file -- this may contain HTML or a picture (eg. a GIF or JPEG).

The Url class provides helper functions for manipulating URLs.

Url Creation

The create function can be used to create a Url object eg.

    (create Url "http://silly.com:80/here/we/are.htm")
Once created, this object is tailored using its properties and methods.

Url Properties

An Url object supports the following properties:

property name property type description
host String the host which the holds this resource
port Integer the port on the host which the holds this resource
text String full text of the url
fragments List fragments of the url split on the / character
formData List a list of pairs which holds any form data which comes across as form data attached to the url

Url Methods

The Url object supports the following methods:

method name description
buildRelative build the relative string URL from the contained data -- the relative URL does not include the destination host and port
build build the string URL from the contained data
use fill this Url object with information from the supplied string form of a URL
path create a path from the URL
isSafe check if the URL is safe ie. that it does not contain any .. parts
connectionId treat the first fragment of the URL as an identifier for this connection -- returns the empty string "" if there is no valid connection id
shortPath make a path from the URL ignoring the first fragment
splitFormData splits the supplied form data into an attribute/value list


buildRelative

Build the relative string URL from the contained data -- the relative URL does not include the destination host and port

Arguments: none

Return type: String


build

Build the string URL from the contained data.

Arguments: none

Return type: String


use

Fill this Url object with information from the supplied string form of a URL.

Arguments:

urlString

Return type: the empty List ()


path

Create a path from the URL. The root directory, which is the root of the file hierarchy for the Web server, is supplied.

Arguments:

rootDirectoryString

Return type: String


isSafe

Check if the URL is safe ie. that it does not contain any .. parts.

Arguments: none

Return type: returns the Symbol true if it is safe, the empty List () otherwise


connectionId

Treat the first fragment of the URL as an identifier for this connection. The empty string "" is returned if there is no valid connection id.

Arguments: none

Return type: String


shortPath

Make a path from the URL ignoring the first fragment. The root directory, which is the root of the file hierarchy for the Web server, is supplied.

Arguments:

rootDirectoryString

Return type: String


splitFormData

Splits the supplied form data into an attribute/value list.

Arguments:

dataString

Return type: List


Contents Index Current topic: communications Related topics: communications classes, objects