Interface IHttpPoster

All Known Implementing Classes:
BasicHttpPoster

public interface IHttpPoster
Interface for an HTTP POST sender.
Since:
0.13.0
Author:
Philip Helger
  • Method Summary

    Modifier and Type
    Method
    Description
    @NonNull com.helger.httpclient.HttpClientFactory
     
    @Nullable Consumer<? super org.apache.hc.client5.http.classic.methods.HttpPost>
     
    boolean
     
    <T> @Nullable T
    sendGenericMessage(@NonNull @Nonempty String sURL, @Nullable com.helger.http.header.HttpHeaderMap aCustomHttpHeaders, @NonNull org.apache.hc.core5.http.HttpEntity aHttpEntity, @NonNull org.apache.hc.core5.http.io.HttpClientResponseHandler<? extends T> aResponseHandler)
    Deprecated, for removal: This API element is subject to removal in a future version.
    default <T> @Nullable T
    sendGenericMessage(@NonNull @Nonempty String sURL, @Nullable com.helger.http.header.HttpHeaderMap aCustomHttpHeaders, @NonNull org.apache.hc.core5.http.HttpEntity aHttpEntity, @NonNull org.apache.hc.core5.http.io.HttpClientResponseHandler<? extends T> aResponseHandler, @Nullable Consumer<? super com.helger.collection.commons.ICommonsList<X509Certificate>> aRemoteTlsCertConsumer)
    Send an arbitrary HTTP POST message to the provided URL, using the contained HttpClientFactory as well as the customizer.
    <T> @Nullable T
    sendGenericMessageWithRetries(@NonNull String sURL, @Nullable com.helger.http.header.HttpHeaderMap aCustomHttpHeaders, @NonNull org.apache.hc.core5.http.HttpEntity aHttpEntity, @NonNull String sMessageID, @NonNull HttpRetrySettings aRetrySettings, @NonNull org.apache.hc.core5.http.io.HttpClientResponseHandler<? extends T> aResponseHandler, @Nullable IAS4OutgoingDumper aOutgoingDumper, @Nullable IAS4RetryCallback aRetryCallback)
    Deprecated, for removal: This API element is subject to removal in a future version.
    default <T> @Nullable T
    sendGenericMessageWithRetries(@NonNull String sURL, @Nullable com.helger.http.header.HttpHeaderMap aCustomHttpHeaders, @NonNull org.apache.hc.core5.http.HttpEntity aHttpEntity, @NonNull String sMessageID, @NonNull HttpRetrySettings aRetrySettings, @NonNull org.apache.hc.core5.http.io.HttpClientResponseHandler<? extends T> aResponseHandler, @Nullable IAS4OutgoingDumper aOutgoingDumper, @Nullable IAS4RetryCallback aRetryCallback, @Nullable Consumer<? super com.helger.collection.commons.ICommonsList<X509Certificate>> aRemoteTlsPeerCertConsumer)
    Same as sendGenericMessageWithRetries(String, HttpHeaderMap, HttpEntity, String, HttpRetrySettings, HttpClientResponseHandler, IAS4OutgoingDumper, IAS4RetryCallback) but additionally surfaces the remote TLS server certificates of the (last) successful HTTPS exchange to the provided consumer.
    @NonNull IHttpPoster
    setHttpClientFactory(@NonNull com.helger.httpclient.HttpClientFactory aHttpClientFactory)
    Set the HTTP client provider to be used.
    @NonNull IHttpPoster
    setHttpCustomizer(@Nullable Consumer<? super org.apache.hc.client5.http.classic.methods.HttpPost> aHttpCustomizer)
    Set the HTTP Post Customizer to be used.
    @NonNull IHttpPoster
    setQuoteHttpHeaders(boolean bQuoteHttpHeaders)
    Enable or disable, if HTTP header values should be quoted or not.
  • Method Details

    • getHttpClientFactory

      @NonNull com.helger.httpclient.HttpClientFactory getHttpClientFactory()
      Returns:
      The internal http client factory used for http sending. May not be null.
    • setHttpClientFactory

      @NonNull IHttpPoster setHttpClientFactory(@NonNull com.helger.httpclient.HttpClientFactory aHttpClientFactory)
      Set the HTTP client provider to be used. This is e.g. necessary when a custom SSL context or a proxy server is to be used. See BasicHttpPoster.createDefaultHttpClientFactory() as the default implementation of IHttpClientProvider. This factory is used for http sending.
      Parameters:
      aHttpClientFactory - The HTTP client factory to be used. May not be null.
      Returns:
      this for chaining
    • getHttpCustomizer

      @Nullable Consumer<? super org.apache.hc.client5.http.classic.methods.HttpPost> getHttpCustomizer()
      Returns:
      The HTTP Post customizer to be used. May be null.
    • setHttpCustomizer

      @NonNull IHttpPoster setHttpCustomizer(@Nullable Consumer<? super org.apache.hc.client5.http.classic.methods.HttpPost> aHttpCustomizer)
      Set the HTTP Post Customizer to be used.
      Parameters:
      aHttpCustomizer - The new customizer. May be null.
      Returns:
      this for chaining
    • isQuoteHttpHeaders

      boolean isQuoteHttpHeaders()
      Returns:
      true if HTTP header values should be quoted if they contain forbidden characters, false if not.
    • setQuoteHttpHeaders

      @NonNull IHttpPoster setQuoteHttpHeaders(boolean bQuoteHttpHeaders)
      Enable or disable, if HTTP header values should be quoted or not. For compatibility it is recommended, to not quote the values.
      Parameters:
      bQuoteHttpHeaders - true to quote them, false to not quote them.
      Returns:
      this for chaining
    • sendGenericMessage

      @Deprecated(forRemoval=true, since="4.5.1") <T> @Nullable T sendGenericMessage(@Nonempty @NonNull @Nonempty String sURL, @Nullable com.helger.http.header.HttpHeaderMap aCustomHttpHeaders, @NonNull org.apache.hc.core5.http.HttpEntity aHttpEntity, @NonNull org.apache.hc.core5.http.io.HttpClientResponseHandler<? extends T> aResponseHandler) throws IOException
      Deprecated, for removal: This API element is subject to removal in a future version.
      Send an arbitrary HTTP POST message to the provided URL, using the contained HttpClientFactory as well as the customizer. Additionally the AS4 HTTP debugging is invoked in here.
      This method does NOT retry
      Type Parameters:
      T - Response data type
      Parameters:
      sURL - The URL to send to. May neither be null nor empty.
      aCustomHttpHeaders - An optional http header map that should be applied. May be null.
      aHttpEntity - The HTTP entity to be send. May not be null.
      aResponseHandler - The HTTP response handler that should be used to convert the HTTP response to a domain object.
      Returns:
      The HTTP response data as indicated by the ResponseHandler. Should not be null but basically depends on the response handler.
      Throws:
      IOException - In case of IO error
    • sendGenericMessage

      default <T> @Nullable T sendGenericMessage(@Nonempty @NonNull @Nonempty String sURL, @Nullable com.helger.http.header.HttpHeaderMap aCustomHttpHeaders, @NonNull org.apache.hc.core5.http.HttpEntity aHttpEntity, @NonNull org.apache.hc.core5.http.io.HttpClientResponseHandler<? extends T> aResponseHandler, @Nullable Consumer<? super com.helger.collection.commons.ICommonsList<X509Certificate>> aRemoteTlsCertConsumer) throws IOException
      Send an arbitrary HTTP POST message to the provided URL, using the contained HttpClientFactory as well as the customizer. Additionally the AS4 HTTP debugging is invoked in here. This method does NOT retry. Compared to sendGenericMessage(String, HttpHeaderMap, HttpEntity, HttpClientResponseHandler) this variant additionally surfaces the remote TLS server certificates of the underlying HTTPS connection.

      The default implementation ignores the consumer and simply forwards to the cert-less variant, which preserves backward compatibility for custom implementations of this interface.

      Type Parameters:
      T - Response data type
      Parameters:
      sURL - The URL to send to. May neither be null nor empty.
      aCustomHttpHeaders - An optional http header map that should be applied. May be null.
      aHttpEntity - The HTTP entity to be send. May not be null.
      aResponseHandler - The HTTP response handler that should be used to convert the HTTP response to a domain object.
      aRemoteTlsCertConsumer - An optional consumer that is invoked with the remote TLS server certificates after a successful HTTPS request. May be null. The list passed in may be null if no certificates were captured (e.g. plain HTTP).
      Returns:
      The HTTP response data as indicated by the ResponseHandler. Should not be null but basically depends on the response handler.
      Throws:
      IOException - In case of IO error
      Since:
      4.5.1
    • sendGenericMessageWithRetries

      @Deprecated(forRemoval=true, since="4.5.1") <T> @Nullable T sendGenericMessageWithRetries(@NonNull String sURL, @Nullable com.helger.http.header.HttpHeaderMap aCustomHttpHeaders, @NonNull org.apache.hc.core5.http.HttpEntity aHttpEntity, @NonNull String sMessageID, @NonNull HttpRetrySettings aRetrySettings, @NonNull org.apache.hc.core5.http.io.HttpClientResponseHandler<? extends T> aResponseHandler, @Nullable IAS4OutgoingDumper aOutgoingDumper, @Nullable IAS4RetryCallback aRetryCallback) throws IOException
      Deprecated, for removal: This API element is subject to removal in a future version.
      Send an arbitrary HTTP POST message to the provided URL, using the contained HttpClientFactory as well as the customizer. Additionally the AS4 HTTP debugging is invoked in here.
      Type Parameters:
      T - Response data type
      Parameters:
      sURL - The URL to send to. May neither be null nor empty.
      aCustomHttpHeaders - An optional http header map that should be applied. May be null.
      aHttpEntity - The HTTP entity to be send. May not be null.
      sMessageID - the AS4 message ID. May not be null.
      aRetrySettings - The retry settings to use. May not be null.
      aResponseHandler - The HTTP response handler that should be used to convert the HTTP response to a domain object.
      aOutgoingDumper - An optional outgoing dumper for this message. May be null to use the global one.
      aRetryCallback - An optional retry callback that is invoked, before a retry happens.
      Returns:
      The HTTP response data as indicated by the ResponseHandler. Should not be null but basically depends on the response handler.
      Throws:
      IOException - In case of IO error
    • sendGenericMessageWithRetries

      default <T> @Nullable T sendGenericMessageWithRetries(@NonNull String sURL, @Nullable com.helger.http.header.HttpHeaderMap aCustomHttpHeaders, @NonNull org.apache.hc.core5.http.HttpEntity aHttpEntity, @NonNull String sMessageID, @NonNull HttpRetrySettings aRetrySettings, @NonNull org.apache.hc.core5.http.io.HttpClientResponseHandler<? extends T> aResponseHandler, @Nullable IAS4OutgoingDumper aOutgoingDumper, @Nullable IAS4RetryCallback aRetryCallback, @Nullable Consumer<? super com.helger.collection.commons.ICommonsList<X509Certificate>> aRemoteTlsPeerCertConsumer) throws IOException
      Same as sendGenericMessageWithRetries(String, HttpHeaderMap, HttpEntity, String, HttpRetrySettings, HttpClientResponseHandler, IAS4OutgoingDumper, IAS4RetryCallback) but additionally surfaces the remote TLS server certificates of the (last) successful HTTPS exchange to the provided consumer.

      The default implementation ignores the consumer and simply forwards to the cert-less variant, which preserves backward compatibility for custom implementations of this interface.

      Type Parameters:
      T - Response data type
      Parameters:
      sURL - The URL to send to. May neither be null nor empty.
      aCustomHttpHeaders - An optional http header map that should be applied. May be null.
      aHttpEntity - The HTTP entity to be send. May not be null.
      sMessageID - the AS4 message ID. May not be null.
      aRetrySettings - The retry settings to use. May not be null.
      aResponseHandler - The HTTP response handler that should be used to convert the HTTP response to a domain object.
      aOutgoingDumper - An optional outgoing dumper for this message. May be null to use the global one.
      aRetryCallback - An optional retry callback that is invoked, before a retry happens. May be null.
      aRemoteTlsPeerCertConsumer - An optional consumer that is invoked with the remote TLS server certificates after each successful HTTPS attempt. May be null. The list passed in may be null if no certificates were captured (e.g. plain HTTP).
      Returns:
      The HTTP response data as indicated by the ResponseHandler. Should not be null but basically depends on the response handler.
      Throws:
      IOException - In case of IO error
      Since:
      4.5.1