use of org.apache.cxf.transports.http.configuration.HTTPServerPolicy in project cxf by apache.
the class UndertowHTTPDestinationTest method testServerPolicyInServiceModel.
@Test
public void testServerPolicyInServiceModel() throws Exception {
policy = new HTTPServerPolicy();
address = getEPR("bar/foo");
bus = BusFactory.getDefaultBus(true);
transportFactory = new HTTPTransportFactory();
ServiceInfo serviceInfo = new ServiceInfo();
serviceInfo.setName(new QName("bla", "Service"));
endpointInfo = new EndpointInfo(serviceInfo, "");
endpointInfo.setName(new QName("bla", "Port"));
endpointInfo.addExtensor(policy);
engine = EasyMock.createMock(UndertowHTTPServerEngine.class);
EasyMock.replay();
endpointInfo.setAddress(NOWHERE + "bar/foo");
UndertowHTTPDestination dest = new EasyMockUndertowHTTPDestination(bus, transportFactory.getRegistry(), endpointInfo, null, engine);
assertEquals(policy, dest.getServer());
}
use of org.apache.cxf.transports.http.configuration.HTTPServerPolicy in project cxf by apache.
the class AbstractHTTPDestination method flushHeaders.
protected OutputStream flushHeaders(Message outMessage, boolean getStream) throws IOException {
if (isResponseRedirected(outMessage)) {
return null;
}
cacheInput(outMessage);
HTTPServerPolicy sp = calcServerPolicy(outMessage);
if (sp != null) {
new Headers(outMessage).setFromServerPolicy(sp);
}
OutputStream responseStream = null;
boolean oneWay = isOneWay(outMessage);
HttpServletResponse response = getHttpResponseFromMessage(outMessage);
int responseCode = getReponseCodeFromMessage(outMessage);
if (responseCode >= 300) {
String ec = (String) outMessage.get(Message.ERROR_MESSAGE);
if (!StringUtils.isEmpty(ec)) {
response.sendError(responseCode, ec);
return null;
}
}
response.setStatus(responseCode);
new Headers(outMessage).copyToResponse(response);
outMessage.put(RESPONSE_HEADERS_COPIED, "true");
if (hasNoResponseContent(outMessage)) {
response.setContentLength(0);
response.flushBuffer();
closeResponseOutputStream(response);
} else if (!getStream) {
closeResponseOutputStream(response);
} else {
responseStream = response.getOutputStream();
}
if (oneWay) {
outMessage.remove(HTTP_RESPONSE);
}
return responseStream;
}
Aggregations