@@ -66,7 +66,6 @@ import Control.Monad.IO.Class
6666import Data.Aeson
6767import Data.ByteString.Lazy.Builder
6868import qualified Data.ByteString.Lazy.Char8 as L
69−import Data.Default.Class
7069import Data.Ix
7170import qualified Data.List as LS (filter)
7271import Data.Maybe (fromMaybe, isJust)
@@ -79,8 +78,8 @@ import Network.HTTP.Client
7978import qualified Network.HTTP.Types.Method as NHTM
8079import qualified Network.HTTP.Types.Status as NHTS
8180import qualified Network.HTTP.Types.URI as NHTU
81+import qualified Network.URI as URI
8282import Prelude hiding (filter, head)
83−import URI.ByteString hiding (Query)
8483
8584import Database.Bloodhound.Types
8685
@@ -631,32 +630,7 @@ pageSearch :: From -- ^ The result offset
631630pageSearch resultOffset pageSize search = search { from = resultOffset, size = pageSize }
632631
633632parseUrl' :: MonadThrow m => Text -> m Request
634−parseUrl' t =
635− case parseURI laxURIParserOptions (T.encodeUtf8 t) of
636− Right uri -> setURI def uri
637− Left e -> throwM $ InvalidUrlException (T.unpack t) ("Invalid URL: " ++ show e)
638−
639−setURI :: MonadThrow m => Request -> URI -> m Request
640−setURI req URI{..} = do
641− Authority {..} <- maybe missingUA return uriAuthority
642− let req' = req { secure = isSecure
643− , host = hostBS authorityHost
644− , port = thePort
645− , path = uriPath
646− }
647− thePort = maybe defPort portNumber authorityPort
648− addAuth = maybe id addAuth' authorityUserInfo
649− return $ setQueryString theQueryString $ addAuth req'
650− where
651− missingUA = throwM $ InvalidUrlException "N/A" "Missing URI host/port"
652− addAuth' UserInfo {..} = applyBasicProxyAuth uiUsername uiPassword
653− defPort
654− | isSecure = 443
655− | otherwise = 80
656− isSecure = case uriScheme of
657− Scheme "https" -> True
658− _ -> False
659− theQueryString = [(k , Just v) | (k, v) <- queryPairs uriQuery]
633+parseUrl' t = parseUrl (URI.escapeURIString URI.isAllowedInURI (T.unpack t))
660634
661635-- | Was there an optimistic concurrency control conflict when
662636-- indexing a document?