我正在使用http-client教程使用 TLS 连接获取响应正文。既然我可以观察到它print是由 调用的withResponse,为什么不print强制对以下片段中的输出进行完整响应?
withResponse request manager $ \response -> do
putStrLn $ "The status code was: " ++
body <- (responseBody response)
print body
Run Code Online (Sandbox Code Playgroud)
我需要写这个:
response <- httpLbs request manager
putStrLn $ "The status code was: " ++
show (statusCode $ responseStatus response)
print $ responseBody response
Run Code Online (Sandbox Code Playgroud)
我要打印的正文是一个懒惰的 ByteString。我仍然不确定是否应该print打印整个值。
instance Show ByteString where
showsPrec p ps r = showsPrec p (unpackChars ps) r
Run Code Online (Sandbox Code Playgroud)