zoukankan      html  css  js  c++  java
  • 关于delete method的body

    PostMan测试delete请求是正常的, 但是有个后端应用使用老版的httpClient, server端出现java.io.EOFException: Unexpected EOF read on the socket

    HttpClient 3中deleteMethod是不支持body参数的 (同时造成restTemplate的exchange()执行delete请求也失败)

    可以用设置代理的方式看出来, 这是个技术活, 不过验证一下过后还是移除了这段代码

    private void setProxyIfNeed(CommonsClientHttpRequestFactory requestFactory) {
    		if (setProxy) {
    			HostConfiguration config = requestFactory.getHttpClient().getHostConfiguration();
    			config.setProxy("localhost", 8866);
    			Credentials credentials = new UsernamePasswordCredentials();
    			AuthScope authScope = new AuthScope("localhost", 8866);
    			requestFactory.getHttpClient().getState().setProxyCredentials(authScope, credentials);
    		}
    	}
    

    修改HttpClient 3太麻烦, 升级spring mvc3动静又太大, 那就重写SimpleClientHttpRequestFactory

    if ("PUT".equals(httpMethod) || "POST".equals(httpMethod) || "DELETE"..equals(httpMethod)) {
    			connection.setDoOutput(true);
    		}
    
    @@@build beautiful things, share happiness@@@
  • 相关阅读:
    three.js-texture
    three.js-binary operator
    three.js-model
    three.js-bone
    JS时间戳
    JQUERY删除操作
    Synchronized和Static Synchronized区别
    JQUERY 保存成功后又下角动态提示
    jquery from提交和post提交
    防止多次领取红包进行ID锁
  • 原文地址:https://www.cnblogs.com/yszzu/p/14649610.html
Copyright © 2011-2022 走看看