Package de.xima.fc.http
Class HttpPostRequestBuilder
- java.lang.Object
-
- de.xima.fc.http.HttpPostRequestBuilder
-
public class HttpPostRequestBuilder extends Object
Builder for an http post request, which use apache http components.- Since:
- 7.0.0
- Author:
- XIMA MEDIA GmbH
-
-
Constructor Summary
Constructors Constructor Description HttpPostRequestBuilder(String uri)HttpPostRequestBuilder(URI uri)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description HttpPostRequestBuilderaddBinayData(String elementName, byte[] data, String filename, @NotNull String mimeType)HttpPostRequestBuilderaddBinayData(String elementName, byte[] data, String filename, @NotNull String mimeType, @NotNull Charset charset)HttpPostRequestBuilderaddHeader(String name, String value)HttpPostRequestBuilderaddParameter(String name, String value)HttpPostRequestBuilderaddParameter(String name, String value, org.apache.http.entity.ContentType contentType)org.apache.http.client.methods.CloseableHttpResponsebuild()Performs the HTTP request to the server and returns the response.StringgetUrl()HttpPostRequestBuildersetBasicAuthLogin(String login)HttpPostRequestBuildersetBasicAuthPassword(String pwd)HttpPostRequestBuildersetInputCharset(Charset inputCharset)Sets the request character encoding.HttpPostRequestBuildersetProxyServer(@NotNull FcPostRequestProps.ProxyProps proxyConfig)Sets the following proxy server configuration parameters if defined inside theFcPostRequestProps.ProxyPropsobject: proxy server host proxy server port login for a proxy server authentication password for a proxy server authenticationHttpPostRequestBuildersetProxyServerAuth(@NotNull FcPostRequestProps.ProxyAuthProps proxyAuth)HttpPostRequestBuildersetProxyServerAuthLogin(String login)HttpPostRequestBuildersetProxyServerAuthPassword(String pwd)HttpPostRequestBuildersetProxyServerHost(String host)Sets the proxy server host.HttpPostRequestBuildersetProxyServerPort(int port)Sets the proxy server port.booleanuseBasicAuthentication()booleanuseProxyServer()booleanuseProxyServerAuthentication()
-
-
-
Constructor Detail
-
HttpPostRequestBuilder
public HttpPostRequestBuilder(URI uri)
- Parameters:
uri- The request URL. Whennull,URI.from("")is used.
-
HttpPostRequestBuilder
public HttpPostRequestBuilder(String uri) throws URISyntaxException
- Parameters:
uri- The request URL, must not benull- Throws:
URISyntaxException- When the given string is not a valid URI.
-
-
Method Detail
-
getUrl
public String getUrl()
- Returns:
- the request URL
-
useProxyServer
public boolean useProxyServer()
- Returns:
trueif the host and port for a proxy server use is set, otherwisefalse
-
useProxyServerAuthentication
public boolean useProxyServerAuthentication()
- Returns:
trueif an login and password for proxy server authentication is set, otherwisefalse
-
useBasicAuthentication
public boolean useBasicAuthentication()
- Returns:
trueif an login and password for basic authentication is set, otherwisetrue
-
setInputCharset
public HttpPostRequestBuilder setInputCharset(Charset inputCharset)
Sets the request character encoding.- Parameters:
inputCharset- encoding character set- Returns:
HttpPostRequestBuilderfor fluent API
-
setProxyServerHost
public HttpPostRequestBuilder setProxyServerHost(String host)
Sets the proxy server host.- Parameters:
host- proxy server host- Returns:
HttpPostRequestBuilderfor fluent API
-
setProxyServerPort
public HttpPostRequestBuilder setProxyServerPort(int port)
Sets the proxy server port.- Parameters:
port- proxy server port- Returns:
HttpPostRequestBuilderfor fluent API
-
setProxyServer
public HttpPostRequestBuilder setProxyServer(@NotNull @NotNull FcPostRequestProps.ProxyProps proxyConfig)
Sets the following proxy server configuration parameters if defined inside theFcPostRequestProps.ProxyPropsobject:- proxy server host
- proxy server port
- login for a proxy server authentication
- password for a proxy server authentication
- Parameters:
proxyConfig- the proxy server configuration- Returns:
HttpPostRequestBuilderfor fluent API
-
setProxyServerAuth
public HttpPostRequestBuilder setProxyServerAuth(@NotNull @NotNull FcPostRequestProps.ProxyAuthProps proxyAuth)
-
setProxyServerAuthLogin
public HttpPostRequestBuilder setProxyServerAuthLogin(String login)
-
setProxyServerAuthPassword
public HttpPostRequestBuilder setProxyServerAuthPassword(String pwd)
-
setBasicAuthLogin
public HttpPostRequestBuilder setBasicAuthLogin(String login)
-
setBasicAuthPassword
public HttpPostRequestBuilder setBasicAuthPassword(String pwd)
-
addParameter
public HttpPostRequestBuilder addParameter(String name, String value)
-
addParameter
public HttpPostRequestBuilder addParameter(String name, String value, org.apache.http.entity.ContentType contentType)
-
addHeader
public HttpPostRequestBuilder addHeader(String name, String value)
-
addBinayData
public HttpPostRequestBuilder addBinayData(String elementName, byte[] data, String filename, @NotNull @NotNull String mimeType) throws Exception
- Throws:
Exception
-
addBinayData
public HttpPostRequestBuilder addBinayData(String elementName, byte[] data, String filename, @NotNull @NotNull String mimeType, @NotNull @NotNull Charset charset) throws Exception
- Throws:
Exception
-
build
public org.apache.http.client.methods.CloseableHttpResponse build() throws IOExceptionPerforms the HTTP request to the server and returns the response.- Returns:
- The response that was obtained from the server.
- Throws:
IOException- When a network failure occurred and data could not be sent to the remote host or the response could not be received.
-
-