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 HttpPostRequestBuilder
addBinayData(String elementName, byte[] data, String filename, @NotNull String mimeType)
HttpPostRequestBuilder
addBinayData(String elementName, byte[] data, String filename, @NotNull String mimeType, @NotNull Charset charset)
HttpPostRequestBuilder
addHeader(String name, String value)
HttpPostRequestBuilder
addParameter(String name, String value)
HttpPostRequestBuilder
addParameter(String name, String value, org.apache.http.entity.ContentType contentType)
org.apache.http.client.methods.CloseableHttpResponse
build()
Performs the HTTP request to the server and returns the response.String
getUrl()
HttpPostRequestBuilder
setBasicAuthLogin(String login)
HttpPostRequestBuilder
setBasicAuthPassword(String pwd)
HttpPostRequestBuilder
setInputCharset(Charset inputCharset)
Sets the request character encoding.HttpPostRequestBuilder
setProxyServer(@NotNull FcPostRequestProps.ProxyProps proxyConfig)
Sets the following proxy server configuration parameters if defined inside theFcPostRequestProps.ProxyProps
object: proxy server host proxy server port login for a proxy server authentication password for a proxy server authenticationHttpPostRequestBuilder
setProxyServerAuth(@NotNull FcPostRequestProps.ProxyAuthProps proxyAuth)
HttpPostRequestBuilder
setProxyServerAuthLogin(String login)
HttpPostRequestBuilder
setProxyServerAuthPassword(String pwd)
HttpPostRequestBuilder
setProxyServerHost(String host)
Sets the proxy server host.HttpPostRequestBuilder
setProxyServerPort(int port)
Sets the proxy server port.boolean
useBasicAuthentication()
boolean
useProxyServer()
boolean
useProxyServerAuthentication()
-
-
-
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:
true
if the host and port for a proxy server use is set, otherwisefalse
-
useProxyServerAuthentication
public boolean useProxyServerAuthentication()
- Returns:
true
if an login and password for proxy server authentication is set, otherwisefalse
-
useBasicAuthentication
public boolean useBasicAuthentication()
- Returns:
true
if 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:
HttpPostRequestBuilder
for fluent API
-
setProxyServerHost
public HttpPostRequestBuilder setProxyServerHost(String host)
Sets the proxy server host.- Parameters:
host
- proxy server host- Returns:
HttpPostRequestBuilder
for fluent API
-
setProxyServerPort
public HttpPostRequestBuilder setProxyServerPort(int port)
Sets the proxy server port.- Parameters:
port
- proxy server port- Returns:
HttpPostRequestBuilder
for fluent API
-
setProxyServer
public HttpPostRequestBuilder setProxyServer(@NotNull @NotNull FcPostRequestProps.ProxyProps proxyConfig)
Sets the following proxy server configuration parameters if defined inside theFcPostRequestProps.ProxyProps
object:- 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:
HttpPostRequestBuilder
for 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 IOException
Performs 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.
-
-