码迷,mamicode.com
首页 > Web开发 > 详细

http 协议

时间:2017-05-17 14:06:54      阅读:218      评论:0      收藏:0      [点我收藏+]

标签:value   修改   apache   rest   响应协议   pre   option   protocol   lock   


HTTP协议

我们这边查询到的下发日志里发现你们接口返回的结果包含了 HTTP 请求头,导致我们这边无法解析返回结果。排查一下相关问题。
这是你们返回的结果:
HTTP\/1.1 200 \r\nx-frame-options: SAMEORIGIN\r\nContent-Security-Policy: script-src ‘unsafe-inline‘ ‘self‘ ‘unsafe-eval‘ https:;object-src
‘none‘;\r\nX-Content-Type-Options: nosniff\r\nX-XSS-Protection: 1; mode=block\r\nStrict-Transport-Security: max-age=10886400;
includeSubDomains\r\nAccess-Control-Allow-Origin: *\r\nContent-Type: application\/json;charset=utf-8\r\nContent-Length:
50\r\nDate: Wed, 17 May 2017 03:04:33 GMT\r\n\r\n
{\"code\":\"100000\",\"msg\":\"\u63a5\u6536\u5ba1\u6838\u4fe1\u606f\u6210\u529f\"}","eType":"BV_INFO_BUSINESS"}


分别更改两个地方:
1、修改tomcat/conf/server.xml文件,将
protocol="org.apache.coyote.http11.Http11NioProtocol" 修改为 protocol="HTTP/1.1"
试试。

如果还不好用的话,将自定义的响应协议安全拦截器注释掉。
<mvc:interceptors>
<mvc:interceptor>
<mvc:mapping path="/rest/**" />
<ref bean="loginIntercepter"></ref>
</mvc:interceptor>
<!-- <mvc:interceptor>
<mvc:mapping path="/**" />
<ref bean="responseHeadersIntercepter" />
</mvc:interceptor> -->
</mvc:interceptors>

<bean id="responseHeadersIntercepter" class="com.sinoeyes.web.intercepters.ResponseHeadersIntercepter">
<property name="headers">
<map>
<entry key="x-frame-options" value="SAMEORIGIN" ></entry>
<entry key="Content-Security-Policy" value="script-src ‘unsafe-inline‘ ‘self‘ ‘unsafe-eval‘ https:;object-src ‘none‘;" ></entry>
<entry key="X-Content-Type-Options" value="nosniff" ></entry>
<entry key="X-XSS-Protection" value=" 1; mode=block" ></entry>
<entry key="Strict-Transport-Security" value="max-age=10886400; includeSubDomains" ></entry>
<entry key="Access-Control-Allow-Origin" value="*"></entry>
</map>
</property>
</bean>


public class ResponseHeadersIntercepter extends HandlerInterceptorAdapter {

private Map<String, String> headers;

@Override
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {

for (Map.Entry<String, String> entry : headers.entrySet()) {
response.setHeader(entry.getKey(), entry.getValue());
if ("Access-Control-Allow-Origin".equals(entry.getKey()) && "*".equals(entry.getValue())) {
request.setAttribute("isJsonp", true);
}
}
return super.preHandle(request, response, handler);
}

public Map<String, String> getHeaders() {
return headers;
}

public void setHeaders(Map<String, String> headers) {
this.headers = headers;
}
}

 

http 协议

标签:value   修改   apache   rest   响应协议   pre   option   protocol   lock   

原文地址:http://www.cnblogs.com/Lichuntao/p/6866949.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!