simplify
This commit is contained in:
parent
2228d56db3
commit
14e0f778b7
2 changed files with 14 additions and 23 deletions
32
P2P/Http.hs
32
P2P/Http.hs
|
@ -264,8 +264,8 @@ clientGet
|
||||||
-> Maybe Offset
|
-> Maybe Offset
|
||||||
-> Maybe Auth
|
-> Maybe Auth
|
||||||
-> IO ()
|
-> IO ()
|
||||||
clientGet clientenv ver k su cu bypass af o auth =
|
clientGet clientenv (ProtocolVersion ver) k su cu bypass af o auth =
|
||||||
withClientM (clientGet' su ver k cu bypass af o auth) clientenv $ \case
|
withClientM (cli k cu bypass af o auth) clientenv $ \case
|
||||||
Left err -> throwM err
|
Left err -> throwM err
|
||||||
Right respheaders -> do
|
Right respheaders -> do
|
||||||
let dl = case lookupResponseHeader @DataLengthHeader' respheaders of
|
let dl = case lookupResponseHeader @DataLengthHeader' respheaders of
|
||||||
|
@ -275,6 +275,15 @@ clientGet clientenv ver k su cu bypass af o auth =
|
||||||
b <- S.unSourceT (getResponse respheaders) gatherByteString
|
b <- S.unSourceT (getResponse respheaders) gatherByteString
|
||||||
liftIO $ print "got it all, writing to file 'got'"
|
liftIO $ print "got it all, writing to file 'got'"
|
||||||
L.writeFile "got" b
|
L.writeFile "got" b
|
||||||
|
where
|
||||||
|
cli =case ver of
|
||||||
|
3 -> v3 su V3
|
||||||
|
2 -> v2 su V2
|
||||||
|
1 -> v1 su V1
|
||||||
|
0 -> v0 su V0
|
||||||
|
_ -> error "unsupported protocol version"
|
||||||
|
|
||||||
|
v3 :<|> v2 :<|> v1 :<|> v0 :<|> _ = client p2pHttpAPI
|
||||||
|
|
||||||
gatherByteString :: S.StepT IO B.ByteString -> IO L.ByteString
|
gatherByteString :: S.StepT IO B.ByteString -> IO L.ByteString
|
||||||
gatherByteString = unsafeInterleaveIO . go
|
gatherByteString = unsafeInterleaveIO . go
|
||||||
|
@ -285,25 +294,6 @@ gatherByteString = unsafeInterleaveIO . go
|
||||||
go (S.Effect ms) = ms >>= go
|
go (S.Effect ms) = ms >>= go
|
||||||
go (S.Yield v s) = LI.Chunk v <$> unsafeInterleaveIO (go s)
|
go (S.Yield v s) = LI.Chunk v <$> unsafeInterleaveIO (go s)
|
||||||
|
|
||||||
clientGet'
|
|
||||||
:: B64UUID ServerSide
|
|
||||||
-> ProtocolVersion
|
|
||||||
-> B64Key
|
|
||||||
-> B64UUID ClientSide
|
|
||||||
-> [B64UUID Bypass]
|
|
||||||
-> Maybe B64FilePath
|
|
||||||
-> Maybe Offset
|
|
||||||
-> Maybe Auth
|
|
||||||
-> ClientM (Headers '[DataLengthHeader] (S.SourceT IO B.ByteString))
|
|
||||||
clientGet' su (ProtocolVersion ver) = case ver of
|
|
||||||
3 -> v3 su V3
|
|
||||||
2 -> v2 su V2
|
|
||||||
1 -> v1 su V1
|
|
||||||
0 -> v0 su V0
|
|
||||||
_ -> error "unsupported protocol version"
|
|
||||||
where
|
|
||||||
v3 :<|> v2 :<|> v1 :<|> v0 :<|> _ = client p2pHttpAPI
|
|
||||||
|
|
||||||
type CheckPresentAPI
|
type CheckPresentAPI
|
||||||
= KeyParam
|
= KeyParam
|
||||||
:> CU Required
|
:> CU Required
|
||||||
|
|
|
@ -28,8 +28,7 @@ Planned schedule of work:
|
||||||
|
|
||||||
## work notes
|
## work notes
|
||||||
|
|
||||||
* http server and client are working, remaining
|
* Implement: servePut, servePutOffset, serveLockContent
|
||||||
server API endpoints need wiring up and testing.
|
|
||||||
|
|
||||||
* I have a file `servant.hs` in the httpproto branch that works through some
|
* I have a file `servant.hs` in the httpproto branch that works through some
|
||||||
of the bytestring streaming issues.
|
of the bytestring streaming issues.
|
||||||
|
@ -55,6 +54,8 @@ Planned schedule of work:
|
||||||
* finalized HTTP P2P protocol draft 1,
|
* finalized HTTP P2P protocol draft 1,
|
||||||
[[design/p2p_protocol_over_http/draft1]]
|
[[design/p2p_protocol_over_http/draft1]]
|
||||||
|
|
||||||
|
* implemented server and client for HTTP P2P protocol
|
||||||
|
|
||||||
## items deferred until later for [[design/passthrough_proxy]]
|
## items deferred until later for [[design/passthrough_proxy]]
|
||||||
|
|
||||||
* Check annex.diskreserve when proxying for special remotes
|
* Check annex.diskreserve when proxying for special remotes
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue