如何设置HTTP请求标头“认证”使用HTTPClient? [英] How to set HTTP Request Header "authentication" using HTTPClient?
本文介绍了如何设置HTTP请求标头“认证”使用HTTPClient?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想在向服务器发送POST请求时设置HTTP请求标头授权。
我如何用Java做到这一点? HttpClient是否有任何支持?
I want to set the HTTP Request header "Authorization" when sending a POST request to a server. How do I do it in Java? Does HttpClient have any support for it?
http://www.w3.org/Protocols/HTTP/HTRQ_Headers.html#z9
服务器要求我设置一些具体的授权字段的值:
格式ID:签名,然后用于验证请求。
The server requires me to set some specific value for the authorization field: of the form ID:signature which they will then use to authenticate the request.
谢谢
Ajay
Thanks Ajay
推荐答案
以下是设置请求标题的示例
Below is the example for setting request headers
HttpPost post = new HttpPost("someurl");
post.addHeader(key1, value1));
post.addHeader(key2, value2));
这篇关于如何设置HTTP请求标头“认证”使用HTTPClient?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文