Inets http 客户端 +授权
我应该如何在 httpc:request() 函数发出的 http 请求中指定客户端授权的用户/密码?
How should I specify user/password for client authorization in http request made by httpc:request() function??
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
我不认为 httpc 模块为此提供了便利。
尽管如此,实现起来并不难(如果我们谈论的是基本身份验证)。毕竟,它只是一个带有“用户:密码”对 Base64 编码的附加请求标头。
例如 Tsung 的 ts_http_common 模块 就是这样做的。
例如,以下是如何使用基本身份验证运行 HTTP PUT 请求:
I don't think
httpc
module provides facility for that.Nevertheless it isn't hard to implement (if we are talking about Basic Authentification). After all it's just an additional request header with 'user:password' pair Base64 encoded.
For example Tsung's ts_http_common module does it.
For instance, here is how you can run HTTP PUT request with basic authentication:
我在文档中看到 HTTPOptions 保存了 pass 和 user:
文档: http:// www.erlang.org/doc/man/httpc.html#request-5
I see in doc that HTTPOptions holds pass and user:
documentation: http://www.erlang.org/doc/man/httpc.html#request-5
对于摘要,您需要执行与基本操作相同的操作,但要做的更多。通常,您将在没有身份验证的情况下访问页面,获取“WWW-Authenticate”标头信息,然后使用领域和随机数来生成“Authorization”标头。 http://en.wikipedia.org/wiki/Digest_access_authentication 在底部有一个不错的例子。
一般来说,对于大多数用例来说,HTTPS + Basic 就算不是更好,也足够了。
For digest, you'll need to do the same thing as basic but more so. Generally you'll hit the page without auth, get the "WWW-Authenticate" header info, then use the realm and nonce there to generate your "Authorization" header. http://en.wikipedia.org/wiki/Digest_access_authentication has a decent example at the bottom.
Generally, HTTPS + Basic is sufficient, if not better, for most use cases.
尝试使用 ibrowse,它支持并且我一直在使用它! https://github.com/cmullaparthi/ibrowse
Try using ibrowse, that supports and I am have been using that! https://github.com/cmullaparthi/ibrowse