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));
}
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);
}
}
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);
}
Aggregations