return null;
}
public void submitResponse(MessageContext msgContext)
throws IOException, HttpException {
SourceConfiguration sourceConfiguration = (SourceConfiguration) msgContext.getProperty(
RelayConstants.RELAY_SOURCE_CONFIGURATION);
NHttpServerConnection conn = (NHttpServerConnection) msgContext.getProperty(
RelayConstants.RELAY_SOURCE_CONNECTION);
SourceRequest sourceRequest = SourceContext.getRequest(conn);
SourceResponse sourceResponse = SourceResponseFactory.create(msgContext,
sourceRequest, sourceConfiguration);
SourceContext.setResponse(conn, sourceResponse);
Boolean noEntityBody = (Boolean) msgContext.getProperty(RelayConstants.NO_ENTITY_BODY);
Pipe pipe = (Pipe) msgContext.getProperty(RelayConstants.RELAY_PIPE);
if ((noEntityBody == null || !noEntityBody) || pipe != null) {
if (pipe != null) {
pipe.attachConsumer(conn);
sourceResponse.connect(pipe);
}
}
Integer errorCode = (Integer) msgContext.getProperty(RelayConstants.ERROR_CODE);
if (errorCode != null) {
sourceResponse.setStatus(HttpStatus.SC_BAD_GATEWAY);
SourceContext.get(conn).setShutDown(true);
}
ProtocolState state = SourceContext.getState(conn);
if (state != null && state.compareTo(ProtocolState.REQUEST_DONE) <= 0) {
// start sending the response if we
conn.requestOutput();
} else {
// nothing much to do as we have started the response already
if (errorCode != null) {
if (log.isDebugEnabled()) {
log.warn("A Source connection is closed because of an " +
"error in target: " + conn);
}
} else {
log.debug("A Source Connection is closed, because source handler " +
"is already in the process of writing a response while " +
"another response is submitted: " + conn);
}
SourceContext.updateState(conn, ProtocolState.CLOSED);
sourceConfiguration.getSourceConnections().shutDownConnection(conn);
}
}