use of org.apache.http.client.methods.HttpPost in project jstorm by alibaba.
the class UIUtils method getHttpResponse.
public static Response getHttpResponse(String url) {
Response res;
try {
// 1. proxy call the task host log view service
HttpClient client = HttpClientBuilder.create().build();
HttpPost post = new HttpPost(url);
HttpResponse response = client.execute(post);
int status = response.getStatusLine().getStatusCode();
String data = EntityUtils.toString(response.getEntity());
res = new Response(status, data);
} catch (Exception e) {
res = new Response(-1, e.getMessage());
}
return res;
}
use of org.apache.http.client.methods.HttpPost in project camel by apache.
the class RestletExceptionResponseTest method testExceptionResponse.
@Test
public void testExceptionResponse() throws Exception {
HttpResponse response = doExecute(new HttpPost("http://localhost:" + portNum + "/users/homer"));
String body = EntityUtils.toString(response.getEntity());
assertHttpResponse(response, 500, "text/plain");
assertTrue(body.contains("IllegalArgumentException"));
assertTrue(body.contains("Damn something went wrong"));
}
use of org.apache.http.client.methods.HttpPost in project camel by apache.
the class RestletFaultTest method testFaultResponse.
@Test
public void testFaultResponse() throws Exception {
HttpResponse response = doExecute(new HttpPost("http://localhost:" + portNum + "/users/homer"));
assertHttpResponse(response, 404, "text/plain", "Application fault");
}
use of org.apache.http.client.methods.HttpPost in project camel by apache.
the class RestletHttpsWithSSLContextParametersTest method postRequestMessage.
private void postRequestMessage(String message) throws Exception {
// ensure jsse clients can validate the self signed dummy localhost cert,
// use the server keystore as the trust store for these tests
URL trustStoreUrl = this.getClass().getClassLoader().getResource("jsse/localhost.ks");
System.setProperty("javax.net.ssl.trustStore", trustStoreUrl.toURI().getPath());
HttpPost post = new HttpPost("https://localhost:" + portNum + "/users/");
post.addHeader(Exchange.CONTENT_TYPE, "application/xml");
post.setEntity(new StringEntity(message));
HttpResponse response = doExecute(post);
assertHttpResponse(response, 200, "application/xml");
String s = context.getTypeConverter().convertTo(String.class, response.getEntity().getContent());
assertEquals("<status>OK</status>", s);
}
use of org.apache.http.client.methods.HttpPost in project camel by apache.
the class RestletMultiRoutesEndpointTest method testPostMethod.
@Test
public void testPostMethod() throws Exception {
HttpResponse response = doExecute(new HttpPost("http://localhost:" + portNum + "/users/homer"));
assertHttpResponse(response, 200, "text/plain", "POST");
}
Aggregations