salvia-protocol-1.0.1: Salvia webserver protocol suite supporting URI, HTTP, Cookie and MIME.

Network.Protocol.Uri

Contents

Description

See rfc2396 for more info.

Synopsis

URI datatype.

data Domain Source

Constructors

Domain [String] 

Instances

data IPv4 Source

Constructors

IPv4 Int Int Int Int 

Instances

data Path Source

Constructors

Path [PathSegment] 

Instances

data Host Source

Instances

data Uri Source

Instances

Accessing parts of URIs.

relative :: Uri :-> BoolSource

Is a URI relative?

scheme :: Uri :-> SchemeSource

Access the scheme part of the URI. A scheme is probably the protocol indicator like http, ftp, etc.

userinfo :: Uri :-> StringSource

Access the userinfo part of the URI. The userinfo contains an optional username and password or some other credentials.

authority :: Uri :-> AuthoritySource

Access authority part of the URI.

host :: Uri :-> StringSource

Access the host part of the URI.

domain :: Uri :-> Maybe DomainSource

Access domain part of the URI, returns Nothing when the host is a regname or IP-address.

ipv4 :: Uri :-> Maybe IPv4Source

Access IPv4-address part of the URI, returns Nothing when the host is a domain or regname.

regname :: Uri :-> Maybe RegNameSource

Access regname part of the URI, returns Nothing when the host is a domain or IP-address.

port :: Uri :-> Maybe PortSource

Access the port number part of the URI when available.

path :: Uri :-> FilePathSource

Access the path part of the URI. The query will be properly decoded when reading and encoded when writing.

segments :: Uri :-> [PathSegment]Source

Access the path part of the URI as a list of path segments. The segments will still be URI-encoded.

query :: Uri :-> QuerySource

Access the query part of the URI, the part that follows the ?. The query will be properly decoded when reading and encoded when writing.

fragment :: Uri :-> FragmentSource

Access the fragment part of the URI, the part that follows the #. The fragment will be properly decoded when reading and encoded when writing.

More advanced labels and functions.

pathAndQuery :: Uri :-> StringSource

Access the path and query parts of the URI as a single string. The string will will be properly decoded when reading and encoded when writing.

queryParams :: Uri :-> ParametersSource

Fetch the query parameters form a URI.

params :: String :<->: ParametersSource

Generic lens to parse/print a string as query parameters.

extension :: FilePath :-> Maybe StringSource

Label to access the extension of a filename.

remap :: (Uri, Uri) -> Uri -> Maybe UriSource

Map one URI to another using a URI mapping scheme. A URI mapping scheme is simply a pair of URIs of which only the host part, port number and path will be taken into account when mapping.

Encoding/decoding URI encoded strings.

encode :: String -> StringSource

URI encode a string.

decode :: String -> StringSource

URI decode a string.

encoded :: String :<->: StringSource

Decoding and encoding as a label.

Creating empty URIs.

mkUri :: UriSource

Constructors for making empty URI.

mkScheme :: SchemeSource

Constructors for making empty Scheme.

mkPath :: PathSource

Constructors for making empty Path.

mkAuthority :: AuthoritySource

Constructors for making empty Authority.

mkQuery :: QuerySource

Constructors for making empty Query.

mkFragment :: FragmentSource

Constructors for making empty Fragment.

mkUserinfo :: UserInfoSource

Constructors for making empty UserInfo.

mkHost :: HostSource

Constructors for making empty Host.

mkPort :: Maybe PortSource

Constructors for making empty Port.

Parsing URIs.

toUri :: String -> UriSource

Parse string into a URI and ignore all failures by returning an empty URI when parsing fails. Can be quite useful in situations that parse errors are unlikely.

parseUri :: String -> Either ParseError UriSource

Parse string into a URI.

parseAbsoluteUri :: String -> Either ParseError UriSource

Parse string into a URI and only accept absolute URIs.

parseAuthority :: String -> Either ParseError AuthoritySource

Parse string into an authority.

parsePath :: String -> Either ParseError PathSource

Parse string into a path.

parseHost :: String -> Either ParseError HostSource

Parse string into a host.

Filename related utilities.

mimetype :: FilePath -> Maybe StringSource

Try to guess the correct mime type for the input file based on the file extension.

normalize :: FilePath -> FilePathSource

Normalize a path by removing or merging all dot or dot-dot segments and double slashes.

jailSource

Arguments

:: FilePath

Jail directory.

-> FilePath

Filename to jail.

-> Maybe FilePath 

Jail a filepath within a jail directory.

(/+) :: FilePath -> FilePath -> FilePathSource

Concatenate and normalize two filepaths.