Package com.helger.phase4.http
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 TypeMethodDescriptioncom.helger.httpclient.HttpClientFactoryConsumer<? super org.apache.hc.client5.http.classic.methods.HttpPost>boolean<T> TsendGenericMessage(String sURL, com.helger.commons.http.HttpHeaderMap aCustomHttpHeaders, org.apache.hc.core5.http.HttpEntity aHttpEntity, org.apache.hc.core5.http.io.HttpClientResponseHandler<? extends T> aResponseHandler) Send an arbitrary HTTP POST message to the provided URL, using the contained HttpClientFactory as well as the customizer.<T> TsendGenericMessageWithRetries(String sURL, com.helger.commons.http.HttpHeaderMap aCustomHttpHeaders, org.apache.hc.core5.http.HttpEntity aHttpEntity, String sMessageID, HttpRetrySettings aRetrySettings, org.apache.hc.core5.http.io.HttpClientResponseHandler<? extends T> aResponseHandler, IAS4OutgoingDumper aOutgoingDumper, IAS4RetryCallback aRetryCallback) Send an arbitrary HTTP POST message to the provided URL, using the contained HttpClientFactory as well as the customizer.setHttpClientFactory(com.helger.httpclient.HttpClientFactory aHttpClientFactory) Set the HTTP client provider to be used.setHttpCustomizer(Consumer<? super org.apache.hc.client5.http.classic.methods.HttpPost> aHttpCustomizer) Set the HTTP Post Customizer to be used.setQuoteHttpHeaders(boolean bQuoteHttpHeaders) Enable or disable, if HTTP header values should be quoted or not.
-
Method Details
-
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. SeeBasicHttpPoster.createDefaultHttpClientFactory()as the default implementation ofIHttpClientProvider. This factory is used for http sending.- Parameters:
aHttpClientFactory- The HTTP client factory to be used. May not benull.- Returns:
- this for chaining
-
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 benull.- Returns:
- this for chaining
-
isQuoteHttpHeaders
boolean isQuoteHttpHeaders()- Returns:
trueif HTTP header values should be quoted if they contain forbidden characters,falseif not.
-
setQuoteHttpHeaders
Enable or disable, if HTTP header values should be quoted or not. For compatibility it is recommended, to not quote the values.- Parameters:
bQuoteHttpHeaders-trueto quote them,falseto not quote them.- Returns:
- this for chaining
-
sendGenericMessage
@Nullable <T> T sendGenericMessage(@Nonnull @Nonempty String sURL, @Nullable com.helger.commons.http.HttpHeaderMap aCustomHttpHeaders, @Nonnull org.apache.hc.core5.http.HttpEntity aHttpEntity, @Nonnull org.apache.hc.core5.http.io.HttpClientResponseHandler<? extends T> aResponseHandler) 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- Type Parameters:
T- Response data type- Parameters:
sURL- The URL to send to. May neither benullnor empty.aCustomHttpHeaders- An optional http header map that should be applied. May benull.aHttpEntity- The HTTP entity to be send. May not benull.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
nullbut basically depends on the response handler. - Throws:
IOException- In case of IO error
-
sendGenericMessageWithRetries
@Nullable <T> T sendGenericMessageWithRetries(@Nonnull String sURL, @Nullable com.helger.commons.http.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 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 benullnor empty.aCustomHttpHeaders- An optional http header map that should be applied. May benull.aHttpEntity- The HTTP entity to be send. May not benull.sMessageID- the AS4 message ID. May not benull.aRetrySettings- The retry settings to use. May not benull.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 benullto 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
nullbut basically depends on the response handler. - Throws:
IOException- In case of IO error
-