我正在使用Apache Commons HttpClient v3.1.我的所有请求都在请求行中具有正确的(默认)HTTP版本,即HTTP/1.1,除了1个请求.
在Post请求之后获取请求行为HTTP/0.9:
server : port/cas/v1/tickets/TGT-1-sUqenNbqUzvkGSWW25lcbaJc0OEcJ6wg5DOj3XDMSwoIBf6s7i-cas-1
Body: service=*
Run Code Online (Sandbox Code Playgroud)
我通过http客户端代码调试并看到请求行设置为HTTP/1.1但在服务器上我看到请求是HTTP/0.9.
我尝试使用明确设置HTTP版本,HttpMethodParams但这没有帮助.有谁知道什么可能是错的?
HttpClient client = new HttpClient();
HostConfiguration hc = client.getHostConfiguration();
hc.setHost(new URI(url, false));
PostMethod method = new PostMethod();
method.setURI(new URI(url, false));
method.getParams().setUriCharset("UTF-8");
method.getParams().setHttpElementCharset("UTF-8");
method.getParams().setContentCharset("UTF-8");
method.getParams().setVersion(HttpVersion.HTTP_1_1);
method.addParameter("service", URLEncoder.encode(service, "UTF-8"));
method.setPath(contextPath + "/tickets/" + tgt);
String respBody = null;
int statusCode = client.executeMethod(method);
respBody = method.getResponseBodyAsString();
Run Code Online (Sandbox Code Playgroud)