uri-bytestring-0.4.0.1: Haskell URI parsing as ByteStrings

Copyright | (c) Soostone Inc. 2014-2015 Michael Xavier 2014-2015
License | BSD3
Maintainer | michael.xavier@soostone.com
Stability | experimental
Safe Haskell | None
Language | Haskell2010

URI.ByteString

Contents

- URI-related types
- Operations
- Parsing
- Serializing
  - Normalized Serialization
- Low level utility functions
- Lenses
  - Lenses over `Scheme`
  - Lenses over `Host`
  - Lenses over `Port`
  - Lenses over `Authority`
  - Lenses over `UserInfo`
  - Lenses over `Query`
  - Lenses over `URIRef`
  - Lenses over `URIParserOptions`
  - Deprecated

Description

URI.ByteString aims to be an RFC3986 compliant URI parser that uses efficient ByteStrings for parsing and representing the data. This module provides a URI datatype as well as a parser and serializer.

Note that this library is an early release and may have issues. It is currently being used in production and no issues have been encountered, however. Please report any issues encountered to the issue tracker.

This module also provides analogs to Lens over the various types in this library. These are written in a generic way to avoid a dependency on any particular lens library. You should be able to use these with a number of packages including lens and lens-family-core.

Synopsis

- newtype Scheme = Scheme {
  - schemeBS :: ByteString
  }
- newtype Host = Host {
  - hostBS :: ByteString
  }
- newtype Port = Port {
  - portNumber :: Int
  }
- data Authority = Authority {
  - authorityUserInfo :: Maybe UserInfo
  - authorityHost :: Host
  - authorityPort :: Maybe Port
  }
- data UserInfo = UserInfo {
  - uiUsername :: ByteString
  - uiPassword :: ByteString
  }
- newtype Query = Query {
  - queryPairs :: [(ByteString, ByteString)]
  }
- data URIRef a where
  - URI :: {..} -> URIRef Absolute
  - RelativeRef :: {..} -> URIRef Relative
- data Absolute
- data Relative
- data SchemaError
  - = NonAlphaLeading
  - | InvalidChars
  - | MissingColon
- data URIParseError
  - = MalformedScheme SchemaError
  - | MalformedUserInfo
  - | MalformedQuery
  - | MalformedFragment
  - | MalformedHost
  - | MalformedPort
  - | MalformedPath
  - | OtherError String
- data URIParserOptions = URIParserOptions {
  - upoLaxQueryParsing :: Bool
  }
- strictURIParserOptions :: URIParserOptions
- laxURIParserOptions :: URIParserOptions
- data URINormalizationOptions = URINormalizationOptions {
  - unoDowncaseScheme :: Bool
  - unoDowncaseHost :: Bool
  - unoDropDefPort :: Bool
  - unoSlashEmptyPath :: Bool
  - unoDropExtraSlashes :: Bool
  - unoSortParameters :: Bool
  - unoRemoveDotSegments :: Bool
  - unoDefaultPorts :: Map Scheme Port
  }
- noNormalization :: URINormalizationOptions
- rfc3986Normalization :: URINormalizationOptions
- httpNormalization :: URINormalizationOptions
- aggressiveNormalization :: URINormalizationOptions
- httpDefaultPorts :: Map Scheme Port
- toAbsolute :: Scheme -> URIRef a -> URIRef Absolute
- parseURI :: URIParserOptions -> ByteString -> Either URIParseError (URIRef Absolute)
- parseRelativeRef :: URIParserOptions -> ByteString -> Either URIParseError (URIRef Relative)
- uriParser :: URIParserOptions -> Parser (URIRef Absolute)
- relativeRefParser :: URIParserOptions -> Parser (URIRef Relative)
- serializeURIRef :: URIRef a -> Builder
- serializeURIRef' :: URIRef a -> ByteString
- serializeQuery :: URINormalizationOptions -> Query -> Builder
- serializeQuery' :: URINormalizationOptions -> Query -> ByteString
- serializeFragment :: Maybe ByteString -> Builder
- serializeFragment' :: Maybe ByteString -> ByteString
- serializeAuthority :: URINormalizationOptions -> Maybe Scheme -> Authority -> Builder
- serializeAuthority' :: URINormalizationOptions -> Maybe Scheme -> Authority -> ByteString
- serializeUserInfo :: UserInfo -> Builder
- serializeUserInfo' :: UserInfo -> ByteString
- normalizeURIRef :: URINormalizationOptions -> URIRef a -> Builder
- normalizeURIRef' :: URINormalizationOptions -> URIRef a -> ByteString
- urlEncodeQuery :: ByteString -> Builder
- urlEncodePath :: ByteString -> Builder
- urlEncode :: [Word8] -> ByteString -> Builder
- schemeBSL :: Lens' Scheme ByteString
- hostBSL :: Lens' Host ByteString
- portNumberL :: Lens' Port Int
- authorityUserInfoL :: Lens' Authority (Maybe UserInfo)
- authorityHostL :: Lens' Authority Host
- authorityPortL :: Lens' Authority (Maybe Port)
- uiUsernameL :: Lens' UserInfo ByteString
- uiPasswordL :: Lens' UserInfo ByteString
- queryPairsL :: Lens' Query [(ByteString, ByteString)]
- uriSchemeL :: Lens' (URIRef Absolute) Scheme
- authorityL :: forall a f. Functor f => (Maybe Authority -> f (Maybe Authority)) -> URIRef a -> f (URIRef a)
- pathL :: forall a f. Functor f => (ByteString -> f ByteString) -> URIRef a -> f (URIRef a)
- queryL :: forall a f. Functor f => (Query -> f Query) -> URIRef a -> f (URIRef a)
- fragmentL :: forall a f. Functor f => (Maybe ByteString -> f (Maybe ByteString)) -> URIRef a -> f (URIRef a)
- upoValidQueryCharL :: Lens' URIParserOptions Bool
- type URI = URIRef Absolute
- type RelativeRef = URIRef Relative
- serializeURI :: URIRef Absolute -> Builder
- serializeURI' :: URIRef Absolute -> ByteString
- serializeRelativeRef :: URIRef Relative -> Builder
- serializeRelativeRef' :: URIRef Relative -> ByteString
- uriAuthorityL :: Lens' URI (Maybe Authority)
- uriPathL :: Lens' URI ByteString
- uriQueryL :: Lens' URI Query
- uriFragmentL :: Lens' URI (Maybe ByteString)
- rrAuthorityL :: Lens' RelativeRef (Maybe Authority)
- rrPathL :: Lens' RelativeRef ByteString
- rrQueryL :: Lens' RelativeRef Query
- rrFragmentL :: Lens' RelativeRef (Maybe ByteString)

# URI-related types

newtype Scheme Source #

Required first component to referring to a specification for the remainder of the URI's components, e.g. "http" or "https"

Constructors

Scheme |

Fields

- schemeBS :: ByteString

#### Instances

Instances details

Generic Scheme Source # |

Instance details

Defined in URI.ByteString.Types

Associated Types

type Rep Scheme |
Instance details Defined in URI.ByteString.Types type Rep Scheme = D1 ('MetaData "Scheme" "URI.ByteString.Types" "uri-bytestring-0.4.0.1-5WAqvjUtsnB4agtrnfGEtf" 'True) (C1 ('MetaCons "Scheme" 'PrefixI 'True) (S1 ('MetaSel ('Just "schemeBS") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 ByteString)))

Methods

from :: Scheme -> Rep Scheme x Source #

to :: Rep Scheme x -> Scheme Source #

Show Scheme Source # |
Instance details Defined in URI.ByteString.Types Methods showsPrec :: Int -> Scheme -> ShowS Source # show :: Scheme -> String Source # showList :: [Scheme] -> ShowS Source #
Eq Scheme Source # |
Instance details Defined in URI.ByteString.Types Methods (==) :: Scheme -> Scheme -> Bool Source # (/=) :: Scheme -> Scheme -> Bool Source #
Ord Scheme Source # |
Instance details Defined in URI.ByteString.Types Methods compare :: Scheme -> Scheme -> Ordering Source # (<) :: Scheme -> Scheme -> Bool Source # (<=) :: Scheme -> Scheme -> Bool Source # (>) :: Scheme -> Scheme -> Bool Source # (>=) :: Scheme -> Scheme -> Bool Source # max :: Scheme -> Scheme -> Scheme Source # min :: Scheme -> Scheme -> Scheme Source #
Lift Scheme Source # |
Instance details Defined in URI.ByteString.Types Methods lift :: Quote m => Scheme -> m Exp Source # liftTyped :: forall (m :: Type -> Type). Quote m => Scheme -> Code m Scheme Source #
type Rep Scheme Source # |
Instance details Defined in URI.ByteString.Types type Rep Scheme = D1 ('MetaData "Scheme" "URI.ByteString.Types" "uri-bytestring-0.4.0.1-5WAqvjUtsnB4agtrnfGEtf" 'True) (C1 ('MetaCons "Scheme" 'PrefixI 'True) (S1 ('MetaSel ('Just "schemeBS") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 ByteString)))

newtype Host Source #

Constructors

Host |

Fields

- hostBS :: ByteString

#### Instances

Instances details

Generic Host Source # |

Instance details

Defined in URI.ByteString.Types

Associated Types

type Rep Host |
Instance details Defined in URI.ByteString.Types type Rep Host = D1 ('MetaData "Host" "URI.ByteString.Types" "uri-bytestring-0.4.0.1-5WAqvjUtsnB4agtrnfGEtf" 'True) (C1 ('MetaCons "Host" 'PrefixI 'True) (S1 ('MetaSel ('Just "hostBS") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 ByteString)))

Methods

from :: Host -> Rep Host x Source #

to :: Rep Host x -> Host Source #

Show Host Source # |
Instance details Defined in URI.ByteString.Types Methods showsPrec :: Int -> Host -> ShowS Source # show :: Host -> String Source # showList :: [Host] -> ShowS Source #
Eq Host Source # |
Instance details Defined in URI.ByteString.Types Methods (==) :: Host -> Host -> Bool Source # (/=) :: Host -> Host -> Bool Source #
Ord Host Source # |
Instance details Defined in URI.ByteString.Types 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 #
Lift Host Source # |
Instance details Defined in URI.ByteString.Types Methods lift :: Quote m => Host -> m Exp Source # liftTyped :: forall (m :: Type -> Type). Quote m => Host -> Code m Host Source #
type Rep Host Source # |
Instance details Defined in URI.ByteString.Types type Rep Host = D1 ('MetaData "Host" "URI.ByteString.Types" "uri-bytestring-0.4.0.1-5WAqvjUtsnB4agtrnfGEtf" 'True) (C1 ('MetaCons "Host" 'PrefixI 'True) (S1 ('MetaSel ('Just "hostBS") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 ByteString)))

newtype Port Source #

While some libraries have chosen to limit this to a Word16, the spec only specifies that the string be comprised of digits.

Constructors

Port |

Fields

- portNumber :: Int

#### Instances

Instances details

Generic Port Source # |

Instance details

Defined in URI.ByteString.Types

Associated Types

type Rep Port |
Instance details Defined in URI.ByteString.Types type Rep Port = D1 ('MetaData "Port" "URI.ByteString.Types" "uri-bytestring-0.4.0.1-5WAqvjUtsnB4agtrnfGEtf" 'True) (C1 ('MetaCons "Port" 'PrefixI 'True) (S1 ('MetaSel ('Just "portNumber") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Int)))

Methods

from :: Port -> Rep Port x Source #

to :: Rep Port x -> Port Source #

Show Port Source # |
Instance details Defined in URI.ByteString.Types Methods showsPrec :: Int -> Port -> ShowS Source # show :: Port -> String Source # showList :: [Port] -> ShowS Source #
Eq Port Source # |
Instance details Defined in URI.ByteString.Types Methods (==) :: Port -> Port -> Bool Source # (/=) :: Port -> Port -> Bool Source #
Ord Port Source # |
Instance details Defined in URI.ByteString.Types Methods compare :: Port -> Port -> Ordering Source # (<) :: Port -> Port -> Bool Source # (<=) :: Port -> Port -> Bool Source # (>) :: Port -> Port -> Bool Source # (>=) :: Port -> Port -> Bool Source # max :: Port -> Port -> Port Source # min :: Port -> Port -> Port Source #
Lift Port Source # |
Instance details Defined in URI.ByteString.Types Methods lift :: Quote m => Port -> m Exp Source # liftTyped :: forall (m :: Type -> Type). Quote m => Port -> Code m Port Source #
type Rep Port Source # |
Instance details Defined in URI.ByteString.Types type Rep Port = D1 ('MetaData "Port" "URI.ByteString.Types" "uri-bytestring-0.4.0.1-5WAqvjUtsnB4agtrnfGEtf" 'True) (C1 ('MetaCons "Port" 'PrefixI 'True) (S1 ('MetaSel ('Just "portNumber") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Int)))

data Authority Source #

Constructors

Authority |

Fields

- authorityUserInfo :: Maybe UserInfo
- authorityHost :: Host
- authorityPort :: Maybe Port

#### Instances

Instances details

Generic Authority Source # |

Instance details

Defined in URI.ByteString.Types

Associated Types

type Rep Authority |

Instance details

Defined in URI.ByteString.Types

type Rep Authority = D1 ('MetaData "Authority" "URI.ByteString.Types" "uri-bytestring-0.4.0.1-5WAqvjUtsnB4agtrnfGEtf" 'False) (C1 ('MetaCons "Authority" 'PrefixI 'True) (S1 ('MetaSel ('Just "authorityUserInfo") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Maybe UserInfo)) :*: (S1 ('MetaSel ('Just "authorityHost") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Host) :*: S1 ('MetaSel ('Just "authorityPort") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Maybe Port)))))

Methods

from :: Authority -> Rep Authority x Source #

to :: Rep Authority x -> Authority Source #

Show Authority Source # |
Instance details Defined in URI.ByteString.Types Methods showsPrec :: Int -> Authority -> ShowS Source # show :: Authority -> String Source # showList :: [Authority] -> ShowS Source #
Eq Authority Source # |
Instance details Defined in URI.ByteString.Types Methods (==) :: Authority -> Authority -> Bool Source # (/=) :: Authority -> Authority -> Bool Source #
Ord Authority Source # |

Instance details

Defined in URI.ByteString.Types

Methods

compare :: Authority -> Authority -> Ordering Source #

(<) :: Authority -> Authority -> Bool Source #

(<=) :: Authority -> Authority -> Bool Source #

(>) :: Authority -> Authority -> Bool Source #

(>=) :: Authority -> Authority -> Bool Source #

max :: Authority -> Authority -> Authority Source #

min :: Authority -> Authority -> Authority Source #

Lift Authority Source # |
Instance details Defined in URI.ByteString.Types Methods lift :: Quote m => Authority -> m Exp Source # liftTyped :: forall (m :: Type -> Type). Quote m => Authority -> Code m Authority Source #
type Rep Authority Source # |

Instance details

Defined in URI.ByteString.Types

type Rep Authority = D1 ('MetaData "Authority" "URI.ByteString.Types" "uri-bytestring-0.4.0.1-5WAqvjUtsnB4agtrnfGEtf" 'False) (C1 ('MetaCons "Authority" 'PrefixI 'True) (S1 ('MetaSel ('Just "authorityUserInfo") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Maybe UserInfo)) :*: (S1 ('MetaSel ('Just "authorityHost") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Host) :*: S1 ('MetaSel ('Just "authorityPort") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Maybe Port)))))

data UserInfo Source #

Constructors

UserInfo |

Fields

- uiUsername :: ByteString
- uiPassword :: ByteString

#### Instances

Instances details

Generic UserInfo Source # |

Instance details

Defined in URI.ByteString.Types

Associated Types

type Rep UserInfo |

Instance details

Defined in URI.ByteString.Types

type Rep UserInfo = D1 ('MetaData "UserInfo" "URI.ByteString.Types" "uri-bytestring-0.4.0.1-5WAqvjUtsnB4agtrnfGEtf" 'False) (C1 ('MetaCons "UserInfo" 'PrefixI 'True) (S1 ('MetaSel ('Just "uiUsername") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 ByteString) :*: S1 ('MetaSel ('Just "uiPassword") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 ByteString)))

Methods

from :: UserInfo -> Rep UserInfo x Source #

to :: Rep UserInfo x -> UserInfo Source #

Show UserInfo Source # |
Instance details Defined in URI.ByteString.Types Methods showsPrec :: Int -> UserInfo -> ShowS Source # show :: UserInfo -> String Source # showList :: [UserInfo] -> ShowS Source #
Eq UserInfo Source # |
Instance details Defined in URI.ByteString.Types Methods (==) :: UserInfo -> UserInfo -> Bool Source # (/=) :: UserInfo -> UserInfo -> Bool Source #
Ord UserInfo Source # |
Instance details Defined in URI.ByteString.Types Methods compare :: UserInfo -> UserInfo -> Ordering Source # (<) :: UserInfo -> UserInfo -> Bool Source # (<=) :: UserInfo -> UserInfo -> Bool Source # (>) :: UserInfo -> UserInfo -> Bool Source # (>=) :: UserInfo -> UserInfo -> Bool Source # max :: UserInfo -> UserInfo -> UserInfo Source # min :: UserInfo -> UserInfo -> UserInfo Source #
Lift UserInfo Source # |
Instance details Defined in URI.ByteString.Types Methods lift :: Quote m => UserInfo -> m Exp Source # liftTyped :: forall (m :: Type -> Type). Quote m => UserInfo -> Code m UserInfo Source #
type Rep UserInfo Source # |

Instance details

Defined in URI.ByteString.Types

type Rep UserInfo = D1 ('MetaData "UserInfo" "URI.ByteString.Types" "uri-bytestring-0.4.0.1-5WAqvjUtsnB4agtrnfGEtf" 'False) (C1 ('MetaCons "UserInfo" 'PrefixI 'True) (S1 ('MetaSel ('Just "uiUsername") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 ByteString) :*: S1 ('MetaSel ('Just "uiPassword") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 ByteString)))

newtype Query Source #

Constructors

Query |

Fields

- queryPairs :: [(ByteString, ByteString)]

#### Instances

Instances details

Monoid Query Source # |
Instance details Defined in URI.ByteString.Types Methods mempty :: Query Source # mappend :: Query -> Query -> Query Source # mconcat :: [Query] -> Query Source #
Semigroup Query Source # |
Instance details Defined in URI.ByteString.Types Methods (<>) :: Query -> Query -> Query Source # sconcat :: NonEmpty Query -> Query Source # stimes :: Integral b => b -> Query -> Query Source #
Generic Query Source # |

Instance details

Defined in URI.ByteString.Types

Associated Types

type Rep Query |
Instance details Defined in URI.ByteString.Types type Rep Query = D1 ('MetaData "Query" "URI.ByteString.Types" "uri-bytestring-0.4.0.1-5WAqvjUtsnB4agtrnfGEtf" 'True) (C1 ('MetaCons "Query" 'PrefixI 'True) (S1 ('MetaSel ('Just "queryPairs") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 [(ByteString, ByteString)])))

Methods

from :: Query -> Rep Query x Source #

to :: Rep Query x -> Query Source #

Show Query Source # |
Instance details Defined in URI.ByteString.Types Methods showsPrec :: Int -> Query -> ShowS Source # show :: Query -> String Source # showList :: [Query] -> ShowS Source #
Eq Query Source # |
Instance details Defined in URI.ByteString.Types Methods (==) :: Query -> Query -> Bool Source # (/=) :: Query -> Query -> Bool Source #
Ord Query Source # |
Instance details Defined in URI.ByteString.Types Methods compare :: Query -> Query -> Ordering Source # (<) :: Query -> Query -> Bool Source # (<=) :: Query -> Query -> Bool Source # (>) :: Query -> Query -> Bool Source # (>=) :: Query -> Query -> Bool Source # max :: Query -> Query -> Query Source # min :: Query -> Query -> Query Source #
Lift Query Source # |
Instance details Defined in URI.ByteString.Types Methods lift :: Quote m => Query -> m Exp Source # liftTyped :: forall (m :: Type -> Type). Quote m => Query -> Code m Query Source #
type Rep Query Source # |
Instance details Defined in URI.ByteString.Types type Rep Query = D1 ('MetaData "Query" "URI.ByteString.Types" "uri-bytestring-0.4.0.1-5WAqvjUtsnB4agtrnfGEtf" 'True) (C1 ('MetaCons "Query" 'PrefixI 'True) (S1 ('MetaSel ('Just "queryPairs") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 [(ByteString, ByteString)])))

data URIRef a where Source #

Note: URI fragment does not include the #

Constructors

URI |

Fields

- :: { uriScheme :: Scheme
- , uriAuthority :: Maybe Authority
- , uriPath :: ByteString
- , uriQuery :: Query
- , uriFragment :: Maybe ByteString
- } -> URIRef Absolute

RelativeRef |

Fields

- :: { rrAuthority :: Maybe Authority
- , rrPath :: ByteString
- , rrQuery :: Query
- , rrFragment :: Maybe ByteString
- } -> URIRef Relative

#### Instances

Instances details

Lift (URIRef a :: Type) Source # |
Instance details Defined in URI.ByteString.Types Methods lift :: Quote m => URIRef a -> m Exp Source # liftTyped :: forall (m :: Type -> Type). Quote m => URIRef a -> Code m (URIRef a) Source #
Show (URIRef a) Source # |
Instance details Defined in URI.ByteString.Types Methods showsPrec :: Int -> URIRef a -> ShowS Source # show :: URIRef a -> String Source # showList :: [URIRef a] -> ShowS Source #
Eq (URIRef a) Source # |
Instance details Defined in URI.ByteString.Types Methods (==) :: URIRef a -> URIRef a -> Bool Source # (/=) :: URIRef a -> URIRef a -> Bool Source #
Ord (URIRef a) Source # |
Instance details Defined in URI.ByteString.Types Methods compare :: URIRef a -> URIRef a -> Ordering Source # (<) :: URIRef a -> URIRef a -> Bool Source # (<=) :: URIRef a -> URIRef a -> Bool Source # (>) :: URIRef a -> URIRef a -> Bool Source # (>=) :: URIRef a -> URIRef a -> Bool Source # max :: URIRef a -> URIRef a -> URIRef a Source # min :: URIRef a -> URIRef a -> URIRef a Source #

data Absolute Source #

#### Instances

Instances details

Lift Absolute Source # |
Instance details Defined in URI.ByteString.Types Methods lift :: Quote m => Absolute -> m Exp Source # liftTyped :: forall (m :: Type -> Type). Quote m => Absolute -> Code m Absolute Source #

data Relative Source #

#### Instances

Instances details

Lift Relative Source # |
Instance details Defined in URI.ByteString.Types Methods lift :: Quote m => Relative -> m Exp Source # liftTyped :: forall (m :: Type -> Type). Quote m => Relative -> Code m Relative Source #

data SchemaError Source #

URI Parser Types

Constructors

NonAlphaLeading | Scheme must start with an alphabet character
InvalidChars | Subsequent characters in the schema were invalid
MissingColon | Schemas must be followed by a colon

#### Instances

Instances details

Bounded SchemaError Source # |
Instance details Defined in URI.ByteString.Types Methods minBound :: SchemaError Source # maxBound :: SchemaError Source #
Enum SchemaError Source # |

Instance details

Defined in URI.ByteString.Types

Methods

succ :: SchemaError -> SchemaError Source #

pred :: SchemaError -> SchemaError Source #

toEnum :: Int -> SchemaError Source #

fromEnum :: SchemaError -> Int Source #

enumFrom :: SchemaError -> [SchemaError] Source #

enumFromThen :: SchemaError -> SchemaError -> [SchemaError] Source #

enumFromTo :: SchemaError -> SchemaError -> [SchemaError] Source #

enumFromThenTo :: SchemaError -> SchemaError -> SchemaError -> [SchemaError] Source #

Generic SchemaError Source # |

Instance details

Defined in URI.ByteString.Types

Associated Types

type Rep SchemaError |
Instance details Defined in URI.ByteString.Types type Rep SchemaError = D1 ('MetaData "SchemaError" "URI.ByteString.Types" "uri-bytestring-0.4.0.1-5WAqvjUtsnB4agtrnfGEtf" 'False) (C1 ('MetaCons "NonAlphaLeading" 'PrefixI 'False) (U1 :: Type -> Type) :+: (C1 ('MetaCons "InvalidChars" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "MissingColon" 'PrefixI 'False) (U1 :: Type -> Type)))

Methods

from :: SchemaError -> Rep SchemaError x Source #

to :: Rep SchemaError x -> SchemaError Source #

Read SchemaError Source # |
Instance details Defined in URI.ByteString.Types Methods readsPrec :: Int -> ReadS SchemaError Source # readList :: ReadS [SchemaError] Source # readPrec :: ReadPrec SchemaError Source # readListPrec :: ReadPrec [SchemaError] Source #
Show SchemaError Source # |
Instance details Defined in URI.ByteString.Types Methods showsPrec :: Int -> SchemaError -> ShowS Source # show :: SchemaError -> String Source # showList :: [SchemaError] -> ShowS Source #
Eq SchemaError Source # |
Instance details Defined in URI.ByteString.Types Methods (==) :: SchemaError -> SchemaError -> Bool Source # (/=) :: SchemaError -> SchemaError -> Bool Source #
type Rep SchemaError Source # |
Instance details Defined in URI.ByteString.Types type Rep SchemaError = D1 ('MetaData "SchemaError" "URI.ByteString.Types" "uri-bytestring-0.4.0.1-5WAqvjUtsnB4agtrnfGEtf" 'False) (C1 ('MetaCons "NonAlphaLeading" 'PrefixI 'False) (U1 :: Type -> Type) :+: (C1 ('MetaCons "InvalidChars" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "MissingColon" 'PrefixI 'False) (U1 :: Type -> Type)))

data URIParseError Source #

Constructors

MalformedScheme SchemaError |
MalformedUserInfo |
MalformedQuery |
MalformedFragment |
MalformedHost |
MalformedPort |
MalformedPath |
OtherError String | Catchall for unpredictable errors

#### Instances

Instances details

Generic URIParseError Source # |

Instance details

Defined in URI.ByteString.Types

Associated Types

type Rep URIParseError |

Instance details

Defined in URI.ByteString.Types

type Rep URIParseError = D1 ('MetaData "URIParseError" "URI.ByteString.Types" "uri-bytestring-0.4.0.1-5WAqvjUtsnB4agtrnfGEtf" 'False) (((C1 ('MetaCons "MalformedScheme" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 SchemaError)) :+: C1 ('MetaCons "MalformedUserInfo" 'PrefixI 'False) (U1 :: Type -> Type)) :+: (C1 ('MetaCons "MalformedQuery" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "MalformedFragment" 'PrefixI 'False) (U1 :: Type -> Type))) :+: ((C1 ('MetaCons "MalformedHost" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "MalformedPort" 'PrefixI 'False) (U1 :: Type -> Type)) :+: (C1 ('MetaCons "MalformedPath" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "OtherError" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 String)))))

Methods

from :: URIParseError -> Rep URIParseError x Source #

to :: Rep URIParseError x -> URIParseError Source #

Read URIParseError Source # |
Instance details Defined in URI.ByteString.Types Methods readsPrec :: Int -> ReadS URIParseError Source # readList :: ReadS [URIParseError] Source # readPrec :: ReadPrec URIParseError Source # readListPrec :: ReadPrec [URIParseError] Source #
Show URIParseError Source # |
Instance details Defined in URI.ByteString.Types Methods showsPrec :: Int -> URIParseError -> ShowS Source # show :: URIParseError -> String Source # showList :: [URIParseError] -> ShowS Source #
Eq URIParseError Source # |
Instance details Defined in URI.ByteString.Types Methods (==) :: URIParseError -> URIParseError -> Bool Source # (/=) :: URIParseError -> URIParseError -> Bool Source #
type Rep URIParseError Source # |

Instance details

Defined in URI.ByteString.Types

type Rep URIParseError = D1 ('MetaData "URIParseError" "URI.ByteString.Types" "uri-bytestring-0.4.0.1-5WAqvjUtsnB4agtrnfGEtf" 'False) (((C1 ('MetaCons "MalformedScheme" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 SchemaError)) :+: C1 ('MetaCons "MalformedUserInfo" 'PrefixI 'False) (U1 :: Type -> Type)) :+: (C1 ('MetaCons "MalformedQuery" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "MalformedFragment" 'PrefixI 'False) (U1 :: Type -> Type))) :+: ((C1 ('MetaCons "MalformedHost" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "MalformedPort" 'PrefixI 'False) (U1 :: Type -> Type)) :+: (C1 ('MetaCons "MalformedPath" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "OtherError" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 String)))))

data URIParserOptions Source #

Options for the parser. You will probably want to use either "strictURIParserOptions" or "laxURIParserOptions"

Constructors

URIParserOptions |

Fields

- upoLaxQueryParsing :: Bool

strictURIParserOptions :: URIParserOptions Source #

Strict URI Parser config. Follows RFC3986 as-specified. Use this if you can be certain that your URIs are properly encoded or if you want parsing to fail if they deviate from the spec at all.

laxURIParserOptions :: URIParserOptions Source #

Lax URI Parser config. Use this if you you want to handle common deviations from the spec gracefully.

- Allows non-encoded [ and ] in query string

data URINormalizationOptions Source #

Constructors

URINormalizationOptions |

Fields

- unoDowncaseScheme :: Bool

  hTtP -> http

- unoDowncaseHost :: Bool

  eXaMpLe.org -> example.org

- unoDropDefPort :: Bool

  If the scheme is known and the port is the default (e.g. 80 for http) it is removed.

- unoSlashEmptyPath :: Bool

  If the path is empty, set it to /

- unoDropExtraSlashes :: Bool

  Rewrite path from /foo//bar///baz to /foo/bar/baz

- unoSortParameters :: Bool

  Sorts parameters by parameter name

- unoRemoveDotSegments :: Bool

  Remove dot segments as per RFC3986 Section 5.2.4

- unoDefaultPorts :: Map Scheme Port

  Map of known schemes to their default ports. Used when `unoDropDefPort` is enabled.

#### Instances

Instances details

Show URINormalizationOptions Source # |
Instance details Defined in URI.ByteString.Types Methods showsPrec :: Int -> URINormalizationOptions -> ShowS Source # show :: URINormalizationOptions -> String Source # showList :: [URINormalizationOptions] -> ShowS Source #
Eq URINormalizationOptions Source # |
Instance details Defined in URI.ByteString.Types Methods (==) :: URINormalizationOptions -> URINormalizationOptions -> Bool Source # (/=) :: URINormalizationOptions -> URINormalizationOptions -> Bool Source #

noNormalization :: URINormalizationOptions Source #

All normalization options disabled

rfc3986Normalization :: URINormalizationOptions Source #

Only normalizations deemed appropriate for all protocols by RFC3986 enabled, namely:

- Downcase Scheme
- Downcase Host
- Remove Dot Segments

httpNormalization :: URINormalizationOptions Source #

The same as `rfc3986Normalization` but with additional enabled features if you're working with HTTP URIs:

- Drop Default Port (with `httpDefaultPorts`)
- Drop Extra Slashes

aggressiveNormalization :: URINormalizationOptions Source #

All options enabled

httpDefaultPorts :: Map Scheme Port Source #

The set of known default ports to schemes. Currently only contains http/80 and https/443. Feel free to extend it if needed with `unoDefaultPorts`.

# Operations

toAbsolute :: Scheme -> URIRef a -> URIRef Absolute Source #

`toAbsolute scheme ref` converts `ref` to an absolute URI. If `ref` is already absolute, then it is unchanged.

# Parsing

parseURI :: URIParserOptions -> ByteString -> Either URIParseError (URIRef Absolute) Source #

Parse a strict ByteString into a URI or an error.

Example:

    >>> parseURI strictURIParserOptions "http://www.example.org/foo?bar=baz#quux"
    Right (URI {uriScheme = Scheme {schemeBS = "http"}, uriAuthority = Just (Authority {authorityUserInfo = Nothing, authorityHost = Host {hostBS = "www.example.org"}, authorityPort = Nothing}), uriPath = "/foo", uriQuery = Query {queryPairs = [("bar","baz")]}, uriFragment = Just "quux"})

    >>> parseURI strictURIParserOptions "$$$$://badurl.example.org"
    Left (MalformedScheme NonAlphaLeading)

There are some urls that you'll encounter which defy the spec, such as those with square brackets in the query string. If you must be able to parse those, you can use "laxURIParserOptions" or specify your own

    >>> parseURI strictURIParserOptions "http://www.example.org/foo?bar[]=baz"
    Left MalformedQuery

    >>> parseURI laxURIParserOptions "http://www.example.org/foo?bar[]=baz"
    Right (URI {uriScheme = Scheme {schemeBS = "http"}, uriAuthority = Just (Authority {authorityUserInfo = Nothing, authorityHost = Host {hostBS = "www.example.org"}, authorityPort = Nothing}), uriPath = "/foo", uriQuery = Query {queryPairs = [("bar[]","baz")]}, uriFragment = Nothing})

    >>> let myLaxOptions = URIParserOptions { upoValidQueryChar = liftA2 (||) (upoValidQueryChar strictURIParserOptions) (inClass "[]")}
    >>> parseURI myLaxOptions "http://www.example.org/foo?bar[]=baz"
    Right (URI {uriScheme = Scheme {schemeBS = "http"}, uriAuthority = Just (Authority {authorityUserInfo = Nothing, authorityHost = Host {hostBS = "www.example.org"}, authorityPort = Nothing}), uriPath = "/foo", uriQuery = Query {queryPairs = [("bar[]","baz")]}, uriFragment = Nothing})

parseRelativeRef :: URIParserOptions -> ByteString -> Either URIParseError (URIRef Relative) Source #

Like `parseURI`, but do not parse scheme.

uriParser :: URIParserOptions -> Parser (URIRef Absolute) Source #

Underlying attoparsec parser. Useful for composing with your own parsers.

relativeRefParser :: URIParserOptions -> Parser (URIRef Relative) Source #

Underlying attoparsec parser. Useful for composing with your own parsers.

# Serializing

serializeURIRef :: URIRef a -> Builder Source #

URI Serializer

Serialize a URI reference into a `Builder`.

Example of serializing + converting to a lazy Data.ByteString.Lazy.ByteString:

    >>> BB.toLazyByteString $ serializeURIRef $ URI {uriScheme = Scheme {schemeBS = "http"}, uriAuthority = Just (Authority {authorityUserInfo = Nothing, authorityHost = Host {hostBS = "www.example.org"}, authorityPort = Nothing}), uriPath = "/foo", uriQuery = Query {queryPairs = [("bar","baz")]}, uriFragment = Just "quux"}
    "http://www.example.org/foo?bar=baz#quux"

serializeURIRef' :: URIRef a -> ByteString Source #

Like `serializeURIRef`, with conversion into a strict `ByteString`.

serializeQuery :: URINormalizationOptions -> Query -> Builder Source #

Serialize the query part of a url `serializeQuery opts mempty = ""` `serializeQuery opts (Query [("a","b"),("c","d")]) = "?a=b&c=d"`

serializeQuery' :: URINormalizationOptions -> Query -> ByteString Source #

serializeFragment :: Maybe ByteString -> Builder Source #

serializeFragment' :: Maybe ByteString -> ByteString Source #

serializeAuthority :: URINormalizationOptions -> Maybe Scheme -> Authority -> Builder Source #

serializeAuthority' :: URINormalizationOptions -> Maybe Scheme -> Authority -> ByteString Source #

serializeUserInfo :: UserInfo -> Builder Source #

serializeUserInfo' :: UserInfo -> ByteString Source #

## Normalized Serialization

normalizeURIRef :: URINormalizationOptions -> URIRef a -> Builder Source #

Similar to `serializeURIRef` but performs configurable degrees of URI normalization. If your goal is the fastest serialization speed possible, `serializeURIRef` will be fine. If you intend on comparing URIs (say for caching purposes), you'll want to use this.

normalizeURIRef' :: URINormalizationOptions -> URIRef a -> ByteString Source #

# Low level utility functions

urlEncodeQuery :: ByteString -> Builder Source #

Encode a ByteString for use in the query section of a URL

urlEncodePath :: ByteString -> Builder Source #

Encode a ByteString for use in the path section of a URL

urlEncode :: [Word8] -> ByteString -> Builder Source #

Percent-encoding for URLs. Specify a list of additional unreserved characters to permit.

# Lenses

## Lenses over `Scheme`

schemeBSL :: Lens' Scheme ByteString Source #

## Lenses over `Host`

hostBSL :: Lens' Host ByteString Source #

## Lenses over `Port`

portNumberL :: Lens' Port Int Source #

## Lenses over `Authority`

authorityUserInfoL :: Lens' Authority (Maybe UserInfo) Source #

authorityHostL :: Lens' Authority Host Source #

authorityPortL :: Lens' Authority (Maybe Port) Source #

## Lenses over `UserInfo`

uiUsernameL :: Lens' UserInfo ByteString Source #

uiPasswordL :: Lens' UserInfo ByteString Source #

## Lenses over `Query`

queryPairsL :: Lens' Query [(ByteString, ByteString)] Source #

## Lenses over `URIRef`

uriSchemeL :: Lens' (URIRef Absolute) Scheme Source #

authorityL :: forall a f. Functor f => (Maybe Authority -> f (Maybe Authority)) -> URIRef a -> f (URIRef a) Source #

pathL :: forall a f. Functor f => (ByteString -> f ByteString) -> URIRef a -> f (URIRef a) Source #

queryL :: forall a f. Functor f => (Query -> f Query) -> URIRef a -> f (URIRef a) Source #

fragmentL :: forall a f. Functor f => (Maybe ByteString -> f (Maybe ByteString)) -> URIRef a -> f (URIRef a) Source #

## Lenses over `URIParserOptions`

upoValidQueryCharL :: Lens' URIParserOptions Bool Source #

## Deprecated

type URI = URIRef Absolute Source #

type RelativeRef = URIRef Relative Source #

serializeURI :: URIRef Absolute -> Builder Source #

Deprecated: Use `serializeURIRef` instead

Serialize a URI into a Builder.

serializeURI' :: URIRef Absolute -> ByteString Source #

Deprecated: Use `serializeURIRef'` instead

Like `serializeURI`, with conversion into a strict `ByteString`.

serializeRelativeRef :: URIRef Relative -> Builder Source #

Deprecated: Use `serializeURIRef` instead

Like `serializeURI`, but do not render scheme.

serializeRelativeRef' :: URIRef Relative -> ByteString Source #

Deprecated: Use `serializeURIRef'` instead

Like `serializeRelativeRef`, with conversion into a strict `ByteString`.

uriAuthorityL :: Lens' URI (Maybe Authority) Source #

Deprecated: Use `authorityL` instead

uriPathL :: Lens' URI ByteString Source #

Deprecated: Use `pathL` instead

uriQueryL :: Lens' URI Query Source #

Deprecated: Use `queryL` instead

uriFragmentL :: Lens' URI (Maybe ByteString) Source #

Deprecated: Use `fragmentL` instead

rrAuthorityL :: Lens' RelativeRef (Maybe Authority) Source #

Deprecated: Use `authorityL` instead

rrPathL :: Lens' RelativeRef ByteString Source #

Deprecated: Use `pathL` instead

rrQueryL :: Lens' RelativeRef Query Source #

Deprecated: Use `queryL` instead

rrFragmentL :: Lens' RelativeRef (Maybe ByteString) Source #

Deprecated: Use `fragmentL` instead