我有一个方法的终点HTTP DELETE
。我想传递一些标题,更具体地说Content-Type=application/x-www-form-urlencoded
。还有一些参数,服务器端将根据这些参数决定应该删除哪些记录。我无法访问服务器实现。
我正在使用apache HTTP 客户端。我的 HTTP DELETE 方法如下:
private String doDelete(String url, Map<String,String> params, Map<String,String> headerMap){
HttpClient httpClient = new DefaultHttpClient(httpParams);
HttpDelete httpDelete = new HttpDelete(httpRequestWrapper.getUrl());
if(headerMap != null){
for(String headerName : headerMap.keySet()){
httpDelete.addHeader(headerName, headerMap.get(headerName));
}
}
if(params != null){
for(String paramName : params.keySet()){
httpParams.setParameter(paramName, params.get(paramName));
}
httpDelete.setParams(httpParams);
}
HttpResponse httpResponse = httpClient.execute(httpDelete);
HttpEntity httpEntity = httpResponse.getEntity();
String responseStr = getASCIIContentFromEntity(httpEntity);
return responseStr;
}
问题是,我看到(在调试模式下)参数正在从我端正确地传递到删除请求中。但是在服务器端接收到的参数是空白的。有什么方法可以成功传递参数和标头?
任何帮助表示赞赏。