use of com.helger.as2lib.util.http.AS2HttpResponseHandlerSocket in project as2-lib by phax.
the class AS2MDNReceiverHandler method handle.
public void handle(@Nonnull final AbstractActiveNetModule aOwner, @Nonnull final Socket aSocket) {
final String sClientInfo = getClientInfo(aSocket);
if (LOGGER.isInfoEnabled())
LOGGER.info("incoming connection for receiving AsyncMDN [" + sClientInfo + "]");
final AS2Message aMsg = new AS2Message();
final boolean bQuoteHeaderValues = m_aReceiverModule.isQuoteHeaderValues();
final IAS2HttpResponseHandler aResponseHandler = new AS2HttpResponseHandlerSocket(aSocket, bQuoteHeaderValues);
// Time the transmission
final StopWatch aSW = StopWatch.createdStarted();
DataSource aMdnDataSource = null;
try {
// Read in the message request, headers, and data
final IHTTPIncomingDumper aIncomingDumper = getEffectiveHttpIncomingDumper();
aMdnDataSource = HTTPHelper.readAndDecodeHttpRequest(new AS2HttpRequestDataProviderInputStream(aSocket.getInputStream()), aResponseHandler, aMsg, aIncomingDumper);
} catch (final Exception ex) {
new AS2NetException(aSocket.getInetAddress(), aSocket.getPort(), ex).terminate();
}
aSW.stop();
if (aMdnDataSource == null) {
LOGGER.error("Not having a data source to operate on");
} else {
if (aMdnDataSource instanceof ByteArrayDataSource) {
if (LOGGER.isInfoEnabled())
LOGGER.info("received " + AS2IOHelper.getTransferRate(((ByteArrayDataSource) aMdnDataSource).directGetBytes().length, aSW) + " from " + sClientInfo + aMsg.getLoggingText());
} else {
LOGGER.info("received message from " + sClientInfo + aMsg.getLoggingText() + " in " + aSW.getMillis() + " ms");
}
handleIncomingMessage(sClientInfo, aMdnDataSource, aMsg, aResponseHandler);
}
}
use of com.helger.as2lib.util.http.AS2HttpResponseHandlerSocket in project as2-lib by phax.
the class AS2ReceiverHandler method handle.
public void handle(@Nonnull final AbstractActiveNetModule aOwner, @Nonnull final Socket aSocket) {
final String sClientInfo = getClientInfo(aSocket);
if (LOGGER.isInfoEnabled())
LOGGER.info("Incoming connection " + sClientInfo);
final AS2Message aMsg = createMessage(aSocket);
final boolean bQuoteHeaderValues = m_aReceiverModule.isQuoteHeaderValues();
final IAS2HttpResponseHandler aResponseHandler = new AS2HttpResponseHandlerSocket(aSocket, bQuoteHeaderValues);
// Time the transmission
final StopWatch aSW = StopWatch.createdStarted();
DataSource aMsgDataSource = null;
try {
// Read in the message request, headers, and data
final IHTTPIncomingDumper aIncomingDumper = getEffectiveHttpIncomingDumper();
aMsgDataSource = HTTPHelper.readAndDecodeHttpRequest(new AS2HttpRequestDataProviderInputStream(aSocket.getInputStream()), aResponseHandler, aMsg, aIncomingDumper);
} catch (final Exception ex) {
new AS2NetException(aSocket.getInetAddress(), aSocket.getPort(), ex).terminate();
}
aSW.stop();
if (aMsgDataSource == null) {
LOGGER.error("Not having a data source to operate on");
} else {
if (aMsgDataSource instanceof ByteArrayDataSource) {
if (LOGGER.isInfoEnabled())
LOGGER.info("received " + AS2IOHelper.getTransferRate(((ByteArrayDataSource) aMsgDataSource).directGetBytes().length, aSW) + " from " + sClientInfo + aMsg.getLoggingText());
} else {
LOGGER.info("received message from " + sClientInfo + aMsg.getLoggingText() + " in " + aSW.getMillis() + " ms");
}
handleIncomingMessage(sClientInfo, aMsgDataSource, aMsg, aResponseHandler);
}
}
Aggregations