简体   繁体   English

HTTP基本用户身份验证:“ Authorization”标头不被接受(区分大小写)

[英]HTTP basic user authentication : “Authorization” header not accepted (case-sensitive)

I'm using HTTP Header Basic authentication to send username and password to the server: 我正在使用HTTP Header Basic身份验证将用户名和密码发送到服务器:

Code: 码:

List<String> as = new ArrayList<String>();
HttpTransportProperties.Authenticator basicAuth = new HttpTransportProperties.Authenticator();

as.add(Authenticator.BASIC);
basicAuth.setAuthSchemes(as);

basicAuth.setUsername("ABC");
basicAuth.setPassword("password");

basicAuth.setPreemptiveAuthentication(true);

serviceStub._getServiceClient().getOptions().setProperty(
                org.apache.axis2.transport.http.HTTPConstants.AUTHENTICATE,
                basicAuthenticator);

I'm using Tomcat 6 as a server. 我正在使用Tomcat 6作为服务器。

In catalina.log file, I can see the following: 在catalina.log文件中,可以看到以下内容:

header=authorization=Basic U2hyZXlhczpwYXNzd29yZA== 标头=授权=基本U2hyZXlhczpwYXNzd29yZA ==

I'm expecting "authorization" as "Authorization" ie Captial 'A' in authorization. 我期望“授权”为“授权”,即授权中的大写字母“ A”。

I've checked many existing post but not able to find the answer. 我已经检查了许多现有的帖子,但找不到答案。

Could you please advice how to achieve above result? 您能否建议如何达到上述效果?

Thanks in advance 提前致谢

HTTP Headers field names, as authorization, are case insensitive HTTP标头字段名称(作为授权)不区分大小写

From RFC 2616 - "Hypertext Transfer Protocol -- HTTP/1.1", Section 4.2, "Message Headers": 从RFC 2616-“超文本传输​​协议-HTTP / 1.1”的第4.2节“消息头”:

Each header field consists of a name followed by a colon (":") and the field value. 每个标题字段均由名称,后跟冒号(“:”)和字段值组成。 Field names are case-insensitive . 字段名称不区分大小写

So case shouldn't matter 所以情况不重要

EDIT Add a newer HTTP/1.1 document for reference 编辑添加一个更新的HTTP / 1.1文档以供参考

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM