use of com.predic8.membrane.core.http.Body in project service-proxy by membrane.
the class WSDLInterceptorTest method setUp.
@Before
public void setUp() throws Exception {
exc = new Exchange(new FakeHttpHandler(3011));
exc.setRequest(MessageUtil.getGetRequest("/axis2/services/BLZService?wsdl"));
InputStream resourceAsStream = this.getClass().getResourceAsStream("/blz-service.wsdl");
Response okResponse = Response.ok().contentType("text/xml; charset=utf-8").body(resourceAsStream, true).build();
exc.setResponse(okResponse);
exc.setOriginalHostHeader("thomas-bayer.com:80");
interceptor = new WSDLInterceptor();
}
use of com.predic8.membrane.core.http.Body in project service-proxy by membrane.
the class WebSocketStompReassembler method convertToExchange.
private Exchange convertToExchange(WebSocketFrame wsStompFrame) throws IOException, EndOfStreamException {
byte[] realPayload = new byte[(int) wsStompFrame.getPayloadLength()];
System.arraycopy(wsStompFrame.getPayload(), 0, realPayload, 0, (int) wsStompFrame.getPayloadLength());
if (wsStompFrame.getPayloadLength() == 0)
throw new IOException("Empty STOMP frame.");
ByteArrayInputStream bais = new ByteArrayInputStream(wsStompFrame.getPayload(), 0, (int) wsStompFrame.getPayloadLength() - 1);
Request request = new Request();
if (isHeartBeat(wsStompFrame)) {
request.setMethod("");
request.setBody(new Body(bais));
} else {
if (wsStompFrame.getPayload()[(int) wsStompFrame.getPayloadLength() - 1] != 0)
throw new IOException("STOMP frame is not terminated by \\0.");
request.read(bais, true);
}
Exchange result = new Exchange(null);
result.setRequest(request);
if (wsStompFrame.getOriginalExchange() != null)
result.setProperty(Exchange.WS_ORIGINAL_EXCHANGE, wsStompFrame.getOriginalExchange());
return result;
}
use of com.predic8.membrane.core.http.Body in project service-proxy by membrane.
the class LimitedMemoryExchangeStoreTest method getExchange.
private Exchange getExchange(String id) throws IOException {
Exchange exc = new Exchange(null);
exc.setProperty("id", id);
Request req = new Request();
req.create("GET", "http://test", "HTTP/", new Header(), null);
exc.setRequest(req);
exc.setResponse(Response.ok().body("<xml />").build());
return exc;
}
use of com.predic8.membrane.core.http.Body in project service-proxy by membrane.
the class LargeBodyTest method largeChunked.
@Test
public void largeChunked() throws Exception {
setup();
long len = Integer.MAX_VALUE + 1l;
Exchange e = new Request.Builder().post("http://localhost:3041/foo").body(len, new ConstantInputStream(len)).header(TRANSFER_ENCODING, CHUNKED).buildExchange();
new HttpClient(hcc).call(e);
}
use of com.predic8.membrane.core.http.Body in project service-proxy by membrane.
the class LargeBodyTest method setup.
public void setup() throws Exception {
// streaming only works for maxRetries = 1
hcc = new HttpClientConfiguration();
hcc.setMaxRetries(1);
Rule rule = new ServiceProxy(new ServiceProxyKey("localhost", "POST", ".*", 3040), "thomas-bayer.com", 80);
rule.getInterceptors().add(new AbstractInterceptor() {
@Override
public Outcome handleRequest(Exchange exc) throws Exception {
exc.setResponse(Response.ok().body("").build());
return Outcome.RETURN;
}
});
router = new HttpRouter();
((HTTPClientInterceptor) router.getTransport().getInterceptors().get(3)).setHttpClientConfig(hcc);
router.getRuleManager().addProxyAndOpenPortIfNew(rule);
router.init();
Rule rule1 = new ServiceProxy(new ServiceProxyKey("localhost", "POST", ".*", 3041), "localhost", 3040);
router2 = new HttpRouter();
((HTTPClientInterceptor) router2.getTransport().getInterceptors().get(3)).setHttpClientConfig(hcc);
router2.getRuleManager().addProxyAndOpenPortIfNew(rule1);
router2.init();
}
Aggregations