use of org.apache.http.client.methods.HttpPut in project nanohttpd by NanoHttpd.
the class TestNanolets method doSomeBasicMethodTest.
@Test
public void doSomeBasicMethodTest() throws Exception {
CloseableHttpClient httpclient = HttpClients.createDefault();
HttpGet httpget = new HttpGet("http://localhost:9090/user/blabla");
CloseableHttpResponse response = httpclient.execute(httpget);
HttpEntity entity = response.getEntity();
String string = new String(readContents(entity), "UTF-8");
Assert.assertEquals("<html><body>User handler. Method: GET<br><h1>Uri parameters:</h1><div> Param: id Value: blabla</div><h1>Query parameters:</h1></body></html>", string);
response.close();
HttpPost httppost = new HttpPost("http://localhost:9090/user/blabla");
response = httpclient.execute(httppost);
entity = response.getEntity();
string = new String(readContents(entity), "UTF-8");
Assert.assertEquals("<html><body>User handler. Method: POST<br><h1>Uri parameters:</h1><div> Param: id Value: blabla</div><h1>Query parameters:</h1></body></html>", string);
response.close();
HttpPut httpgput = new HttpPut("http://localhost:9090/user/blabla");
response = httpclient.execute(httpgput);
entity = response.getEntity();
string = new String(readContents(entity), "UTF-8");
Assert.assertEquals("<html><body>User handler. Method: PUT<br><h1>Uri parameters:</h1><div> Param: id Value: blabla</div><h1>Query parameters:</h1></body></html>", string);
response.close();
HttpDelete httpdelete = new HttpDelete("http://localhost:9090/user/blabla");
response = httpclient.execute(httpdelete);
entity = response.getEntity();
string = new String(readContents(entity), "UTF-8");
Assert.assertEquals("<html><body>User handler. Method: DELETE<br><h1>Uri parameters:</h1><div> Param: id Value: blabla</div><h1>Query parameters:</h1></body></html>", string);
response.close();
}
use of org.apache.http.client.methods.HttpPut in project OpenAttestation by OpenAttestation.
the class ApacheHttpClient method put.
public ApiResponse put(String requestURL, ApiRequest message) throws IOException, SignatureException {
log.debug("PUT url: {}", requestURL);
log.debug("PUT content: {}", message == null ? "(empty)" : message.content);
HttpPut request = new HttpPut(requestURL);
if (message != null && message.content != null) {
request.setEntity(new StringEntity(message.content, ContentType.create(message.contentType.toString(), "UTF-8")));
}
HttpResponse httpResponse = httpClient.execute(request);
ApiResponse apiResponse = readResponse(httpResponse);
request.releaseConnection();
return apiResponse;
}
use of org.apache.http.client.methods.HttpPut in project openkit-android by OpenKit.
the class OKHTTPClient method putJSON.
public static void putJSON(String relativeUrl, JSONObject requestParams, AsyncHttpResponseHandler responseHandler) {
StringEntity sEntity = getJSONString(requestParams);
HttpPut request = new HttpPut(getAbsoluteUrl(relativeUrl));
if (sEntity == null) {
responseHandler.onFailure(new Throwable("JSON encoding error"), "JSON encoding error");
} else {
request.setEntity(sEntity);
sign(request);
client.put(request, "application/json", responseHandler);
}
}
use of org.apache.http.client.methods.HttpPut in project FastDev4Android by jiangqqlmj.
the class HttpClientStackTest method createPutRequest.
@Test
public void createPutRequest() throws Exception {
TestRequest.Put request = new TestRequest.Put();
assertEquals(request.getMethod(), Method.PUT);
HttpUriRequest httpRequest = HttpClientStack.createHttpRequest(request, null);
assertTrue(httpRequest instanceof HttpPut);
}
use of org.apache.http.client.methods.HttpPut in project FastDev4Android by jiangqqlmj.
the class HttpClientStackTest method createPutRequestWithBody.
@Test
public void createPutRequestWithBody() throws Exception {
TestRequest.PutWithBody request = new TestRequest.PutWithBody();
assertEquals(request.getMethod(), Method.PUT);
HttpUriRequest httpRequest = HttpClientStack.createHttpRequest(request, null);
assertTrue(httpRequest instanceof HttpPut);
}
Aggregations