use of com.predic8.membrane.core.http.xml.Request in project service-proxy by membrane.
the class ACLTest method test.
@Test
public void test() throws IOException, InterruptedException {
File baseDir = getExampleDir("acl");
Process2 sl = new Process2.Builder().in(baseDir).script("service-proxy").waitForMembrane().start();
try {
getAndAssert200("http://localhost:2000/");
String result = getAndAssert(404, "http://localhost:2000/contacts/");
// this request succeeds through membrane, but fails on the backend with 404
AssertUtils.assertContains("Tomcat", result);
getAndAssert(403, "http://localhost:2000/open-source/");
} finally {
sl.killScript();
}
}
use of com.predic8.membrane.core.http.xml.Request in project service-proxy by membrane.
the class HttpServletHandler method createRequest.
private Request createRequest() throws IOException {
Request srcReq = new Request();
String pathQuery = request.getRequestURI();
if (request.getQueryString() != null)
pathQuery += "?" + request.getQueryString();
if (getTransport().isRemoveContextRoot()) {
String contextPath = request.getContextPath();
if (contextPath.length() > 0 && pathQuery.startsWith(contextPath))
pathQuery = pathQuery.substring(contextPath.length());
}
srcReq.create(request.getMethod(), pathQuery, request.getProtocol(), createHeader(), request.getInputStream());
return srcReq;
}
use of com.predic8.membrane.core.http.xml.Request in project service-proxy by membrane.
the class LoadBalancingInterceptorTest method doTestGetDestinationURL.
private void doTestGetDestinationURL(String requestUri, String expectedUri) throws URISyntaxException {
Exchange exc = new Exchange(null);
exc.setRequest(new Request());
exc.getRequest().setUri(URLUtil.getPathQuery(new URIFactory(), requestUri));
exc.setOriginalRequestUri(requestUri);
assertEquals(expectedUri, new Node("thomas-bayer.com", 80).getDestinationURL(exc));
}
use of com.predic8.membrane.core.http.xml.Request in project service-proxy by membrane.
the class MyInterceptor method handleRequest.
@Override
public Outcome handleRequest(Exchange exc) throws Exception {
System.out.println("MyInterceptor invoked.");
System.out.println("Request headers:");
for (HeaderField headerField : exc.getRequest().getHeader().getAllHeaderFields()) System.out.print(headerField.getHeaderName() + ": " + headerField.getValue());
return Outcome.CONTINUE;
}
use of com.predic8.membrane.core.http.xml.Request in project service-proxy by membrane.
the class LBNotificationClient method notifiyClusterManager.
private Response notifiyClusterManager() throws Exception {
HttpClient client = new HttpClient();
Exchange exc = new Exchange(null);
Request r = MessageUtil.getPostRequest(getRequestURL());
r.setBodyContent(new byte[0]);
exc.setRequest(r);
exc.getDestinations().add(getRequestURL());
Response res = client.call(exc).getResponse();
return res;
}
Aggregations