Search in sources :

Example 1 with MutableHttpResponse

use of com.github.dreamhead.moco.MutableHttpResponse in project moco by dreamhead.

the class AbstractContentResponseHandler method writeToResponse.

@Override
public final void writeToResponse(final SessionContext context) {
    Request request = context.getRequest();
    Response response = context.getResponse();
    if (HttpRequest.class.isInstance(request) && MutableHttpResponse.class.isInstance(response)) {
        HttpRequest httpRequest = HttpRequest.class.cast(request);
        MutableHttpResponse httpResponse = MutableHttpResponse.class.cast(response);
        doWriteToResponse(httpRequest, httpResponse);
        return;
    }
    MutableResponse mutableResponse = MutableResponse.class.cast(response);
    mutableResponse.setContent(requireResponseContent(request));
}
Also used : MutableResponse(com.github.dreamhead.moco.MutableResponse) MutableHttpResponse(com.github.dreamhead.moco.MutableHttpResponse) Response(com.github.dreamhead.moco.Response) HttpRequest(com.github.dreamhead.moco.HttpRequest) MutableResponse(com.github.dreamhead.moco.MutableResponse) MutableHttpResponse(com.github.dreamhead.moco.MutableHttpResponse) HttpRequest(com.github.dreamhead.moco.HttpRequest) Request(com.github.dreamhead.moco.Request)

Example 2 with MutableHttpResponse

use of com.github.dreamhead.moco.MutableHttpResponse in project moco by dreamhead.

the class AbstractHttpResponseHandler method writeToResponse.

@Override
public final void writeToResponse(final SessionContext context) {
    Request request = context.getRequest();
    Response response = context.getResponse();
    if (HttpRequest.class.isInstance(request) && MutableHttpResponse.class.isInstance(response)) {
        HttpRequest httpRequest = HttpRequest.class.cast(request);
        MutableHttpResponse httpResponse = MutableHttpResponse.class.cast(response);
        doWriteToResponse(httpRequest, httpResponse);
    }
}
Also used : MutableHttpResponse(com.github.dreamhead.moco.MutableHttpResponse) Response(com.github.dreamhead.moco.Response) HttpRequest(com.github.dreamhead.moco.HttpRequest) MutableHttpResponse(com.github.dreamhead.moco.MutableHttpResponse) HttpRequest(com.github.dreamhead.moco.HttpRequest) Request(com.github.dreamhead.moco.Request)

Example 3 with MutableHttpResponse

use of com.github.dreamhead.moco.MutableHttpResponse in project moco by dreamhead.

the class AbstractProxyResponseHandler method doWriteToResponse.

@Override
protected final void doWriteToResponse(final HttpRequest httpRequest, final MutableHttpResponse httpResponse) {
    Optional<URL> url = remoteUrl(httpRequest);
    if (!url.isPresent()) {
        return;
    }
    HttpResponse response = doProxy(httpRequest, url.get());
    doWritHttpResponse(response, httpResponse);
}
Also used : MutableHttpResponse(com.github.dreamhead.moco.MutableHttpResponse) FullHttpResponse(io.netty.handler.codec.http.FullHttpResponse) HttpResponse(com.github.dreamhead.moco.HttpResponse) DefaultFullHttpResponse(io.netty.handler.codec.http.DefaultFullHttpResponse) URL(java.net.URL)

Aggregations

MutableHttpResponse (com.github.dreamhead.moco.MutableHttpResponse)3 HttpRequest (com.github.dreamhead.moco.HttpRequest)2 Request (com.github.dreamhead.moco.Request)2 Response (com.github.dreamhead.moco.Response)2 HttpResponse (com.github.dreamhead.moco.HttpResponse)1 MutableResponse (com.github.dreamhead.moco.MutableResponse)1 DefaultFullHttpResponse (io.netty.handler.codec.http.DefaultFullHttpResponse)1 FullHttpResponse (io.netty.handler.codec.http.FullHttpResponse)1 URL (java.net.URL)1