Skip to content
Browse files

fix path prefix

Signed-off-by: Alexander Dorofeev <aka.spin@gmail.com>
  • Loading branch information...
1 parent 8f8af61 commit f3fb9f886a7a6a43a002480d79c15c519e0c78c0 @akaspin committed Mar 9, 2012
View
2 couchdb-conduit.cabal
@@ -1,5 +1,5 @@
name: couchdb-conduit
-version: 0.7.2
+version: 0.7.3
cabal-version: >= 1.8
build-type: Simple
stability: Stable
View
2 src/Database/CouchDB/Conduit/Internal/Connection.hs
@@ -71,7 +71,7 @@ type Revision = B.ByteString
-- | Make correct path and escape fragments. Filter empty fragments.
--
-- > mkPath ["db", "", "doc/with/slashes"]
--- > db/doc%2Fwith%2Fslashes
+-- > /db/doc%2Fwith%2Fslashes
mkPath :: [Path] -- ^ Path fragments be escaped.
-> Path
mkPath = BLB.toByteString . HT.encodePathSegments .
View
5 src/Database/CouchDB/Conduit/LowLevel.hs
@@ -33,6 +33,8 @@ import qualified Network.HTTP.Types as HT
import Database.CouchDB.Conduit.Internal.Connection
+import Control.Monad.IO.Class (liftIO)
+
-- | CouchDB response
type CouchResponse m = H.Response (Source m B.ByteString)
@@ -60,6 +62,7 @@ couch meth path hdrs qs reqBody protectFn = do
, H.queryString = HT.renderQuery False qs
, H.requestBody = reqBody
, H.checkStatus = const . const $ Nothing }
+ liftIO $ print $ withPrefix $ couchPrefix conn
-- Apply auth if needed
let req' = if couchLogin conn == B.empty then req else H.applyBasicAuth
(couchLogin conn) (couchPass conn) req
@@ -68,7 +71,7 @@ couch meth path hdrs qs reqBody protectFn = do
where
withPrefix prx
| B.null prx = path
- | otherwise = prx `B.append` path
+ | otherwise = "/" `B.append` prx `B.append` B.tail path
-- | Protect 'H.Response' from bad status codes. If status code in list
-- of status codes - just return response. Otherwise - throw 'CouchError'.
View
4 test/CouchDBAuth.hs
@@ -8,6 +8,6 @@ import Data.ByteString.Char8 () -- just orchan
login, pass :: ByteString
-- | Set your login
-login = ""
+login = "root"
-- | Set your pass
-pass = ""
+pass = "sumatra"
View
3 test/Database/CouchDB/Conduit/Test/Util.hs
@@ -19,4 +19,5 @@ tearDB n = runCouch conn $ couchDeleteDB n
conn :: CouchConnection
conn = def {
couchLogin = login,
- couchPass = pass}
+ couchPass = pass,
+ couchPrefix = "cct__"}

0 comments on commit f3fb9f8

Please sign in to comment.
Something went wrong with that request. Please try again.