Search in sources :

Example 46 with Request

use of com.predic8.membrane.core.http.Request in project service-proxy by membrane.

the class RequestPerformanceVersion3 method parseHeaderFromArray.

@Test
public void parseHeaderFromArray() throws Exception {
    long time = System.currentTimeMillis();
    for (int i = 0; i <= 1000000; i++) {
        parseHeaderFromArray(new Request(), buffer);
    }
    System.out.println("time from array: " + (System.currentTimeMillis() - time) / 1000.0);
}
Also used : Request(com.predic8.membrane.core.http.Request) Test(org.junit.Test)

Example 47 with Request

use of com.predic8.membrane.core.http.Request in project service-proxy by membrane.

the class RequestPerformanceVersion3 method parseHeaderReadBufferFirst.

@Test
public void parseHeaderReadBufferFirst() throws Exception {
    long time = System.currentTimeMillis();
    for (int i = 0; i <= 1000000; i++) {
        parseHeaderReadBufferFirst(new Request(), getStream());
    }
    System.out.println("time read buffer first: " + (System.currentTimeMillis() - time) / 1000.0);
}
Also used : Request(com.predic8.membrane.core.http.Request) Test(org.junit.Test)

Example 48 with Request

use of com.predic8.membrane.core.http.Request in project service-proxy by membrane.

the class XMLContentFilterTest method getMessage.

private Message getMessage() {
    Message m = new Request();
    m.setBody(new Body(DOC.getBytes()));
    return m;
}
Also used : Message(com.predic8.membrane.core.http.Message) Request(com.predic8.membrane.core.http.Request) Body(com.predic8.membrane.core.http.Body)

Example 49 with Request

use of com.predic8.membrane.core.http.Request in project service-proxy by membrane.

the class ReverseProxyingInterceptorTest method createExchange.

/**
 * Creates a fake exchange which simulates a received redirect by the server.
 */
private Exchange createExchange(String requestHostHeader, String requestDestinationHeader, int port, String requestURI, String redirectionURI) {
    Exchange exc = new Exchange(new FakeHttpHandler(port));
    Request req = new Request();
    req.setUri(requestURI);
    Header header = new Header();
    if (requestHostHeader != null)
        header.setHost(requestHostHeader);
    if (requestDestinationHeader != null)
        header.add(Header.DESTINATION, requestDestinationHeader);
    req.setHeader(header);
    exc.setRequest(req);
    if (redirectionURI != null) {
        Response res = Response.redirect(redirectionURI, false).build();
        exc.setResponse(res);
        exc.getDestinations().add(requestURI);
    }
    return exc;
}
Also used : Exchange(com.predic8.membrane.core.exchange.Exchange) Response(com.predic8.membrane.core.http.Response) Header(com.predic8.membrane.core.http.Header) FakeHttpHandler(com.predic8.membrane.core.transport.http.FakeHttpHandler) Request(com.predic8.membrane.core.http.Request)

Example 50 with Request

use of com.predic8.membrane.core.http.Request in project service-proxy by membrane.

the class WebServiceExplorerInterceptor method createOperationResponse.

@Mapping("[^?]*/operation/([^/?]+)/([^/?]+)/([^/?]+)")
public Response createOperationResponse(QueryParameter params, String relativeRootPath) throws Exception {
    try {
        final String bindingName = params.getGroup(1);
        final String portName = params.getGroup(2);
        final String operationName = params.getGroup(3);
        final Definitions w = getParsedWSDL();
        final Service service = getService(w);
        StringWriter sw = new StringWriter();
        new StandardPage(sw, null) {

            @Override
            protected void createContent() {
                h1().text("Service Proxy for " + service.getName());
                h2().text("Operation: " + operationName).end();
                h3().text("Sample Request").end();
                pre().text(generateSampleRequest(portName, operationName, bindingName, w)).end();
            }
        };
        return Response.ok(sw.toString()).build();
    } catch (IllegalArgumentException e) {
        log.error("", e);
        return Response.internalServerError().build();
    }
}
Also used : StringWriter(java.io.StringWriter) Definitions(com.predic8.wsdl.Definitions) Service(com.predic8.wsdl.Service) Mapping(com.predic8.membrane.core.interceptor.administration.Mapping)

Aggregations

Request (com.predic8.membrane.core.http.Request)39 Exchange (com.predic8.membrane.core.exchange.Exchange)20 Test (org.junit.Test)12 IOException (java.io.IOException)11 Header (com.predic8.membrane.core.http.Header)8 Response (com.predic8.membrane.core.http.Response)8 AbstractExchange (com.predic8.membrane.core.exchange.AbstractExchange)5 Message (com.predic8.membrane.core.http.Message)5 Outcome (com.predic8.membrane.core.interceptor.Outcome)5 Body (com.predic8.membrane.core.http.Body)3 Request (com.predic8.membrane.core.http.xml.Request)3 EndOfStreamException (com.predic8.membrane.core.util.EndOfStreamException)3 JsonGenerator (com.fasterxml.jackson.core.JsonGenerator)2 CacheBuilder (com.google.common.cache.CacheBuilder)2 HeaderField (com.predic8.membrane.core.http.HeaderField)2 ResponseBuilder (com.predic8.membrane.core.http.Response.ResponseBuilder)2 ResolverMap (com.predic8.membrane.core.resolver.ResolverMap)2 HttpClient (com.predic8.membrane.core.transport.http.HttpClient)2 StringReader (java.io.StringReader)2 SocketException (java.net.SocketException)2