Search in sources :

Example 1 with AS2HttpHeaderWrapperHttpURLConnection

use of com.helger.as2lib.util.http.AS2HttpHeaderWrapperHttpURLConnection in project as2-server by phax.

the class MainTestClient method updateHttpHeaders.

protected void updateHttpHeaders(@Nonnull final HttpURLConnection aConn, @Nonnull final IMessage aMsg) {
    final Partnership aPartnership = aMsg.partnership();
    final AS2HttpHeaderWrapperHttpURLConnection aHeaderWrapper = new AS2HttpHeaderWrapperHttpURLConnection(aConn);
    aHeaderWrapper.setHttpHeader(CHttpHeader.CONNECTION, CAS2Header.DEFAULT_CONNECTION);
    aHeaderWrapper.setHttpHeader(CHttpHeader.USER_AGENT, CAS2Header.DEFAULT_USER_AGENT);
    aHeaderWrapper.setHttpHeader(CHttpHeader.DATE, AS2DateHelper.getFormattedDateNow(CAS2Header.DEFAULT_DATE_FORMAT));
    aHeaderWrapper.setHttpHeader(CHttpHeader.MESSAGE_ID, aMsg.getMessageID());
    // make sure this is the encoding used in the msg, run TBF1
    aHeaderWrapper.setHttpHeader(CHttpHeader.MIME_VERSION, CAS2Header.DEFAULT_MIME_VERSION);
    aHeaderWrapper.setHttpHeader(CHttpHeader.CONTENT_TYPE, aMsg.getContentType());
    aHeaderWrapper.setHttpHeader(CHttpHeader.AS2_VERSION, CAS2Header.DEFAULT_AS2_VERSION);
    aHeaderWrapper.setHttpHeader(CHttpHeader.RECIPIENT_ADDRESS, aPartnership.getAS2URL());
    aHeaderWrapper.setHttpHeader(CHttpHeader.AS2_TO, aPartnership.getReceiverAS2ID());
    aHeaderWrapper.setHttpHeader(CHttpHeader.AS2_FROM, aPartnership.getSenderAS2ID());
    aHeaderWrapper.setHttpHeader(CHttpHeader.SUBJECT, aMsg.getSubject());
    aHeaderWrapper.setHttpHeader(CHttpHeader.FROM, aPartnership.getSenderEmail());
    final String sDispTo = aPartnership.getAS2MDNTo();
    if (sDispTo != null)
        aHeaderWrapper.setHttpHeader(CHttpHeader.DISPOSITION_NOTIFICATION_TO, sDispTo);
    final String sDispOptions = aPartnership.getAS2MDNOptions();
    if (sDispOptions != null)
        aHeaderWrapper.setHttpHeader(CHttpHeader.DISPOSITION_NOTIFICATION_OPTIONS, sDispOptions);
    // Async MDN 2007-03-12
    final String sReceiptOption = aPartnership.getAS2ReceiptDeliveryOption();
    if (sReceiptOption != null)
        aHeaderWrapper.setHttpHeader(CHttpHeader.RECEIPT_DELIVERY_OPTION, sReceiptOption);
    // As of 2007-06-01
    final String sContentDisp = aMsg.getContentDisposition();
    if (sContentDisp != null)
        aHeaderWrapper.setHttpHeader(CHttpHeader.CONTENT_DISPOSITION, sContentDisp);
}
Also used : Partnership(com.helger.as2lib.partner.Partnership) AS2HttpHeaderWrapperHttpURLConnection(com.helger.as2lib.util.http.AS2HttpHeaderWrapperHttpURLConnection)

Aggregations

Partnership (com.helger.as2lib.partner.Partnership)1 AS2HttpHeaderWrapperHttpURLConnection (com.helger.as2lib.util.http.AS2HttpHeaderWrapperHttpURLConnection)1