我需要添加一个标头并发送一个请求:
import Network.HTTP.Conduit
import qualified Data.ByteString.Char8 as C8
--..........
res <- withManager $ httpLbs $ createReq request
return ()
where
createReq r = r {
--...........
requestHeaders = ("content-type", "application/json") : requestHeaders r
}
我有两个错误:
Couldn't match type `[Char]'
with `case-insensitive-1.0.0.1:Data.CaseInsensitive.CI
C8.ByteString'
Expected type: HeaderName
Actual type: [Char]
In the expression: "content-type"
In the first argument of `(:)', namely
`("content-type", "application/json")'
In the `requestHeaders' field of a record
Couldn't match expected type `C8.ByteString'
with actual type `[Char]'
In the expression: "application/json"
In the first argument of `(:)', namely
`("content-type", "application/json")'
我该如何解决?
更新:
C8.pack
不会,它会导致其他错误。