gpt4 book ai didi

http - 使用参数发出简单的 post 请求并接收响应

转载 作者:可可西里 更新时间:2023-11-01 16:34:37 25 4
gpt4 key购买 nike

我想复制这个功能:

curl -d "user=username&passwd=passwd&api_type=json" http://www.reddit.com/api/login/username

我遇到过至少 3 个以迂回方式提供此功能的库:http-conduitnetwork-httpcurl .什么库是发出 http 请求的标准,我将如何使用它来发出此 post 请求?

我应该指定我也想阅读回复。

最佳答案

标准库是HTTP .它随 Haskell 平台一起提供。

The HTTP package supports client-side web programming in Haskell. It lets you set up HTTP connections, transmitting requests and processing the responses coming back, all from within the comforts of Haskell. It's dependent on the network package to operate, but other than that, the implementation is all written in Haskell.

A basic API for issuing single HTTP requests + receiving responses is provided. On top of that, a session-level abstraction is also on offer (the BrowserAction monad); it taking care of handling the management of persistent connections, proxies, state (cookies) and authentication credentials required to handle multi-step interactions with a web server.

The representation of the bytes flowing across is extensible via the use of a type class, letting you pick the representation of requests and responses that best fits your use. Some pre-packaged, common instances are provided for you (ByteString, String.)

如果 HTTP 包由于某种原因不适合,Hackage 上有很多包,正如您所指出的,包括直接 curl 绑定(bind)、各种高级绑定(bind)和专注于性能的绑定(bind)。

关于http - 使用参数发出简单的 post 请求并接收响应,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10609405/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com