add method sentPutXml

This commit is contained in:
fanfuxiaoran 2014-01-17 11:16:32 +08:00
parent 6a8c2d9671
commit 6d791b7035
2 changed files with 14 additions and 3 deletions

View File

@ -30,6 +30,7 @@ public class HttpRequester {
this.defaultContentEncoding = defaultContentEncoding;
}
public HttpResponse sendPost(String urlString, Map<String, String> params,
Map<String, String> properties) throws IOException {
return this.send(urlString, "POST", params, "", properties);
@ -50,9 +51,19 @@ public class HttpRequester {
public HttpResponse sendGet(String urlString, Map<String, String> params,
Map<String, String> properties) throws IOException {
return this.send(urlString, "GET", params, "", properties);
}
public HttpResponse sendPutXml(String urlString,String content,
Map<String, String> properties) throws IOException{
if (properties == null) {
properties = new HashMap<String, String>();
}
properties.put("Content-Type", "application/xml");
return this.send(urlString, "PUT", null, content, properties);
}
private HttpResponse send(String urlString, String method,
Map<String, String> parameters, String Content,
Map<String, String> propertys) throws IOException {
@ -79,7 +90,6 @@ public class HttpRequester {
}
URL url = new URL(urlString);
urlConnection = (HttpURLConnection) url.openConnection();
urlConnection.setRequestMethod(method);
urlConnection.setDoOutput(true);
urlConnection.setDoInput(true);
@ -90,7 +100,7 @@ public class HttpRequester {
urlConnection.addRequestProperty(key, propertys.get(key));
}
if (method.equalsIgnoreCase("POST") && parameters != null) {
if ((method.equalsIgnoreCase("POST")||method.equalsIgnoreCase("PUT")) && parameters != null) {
StringBuffer param = new StringBuffer();
for (String key : parameters.keySet()) {
param.append("&");
@ -101,7 +111,7 @@ public class HttpRequester {
urlConnection.getOutputStream().write(param.toString().getBytes());
urlConnection.getOutputStream().flush();
urlConnection.getOutputStream().close();
} else if (method.equalsIgnoreCase("POST") && !Content.isEmpty()) {
} else if ((method.equalsIgnoreCase("POST")||method.equalsIgnoreCase("PUT")) && !Content.isEmpty()) {
urlConnection.getOutputStream().write(Content.getBytes());
urlConnection.getOutputStream().flush();
urlConnection.getOutputStream().close();

View File

@ -139,6 +139,7 @@ public class ScriptBriefResultModel extends SampleModel {
this.vUserCount = vUserCount;
}
@Override
public boolean equals(Object obj) {
if (!(obj instanceof ScriptBriefResultModel) || obj == null) {