}
InputStream in = null;
// oneway or decoupled twoway calls may expect HTTP 202 with no content
Message inMessage = new MessageImpl();
inMessage.setExchange(exchange);
updateResponseHeaders(inMessage);
inMessage.put(Message.RESPONSE_CODE, responseCode);
if (!doProcessResponse(outMessage, responseCode)
|| HttpURLConnection.HTTP_ACCEPTED == responseCode) {
in = getPartialResponse();
if (in == null
|| !MessageUtils.getContextualBoolean(outMessage, Message.PROCESS_ONEWAY_RESPONSE, false)) {
// oneway operation or decoupled MEP without
// partial response
closeInputStream();
if (isOneway(exchange) && responseCode > 300) {
throw new HTTPException(responseCode, getResponseMessage(), url.toURL());
}
ClientCallback cc = exchange.get(ClientCallback.class);
if (null != cc) {
//REVISIT move the decoupled destination property name into api
Endpoint ep = exchange.getEndpoint();
if (null != ep && null != ep.getEndpointInfo() && null == ep.getEndpointInfo().
getProperty("org.apache.cxf.ws.addressing.MAPAggregator.decoupledDestination")) {
cc.handleResponse(null, null);
}
}
exchange.setInMessage(inMessage);
return;
}
} else {
//not going to be resending or anything, clear out the stuff in the out message
//to free memory
outMessage.removeContent(OutputStream.class);
if (cachingForRetransmission && cachedStream != null) {
cachedStream.close();
}
cachedStream = null;
}
String charset = HttpHeaderHelper.findCharset((String)inMessage.get(Message.CONTENT_TYPE));
String normalizedEncoding = HttpHeaderHelper.mapCharset(charset);
if (normalizedEncoding == null) {
String m = new org.apache.cxf.common.i18n.Message("INVALID_ENCODING_MSG",
LOG, charset).toString();
LOG.log(Level.WARNING, m);
throw new IOException(m);
}
inMessage.put(Message.ENCODING, normalizedEncoding);
if (in == null) {
in = getInputStream();
}
if (in == null) {
// Create an empty stream to avoid NullPointerExceptions
in = new ByteArrayInputStream(new byte[] {});
}
inMessage.setContent(InputStream.class, in);
incomingObserver.onMessage(inMessage);
}