@@ -87,7 +87,7 @@ instance Exception ServantError
87
87
data Req = Req
88
88
{ reqPath :: String
89
89
, qs :: QueryText
90
- , reqBody :: Maybe (ByteString , MediaType )
90
+ , reqBody :: Maybe (RequestBody , MediaType )
91
91
, reqAccept :: [MediaType ]
92
92
, headers :: [(String , Text )]
93
93
}
@@ -112,8 +112,31 @@ addHeader name val req = req { headers = headers req
112
112
++ [(name, decodeUtf8 (toHeader val))]
113
113
}
114
114
115
+ -- | Set body and media type of the request being constructed.
116
+ --
117
+ -- The body is set to the given bytestring using the 'RequestBodyLBS'
118
+ -- constructor.
119
+ --
120
+ {-# DEPRECATED setRQBody "Use setReqBodyLBS instead" #-}
115
121
setRQBody :: ByteString -> MediaType -> Req -> Req
116
- setRQBody b t req = req { reqBody = Just (b, t) }
122
+ setRQBody = setReqBodyLBS
123
+
124
+ -- | Set body and media type of the request being constructed.
125
+ --
126
+ -- The body is set to the given bytestring using the 'RequestBodyLBS'
127
+ -- constructor.
128
+ --
129
+ -- @since 0.9.2.0
130
+ --
131
+ setReqBodyLBS :: ByteString -> MediaType -> Req -> Req
132
+ setReqBodyLBS b t req = req { reqBody = Just (RequestBodyLBS b, t) }
133
+
134
+ -- | Set body and media type of the request being constructed.
135
+ --
136
+ -- @since 0.9.2.0
137
+ --
138
+ setReqBody :: RequestBody -> MediaType -> Req -> Req
139
+ setReqBody b t req = req { reqBody = Just (b, t) }
117
140
118
141
reqToRequest :: (Functor m , MonadThrow m ) => Req -> BaseUrl -> m Request
119
142
reqToRequest req (BaseUrl reqScheme reqHost reqPort path) =
@@ -132,7 +155,7 @@ reqToRequest req (BaseUrl reqScheme reqHost reqPort path) =
132
155
133
156
setrqb r = case reqBody req of
134
157
Nothing -> r
135
- Just (b,t) -> r { requestBody = RequestBodyLBS b
158
+ Just (b,t) -> r { requestBody = b
136
159
, requestHeaders = requestHeaders r
137
160
++ [(hContentType, cs . show $ t)] }
138
161
setQS = setQueryString $ queryTextToQuery (qs req)
0 commit comments