use of com.predic8.membrane.core.http.Response in project service-proxy by membrane.
the class HttpUtil method createResponse.
public static Response createResponse(int code, String msg, byte[] body, String contentType, String... headers) {
Response res = new Response();
res.setStatusCode(code);
res.setStatusMessage(msg);
res.setHeader(createHeaders(contentType, headers));
if (body != null)
res.setBodyContent(body);
return res;
}
use of com.predic8.membrane.core.http.Response in project service-proxy by membrane.
the class HttpUtil method createSOAPValidationErrorResponse.
public static Response createSOAPValidationErrorResponse(String message) {
Response response = new Response();
response.setStatusCode(400);
response.setStatusMessage("Bad request");
response.setHeader(createHeaders(MimeType.TEXT_XML_UTF8));
response.setBodyContent(getFaultSOAPBody(message).getBytes(Constants.UTF_8_CHARSET));
return response;
}
use of com.predic8.membrane.core.http.Response in project service-proxy by membrane.
the class HttpServletHandler method writeResponse.
@SuppressWarnings("deprecation")
protected void writeResponse(Response res) throws Exception {
response.setStatus(res.getStatusCode(), res.getStatusMessage());
for (HeaderField header : res.getHeader().getAllHeaderFields()) {
if (header.getHeaderName().equals(Header.TRANSFER_ENCODING))
continue;
response.addHeader(header.getHeaderName().toString(), header.getValue());
}
ServletOutputStream out = response.getOutputStream();
res.getBody().write(new PlainBodyTransferrer(out));
out.flush();
response.flushBuffer();
exchange.setTimeResSent(System.currentTimeMillis());
exchange.collectStatistics();
}
use of com.predic8.membrane.core.http.Response 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;
}
use of com.predic8.membrane.core.http.Response in project service-proxy by membrane.
the class DynamicAdminPageInterceptor method handleNodeSessionsRequest.
@Mapping("/admin/node/sessions/?(\\?.*)?")
public Response handleNodeSessionsRequest(final Map<String, String> params, String relativeRootPath) throws Exception {
StringWriter writer = new StringWriter();
return respond(new AdminPageBuilder(writer, router, relativeRootPath, params, readOnly) {
@Override
protected int getSelectedTab() {
return TAB_ID_LOAD_BALANCING;
}
@Override
protected void createTabContent() throws Exception {
h2().text("Node " + params.get("host") + ":" + params.get("port")).end();
h3().text("Sessions").end();
createSessionsTable(BalancerUtil.lookupBalancer(router, getBalancerParam(params)).getSessionsByNode(params.get("cluster"), new Node(params.get("host"), Integer.parseInt(params.get("port")))));
}
}.createPage());
}
Aggregations