use of org.apache.commons.httpclient.methods.PostMethod in project camel by apache.
the class NettyHttpHeaderMaxSizeTest method testHttpHeaderMaxSizeOk.
@Test
public void testHttpHeaderMaxSizeOk() throws Exception {
HttpClient client = new HttpClient();
HttpMethod method = new PostMethod("http://localhost:" + getPort() + "/myapp/mytest");
method.setRequestHeader("name", "you");
client.executeMethod(method);
assertEquals(200, method.getStatusCode());
assertEquals("Bye World", method.getResponseBodyAsString());
}
use of org.apache.commons.httpclient.methods.PostMethod in project camel by apache.
the class NettyHttpMapHeadersFalseTest method testHttpHeaderCase.
@Test
public void testHttpHeaderCase() throws Exception {
HttpClient client = new HttpClient();
HttpMethod method = new PostMethod("http://localhost:" + getPort() + "/myapp/mytest");
method.setRequestHeader("clientHeader", "fooBAR");
method.setRequestHeader("OTHER", "123");
method.setRequestHeader("beer", "Carlsberg");
client.executeMethod(method);
assertEquals("Bye World", method.getResponseBodyAsString());
assertEquals("aBc123", method.getResponseHeader("MyCaseHeader").getValue());
assertEquals("456DEf", method.getResponseHeader("otherCaseHeader").getValue());
}
use of org.apache.commons.httpclient.methods.PostMethod in project camel by apache.
the class NettyHttpMethodRestrictTest method testProperHttpMethod.
@Test
public void testProperHttpMethod() throws Exception {
HttpClient httpClient = new HttpClient();
PostMethod httpPost = new PostMethod(getUrl());
StringRequestEntity reqEntity = new StringRequestEntity("This is a test", null, null);
httpPost.setRequestEntity(reqEntity);
int status = httpClient.executeMethod(httpPost);
assertEquals("Get a wrong response status", 200, status);
String result = httpPost.getResponseBodyAsString();
assertEquals("Get a wrong result", "This is a test response", result);
}
use of org.apache.commons.httpclient.methods.PostMethod in project camel by apache.
the class AddBreadcrumbHttpHeaderTestInterceptor method handleRequest.
@Override
public boolean handleRequest(MessageContext messageContext) throws WebServiceClientException {
// no extra op
TransportContext context = TransportContextHolder.getTransportContext();
CommonsHttpConnection connection = (CommonsHttpConnection) context.getConnection();
PostMethod postMethod = connection.getPostMethod();
postMethod.addRequestHeader("breadcrumbId", "ID-Ralfs-MacBook-Pro-local-50523-1423553069254-0-5");
return true;
}
use of org.apache.commons.httpclient.methods.PostMethod in project h2o-2 by h2oai.
the class CloudConnect method launch.
/**
* Upload jars to an existing cloud and launches a custom job. Uses the Web API.
*/
public static void launch(String job, String host, File... jars) throws Exception {
HttpClient client = new HttpClient();
String args = "job_class=" + job + "&jars=";
for (File f : jars) {
PostMethod post = new PostMethod("http://" + host + "/Upload.json?key=" + f.getName());
Part[] parts = { new FilePart(f.getName(), f) };
post.setRequestEntity(new MultipartRequestEntity(parts, post.getParams()));
if (200 != client.executeMethod(post))
throw new RuntimeException("Request failed: " + post.getStatusLine());
args += f.getName() + ",";
post.releaseConnection();
}
String href = new LaunchJar().href();
GetMethod get = new GetMethod("http://" + host + href + ".json?" + args);
if (200 != client.executeMethod(get))
throw new RuntimeException("Request failed: " + get.getStatusLine());
get.releaseConnection();
}
Aggregations