mkVCClientEnv in inferno-vc currently uses the internals of Manager (from http-client) to modify request headers and body:
|
mkVCClientEnv :: Manager -> BaseUrl -> ClientEnv |
|
mkVCClientEnv man@Manager {mModifyRequest = modReq} baseUrl = |
|
mkClientEnv man {mModifyRequest = modReq'} baseUrl |
|
where |
|
modReq' :: Request -> IO Request |
|
modReq' r = do |
|
x <- modReq r |
|
pure $ |
|
if ((hContentEncoding, "gzip") `elem` requestHeaders x) |
|
then x |
|
else |
|
let new_hdrs = (hContentEncoding, "gzip") : requestHeaders x |
|
(hrds, body) = case requestBody x of |
|
RequestBodyBuilder _ _ -> (requestHeaders x, requestBody x) |
|
RequestBodyStream _ _ -> (requestHeaders x, requestBody x) |
|
RequestBodyStreamChunked _ -> (requestHeaders x, requestBody x) |
|
b -> (new_hdrs, compressBody b) |
|
in x {requestHeaders = hrds, requestBody = body} |
|
|
|
compressBody :: RequestBody -> RequestBody |
|
compressBody = \case |
|
RequestBodyLBS bsl -> RequestBodyLBS $ compress bsl |
|
RequestBodyBS bs -> RequestBodyLBS $ compress $ BSL.fromStrict bs |
|
RequestBodyIO iob -> RequestBodyIO $ compressBody <$> iob |
|
b -> b |
I don't think we should rely on the internal implementation of Manager like this; the current docs for that Network.HTTP.Client.Internal state
No API stability is guaranteed for this module
which is generally the case for modules marked as internal.
We could probably just use a middleware to achieve the same thing. Or, if that's not possible, this code should document why it's necessary to use internal modules from another library
mkVCClientEnvininferno-vccurrently uses the internals ofManager(fromhttp-client) to modify request headers and body:inferno/inferno-vc/src/Inferno/VersionControl/Client.hs
Lines 19 to 43 in f229ad9
I don't think we should rely on the internal implementation of
Managerlike this; the current docs for thatNetwork.HTTP.Client.Internalstatewhich is generally the case for modules marked as internal.
We could probably just use a middleware to achieve the same thing. Or, if that's not possible, this code should document why it's necessary to use internal modules from another library