url-2.1.3: A library for working with URLs.

Copyright | (c) Galois Inc. 2007 2008
License | BSD3
Maintainer | Iavor S. Diatchki
Stability | Provisional
Portability | Portable
Safe Haskell | Safe-Inferred
Language | Haskell98

Network.URL

Description

Provides a convenient way for working with HTTP URLs. Based on RFC 1738. See also: RFC 3986

Synopsis

- data URL = URL {
  - url_type :: URLType
  - url_path :: String
  - url_params :: [(String, String)]
  }
- data URLType
  - = Absolute Host
  - | HostRelative
  - | PathRelative
- data Host = Host {
  - protocol :: Protocol
  - host :: String
  - port :: Maybe Integer
  }
- data Protocol
  - = HTTP Bool
  - | FTP Bool
  - | RawProt String
- secure :: Host -> Bool
- secure_prot :: Protocol -> Bool
- exportURL :: URL -> String
- importURL :: String -> Maybe URL
- exportHost :: Host -> String
- add_param :: URL -> (String, String) -> URL
- decString :: Bool -> String -> Maybe String
- encString :: Bool -> (Char -> Bool) -> String -> String
- ok_host :: Char -> Bool
- ok_url :: Char -> Bool
- ok_param :: Char -> Bool
- ok_path :: Char -> Bool
- exportParams :: [(String, String)] -> String
- importParams :: String -> Maybe [(String, String)]

# Documentation

data URL Source #

A type for working with URL. The parameters are in `application/x-www-form-urlencoded` format: http://www.w3.org/TR/html4/interact/forms.html#h-17.13.4.1

Constructors

URL |

Fields

- url_type :: URLType
- url_path :: String
- url_params :: [(String, String)]

#### Instances

Instances details

Show URL Source # |
Instance details Defined in Network.URL Methods showsPrec :: Int -> URL -> ShowS Source # show :: URL -> String Source # showList :: [URL] -> ShowS Source #
Eq URL Source # |
Instance details Defined in Network.URL Methods (==) :: URL -> URL -> Bool Source # (/=) :: URL -> URL -> Bool Source #
Ord URL Source # |
Instance details Defined in Network.URL Methods compare :: URL -> URL -> Ordering Source # (<) :: URL -> URL -> Bool Source # (<=) :: URL -> URL -> Bool Source # (>) :: URL -> URL -> Bool Source # (>=) :: URL -> URL -> Bool Source # max :: URL -> URL -> URL Source # min :: URL -> URL -> URL Source #

data URLType Source #

Different types of URL.

Constructors

Absolute Host | Has a host
HostRelative | Does not have a host
PathRelative | Relative to another URL

#### Instances

Instances details

Show URLType Source # |
Instance details Defined in Network.URL Methods showsPrec :: Int -> URLType -> ShowS Source # show :: URLType -> String Source # showList :: [URLType] -> ShowS Source #
Eq URLType Source # |
Instance details Defined in Network.URL Methods (==) :: URLType -> URLType -> Bool Source # (/=) :: URLType -> URLType -> Bool Source #
Ord URLType Source # |
Instance details Defined in Network.URL Methods compare :: URLType -> URLType -> Ordering Source # (<) :: URLType -> URLType -> Bool Source # (<=) :: URLType -> URLType -> Bool Source # (>) :: URLType -> URLType -> Bool Source # (>=) :: URLType -> URLType -> Bool Source # max :: URLType -> URLType -> URLType Source # min :: URLType -> URLType -> URLType Source #

data Host Source #

Contains information about the connection to the host.

Constructors

Host |

Fields

- protocol :: Protocol
- host :: String
- port :: Maybe Integer

#### Instances

Instances details

Show Host Source # |
Instance details Defined in Network.URL Methods showsPrec :: Int -> Host -> ShowS Source # show :: Host -> String Source # showList :: [Host] -> ShowS Source #
Eq Host Source # |
Instance details Defined in Network.URL Methods (==) :: Host -> Host -> Bool Source # (/=) :: Host -> Host -> Bool Source #
Ord Host Source # |
Instance details Defined in Network.URL Methods compare :: Host -> Host -> Ordering Source # (<) :: Host -> Host -> Bool Source # (<=) :: Host -> Host -> Bool Source # (>) :: Host -> Host -> Bool Source # (>=) :: Host -> Host -> Bool Source # max :: Host -> Host -> Host Source # min :: Host -> Host -> Host Source #

data Protocol Source #

The type of known protocols.

Constructors

HTTP Bool |
FTP Bool |
RawProt String |

#### Instances

Instances details

Show Protocol Source # |
Instance details Defined in Network.URL Methods showsPrec :: Int -> Protocol -> ShowS Source # show :: Protocol -> String Source # showList :: [Protocol] -> ShowS Source #
Eq Protocol Source # |
Instance details Defined in Network.URL Methods (==) :: Protocol -> Protocol -> Bool Source # (/=) :: Protocol -> Protocol -> Bool Source #
Ord Protocol Source # |
Instance details Defined in Network.URL Methods compare :: Protocol -> Protocol -> Ordering Source # (<) :: Protocol -> Protocol -> Bool Source # (<=) :: Protocol -> Protocol -> Bool Source # (>) :: Protocol -> Protocol -> Bool Source # (>=) :: Protocol -> Protocol -> Bool Source # max :: Protocol -> Protocol -> Protocol Source # min :: Protocol -> Protocol -> Protocol Source #

secure :: Host -> Bool Source #

Does this host use a "secure" protocol (e.g., https).

secure_prot :: Protocol -> Bool Source #

Is this a "secure" protocol. This works only for known protocols, for `RawProt` values we return `False`.

exportURL :: URL -> String Source #

Convert a URL to a list of "bytes". We represent non-ASCII characters using UTF8.

importURL :: String -> Maybe URL Source #

Convert a list of "bytes" to a URL.

exportHost :: Host -> String Source #

Convert the host part of a URL to a list of "bytes".

add_param :: URL -> (String, String) -> URL Source #

Add a (key,value) parameter to a URL.

decString :: Bool -> String -> Maybe String Source #

Decode a list of "bytes" to a string. Performs % and UTF8 decoding.

encString :: Bool -> (Char -> Bool) -> String -> String Source #

Convert a string to bytes by escaping the characters that do not satisfy the input predicate. The first argument specifies if we should replace spaces with +.

ok_host :: Char -> Bool Source #

ok_url :: Char -> Bool Source #

Characters that do not need to be encoded in URL

ok_param :: Char -> Bool Source #

ok_path :: Char -> Bool Source #

Characters that can appear non % encoded in the path part of the URL

exportParams :: [(String, String)] -> String Source #

importParams :: String -> Maybe [(String, String)] Source #