use of org.apache.http.HttpRequest in project XobotOS by xamarin.
the class AbstractHttpServerConnection method receiveRequestHeader.
public HttpRequest receiveRequestHeader() throws HttpException, IOException {
assertOpen();
HttpRequest request = (HttpRequest) this.requestParser.parse();
this.metrics.incrementRequestCount();
return request;
}
use of org.apache.http.HttpRequest in project camel by apache.
the class HttpProducerTwoHeadersWithSameKeyTest method setUp.
@Before
@Override
public void setUp() throws Exception {
localServer = ServerBootstrap.bootstrap().setHttpProcessor(getBasicHttpProcessor()).setConnectionReuseStrategy(getConnectionReuseStrategy()).setResponseFactory(getHttpResponseFactory()).setExpectationVerifier(getHttpExpectationVerifier()).setSslContext(getSSLContext()).registerHandler("/myapp", new HttpRequestHandler() {
@Override
public void handle(HttpRequest request, HttpResponse response, HttpContext context) throws HttpException, IOException {
Header[] from = request.getHeaders("from");
assertEquals("me", from[0].getValue());
Header[] to = request.getHeaders("to");
assertEquals("[foo, bar]", to[0].getValue());
response.setHeader("bar", "yes");
response.addHeader("foo", "123");
response.addHeader("foo", "456");
response.setEntity(new StringEntity("OK", "ASCII"));
response.setStatusCode(HttpStatus.SC_OK);
}
}).registerHandler("/myapp", new HttpRequestHandler() {
@Override
public void handle(HttpRequest request, HttpResponse response, HttpContext context) throws HttpException, IOException {
Header[] from = request.getHeaders("from");
assertEquals("me", from[0].getValue());
Header[] to = request.getHeaders("to");
assertEquals("[foo, bar]", to[0].getValue());
response.setHeader("bar", "yes");
response.addHeader("foo", "123");
response.addHeader("foo", "456");
response.setEntity(new StringEntity("OK", "ASCII"));
response.setStatusCode(HttpStatus.SC_OK);
}
}).create();
localServer.start();
super.setUp();
}
use of org.apache.http.HttpRequest in project camel by apache.
the class HttpProducerTwoParametersWithSameKeyTest method setUp.
@Before
@Override
public void setUp() throws Exception {
localServer = ServerBootstrap.bootstrap().setHttpProcessor(getBasicHttpProcessor()).setConnectionReuseStrategy(getConnectionReuseStrategy()).setResponseFactory(getHttpResponseFactory()).setExpectationVerifier(getHttpExpectationVerifier()).setSslContext(getSSLContext()).registerHandler("/myapp", new HttpRequestHandler() {
@Override
public void handle(HttpRequest request, HttpResponse response, HttpContext context) throws HttpException, IOException {
String uri = request.getRequestLine().getUri();
assertEquals("/myapp?from=me&to=foo&to=bar", uri);
response.setHeader("bar", "yes");
response.addHeader("foo", "123");
response.addHeader("foo", "456");
response.setEntity(new StringEntity("OK", "ASCII"));
response.setStatusCode(HttpStatus.SC_OK);
}
}).create();
localServer.start();
super.setUp();
}
use of org.apache.http.HttpRequest in project camel by apache.
the class HttpProducerContentTypeTest method setUp.
@Before
@Override
public void setUp() throws Exception {
localServer = ServerBootstrap.bootstrap().setHttpProcessor(getBasicHttpProcessor()).setConnectionReuseStrategy(getConnectionReuseStrategy()).setResponseFactory(getHttpResponseFactory()).setExpectationVerifier(getHttpExpectationVerifier()).setSslContext(getSSLContext()).registerHandler("/content", new HttpRequestHandler() {
@Override
public void handle(HttpRequest request, HttpResponse response, HttpContext context) throws HttpException, IOException {
String contentType = request.getFirstHeader(Exchange.CONTENT_TYPE).getValue();
assertEquals(CONTENT_TYPE, contentType);
response.setEntity(new StringEntity(contentType, "ASCII"));
response.setStatusCode(HttpStatus.SC_OK);
}
}).create();
localServer.start();
super.setUp();
}
use of org.apache.http.HttpRequest in project camel by apache.
the class HttpNoCamelHeaderTest method setUp.
@Before
@Override
public void setUp() throws Exception {
localServer = ServerBootstrap.bootstrap().setHttpProcessor(getBasicHttpProcessor()).setConnectionReuseStrategy(getConnectionReuseStrategy()).setResponseFactory(getHttpResponseFactory()).setExpectationVerifier(getHttpExpectationVerifier()).setSslContext(getSSLContext()).registerHandler("/hello", new HttpRequestHandler() {
@Override
public void handle(HttpRequest request, HttpResponse response, HttpContext context) throws HttpException, IOException {
response.setStatusCode(HttpStatus.SC_OK);
Object header = request.getFirstHeader(Exchange.FILE_NAME);
assertNull("There should be no Camel header", header);
for (Header h : request.getAllHeaders()) {
if (h.getName().startsWith("Camel") || h.getName().startsWith("org.apache.camel")) {
assertNull("There should be no Camel header", h);
}
}
// set ar regular and Camel header
response.setHeader("MyApp", "dude");
response.setHeader(Exchange.TO_ENDPOINT, "foo");
}
}).create();
localServer.start();
super.setUp();
}
Aggregations