Class HttpRequestBuilderBase<T extends HttpRequestBuilder<?>>
java.lang.Object
org.spincast.plugins.httpclient.builders.HttpRequestBuilderBase<T>
- All Implemented Interfaces:
HttpRequestBuilder<T>
- Direct Known Subclasses:
BodySenderRequestBuilderBaseDefault
,ConnectRequestBuilderDefault
,DeleteRequestBuilderDefault
,GetRequestBuilderDefault
,HeadRequestBuilderDefault
,HttpSpincastRequestBuilderBase
,OptionsRequestBuilderDefault
,WebsocketRequestBuilderDefault
public abstract class HttpRequestBuilderBase<T extends HttpRequestBuilder<?>>
extends Object
implements HttpRequestBuilder<T>
Http client builders base class.
-
Constructor Summary
ConstructorDescriptionHttpRequestBuilderBase
(String url, CookieFactory cookieFactory, HttpResponseFactory spincastHttpResponseFactory, SpincastHttpClientUtils spincastHttpClientUtils, SpincastHttpClientConfig spincastHttpClientConfig) Constructor -
Method Summary
Modifier and TypeMethodDescriptionaddHeaderValue
(String key, String value) Adds a value to the specified header.addHeaderValues
(String key, List<String> values) Adds some values to the specified header.Adds anAccept
head forHTML
.Adds anAccept
head forJson
.Adds anAccept
head forplain text
.Adds anAccept
head forXML
.protected org.spincast.shaded.org.apache.http.cookie.Cookie
convertToApacheCookie
(Cookie cookie) Converts a Spincast cookie to an Apache one.protected String
protected String
protected org.spincast.shaded.org.apache.http.client.HttpClient
Creates the HTTPClient with a cookies store.protected org.spincast.shaded.org.apache.http.impl.client.HttpClientBuilder
protected abstract org.spincast.shaded.org.apache.http.client.methods.HttpRequestBase
Creates the HttpRequestBase depending on the HTTP method.Disables automatic handling of redirects.Disables someSSL
certificates errors (such as self-signed certificate errors).protected String
protected CookieFactory
protected org.spincast.shaded.org.apache.http.client.CookieStore
protected String
protected String
protected org.spincast.shaded.org.apache.http.client.HttpClient
protected org.spincast.shaded.org.apache.http.impl.client.HttpClientBuilder
protected org.spincast.shaded.org.apache.http.protocol.HttpRequestExecutor
protected org.spincast.shaded.org.apache.http.client.config.RequestConfig
protected SpincastHttpClientConfig
protected SpincastHttpClientUtils
protected HttpResponseFactory
protected String
getUrl()
protected boolean
protected boolean
send()
Sends the request and gets the HTTP response.protected org.spincast.shaded.org.apache.http.HttpResponse
Sets a cookie.Sets a cookie, secure or not.Sets a cookie.setCookies
(Collection<Cookie> cookies) Sets some cookies.protected void
setCookieStore
(org.spincast.shaded.org.apache.http.client.CookieStore cookieStore) setHeaders
(Map<String, List<String>> headers) Sets the headers.setHeaderValues
(String key, List<String> values) Sets the values of the specified header.setHttpAuthCredentials
(String username, String password) Set HTTP authentication credentials.setHttpClientBuilder
(org.spincast.shaded.org.apache.http.impl.client.HttpClientBuilder httpClientBuilder) Sets a specificHttpClientBuilder
to use.setRequestConfig
(org.spincast.shaded.org.apache.http.client.config.RequestConfig requestConfig) Sets a customRequestConfig
to use.
-
Constructor Details
-
HttpRequestBuilderBase
public HttpRequestBuilderBase(String url, CookieFactory cookieFactory, HttpResponseFactory spincastHttpResponseFactory, SpincastHttpClientUtils spincastHttpClientUtils, SpincastHttpClientConfig spincastHttpClientConfig) Constructor
-
-
Method Details
-
getSpincastHttpResponseFactory
-
isDisableSslCertificateErrors
protected boolean isDisableSslCertificateErrors() -
isDisableRedirectHandling
protected boolean isDisableRedirectHandling() -
getSpincastHttpClientUtils
-
getSpincastHttpClientConfig
-
createHttpClient
protected org.spincast.shaded.org.apache.http.client.HttpClient createHttpClient()Creates the HTTPClient with a cookies store. -
getHttpClientBuilder
protected org.spincast.shaded.org.apache.http.impl.client.HttpClientBuilder getHttpClientBuilder() -
getHttpRequestExecutor
protected org.spincast.shaded.org.apache.http.protocol.HttpRequestExecutor getHttpRequestExecutor() -
createHttpClientBuilder
protected org.spincast.shaded.org.apache.http.impl.client.HttpClientBuilder createHttpClientBuilder() -
setHttpClientBuilder
public T setHttpClientBuilder(org.spincast.shaded.org.apache.http.impl.client.HttpClientBuilder httpClientBuilder) Description copied from interface:HttpRequestBuilder
Sets a specificHttpClientBuilder
to use. If not provided, a default one will be used.- Specified by:
setHttpClientBuilder
in interfaceHttpRequestBuilder<T extends HttpRequestBuilder<?>>
-
disableSslCertificateErrors
Description copied from interface:HttpRequestBuilder
Disables someSSL
certificates errors (such as self-signed certificate errors).SSL
certificate errors are not disabled by default.Be sure you know what you are doing if you disable this! It may lead to some security concerns!
- Specified by:
disableSslCertificateErrors
in interfaceHttpRequestBuilder<T extends HttpRequestBuilder<?>>
-
disableRedirectHandling
Description copied from interface:HttpRequestBuilder
Disables automatic handling of redirects.By default, the client will automatically follow a redirect response. Calling this will allow you to get the actual redirect HTTP status.
- Specified by:
disableRedirectHandling
in interfaceHttpRequestBuilder<T extends HttpRequestBuilder<?>>
-
setCookieStore
protected void setCookieStore(org.spincast.shaded.org.apache.http.client.CookieStore cookieStore) -
getHttpClient
protected org.spincast.shaded.org.apache.http.client.HttpClient getHttpClient() -
getCookieFactory
-
getUrl
-
getCookieStore
protected org.spincast.shaded.org.apache.http.client.CookieStore getCookieStore() -
setCookie
Description copied from interface:HttpRequestBuilder
Sets a cookie. Secure by default (HTTPS only)!- Specified by:
setCookie
in interfaceHttpRequestBuilder<T extends HttpRequestBuilder<?>>
-
setCookie
Description copied from interface:HttpRequestBuilder
Sets a cookie, secure or not.- Specified by:
setCookie
in interfaceHttpRequestBuilder<T extends HttpRequestBuilder<?>>
-
setCookie
Description copied from interface:HttpRequestBuilder
Sets a cookie.- Specified by:
setCookie
in interfaceHttpRequestBuilder<T extends HttpRequestBuilder<?>>
-
setCookies
Description copied from interface:HttpRequestBuilder
Sets some cookies.- Specified by:
setCookies
in interfaceHttpRequestBuilder<T extends HttpRequestBuilder<?>>
-
convertToApacheCookie
Converts a Spincast cookie to an Apache one. -
convertToApacheCookieTweakName
-
convertToApacheCookieTweakValue
-
setHeaders
Description copied from interface:HttpRequestBuilder
Sets the headers. Existing headers will be overwritten.- Specified by:
setHeaders
in interfaceHttpRequestBuilder<T extends HttpRequestBuilder<?>>
-
addHeaderValue
Description copied from interface:HttpRequestBuilder
Adds a value to the specified header. Existing values will be kept.- Specified by:
addHeaderValue
in interfaceHttpRequestBuilder<T extends HttpRequestBuilder<?>>
-
addHeaderValues
Description copied from interface:HttpRequestBuilder
Adds some values to the specified header. Existing values will be kept.- Specified by:
addHeaderValues
in interfaceHttpRequestBuilder<T extends HttpRequestBuilder<?>>
-
setHeaderValues
Description copied from interface:HttpRequestBuilder
Sets the values of the specified header. Existing values of this header will be overwritten.- Specified by:
setHeaderValues
in interfaceHttpRequestBuilder<T extends HttpRequestBuilder<?>>
-
getHeaders
-
addJsonAcceptHeader
Description copied from interface:HttpRequestBuilder
Adds anAccept
head forJson
.- Specified by:
addJsonAcceptHeader
in interfaceHttpRequestBuilder<T extends HttpRequestBuilder<?>>
-
addXMLAcceptHeader
Description copied from interface:HttpRequestBuilder
Adds anAccept
head forXML
.- Specified by:
addXMLAcceptHeader
in interfaceHttpRequestBuilder<T extends HttpRequestBuilder<?>>
-
addHTMLAcceptHeader
Description copied from interface:HttpRequestBuilder
Adds anAccept
head forHTML
.- Specified by:
addHTMLAcceptHeader
in interfaceHttpRequestBuilder<T extends HttpRequestBuilder<?>>
-
addPlainTextAcceptHeader
Description copied from interface:HttpRequestBuilder
Adds anAccept
head forplain text
.- Specified by:
addPlainTextAcceptHeader
in interfaceHttpRequestBuilder<T extends HttpRequestBuilder<?>>
-
setRequestConfig
public T setRequestConfig(org.spincast.shaded.org.apache.http.client.config.RequestConfig requestConfig) Description copied from interface:HttpRequestBuilder
Sets a customRequestConfig
to use. If not provided, a default one will be used.- Specified by:
setRequestConfig
in interfaceHttpRequestBuilder<T extends HttpRequestBuilder<?>>
-
getRequestConfig
protected org.spincast.shaded.org.apache.http.client.config.RequestConfig getRequestConfig() -
getCookieEncoding
-
setHttpAuthCredentials
Description copied from interface:HttpRequestBuilder
Set HTTP authentication credentials.- Specified by:
setHttpAuthCredentials
in interfaceHttpRequestBuilder<T extends HttpRequestBuilder<?>>
-
getHttpAuthUsername
-
getHttpAuthPassword
-
sendGetRawResponse
protected org.spincast.shaded.org.apache.http.HttpResponse sendGetRawResponse()- Returns:
- the raw, unparsed HttpClient's HttpResponse
-
send
Description copied from interface:HttpRequestBuilder
Sends the request and gets the HTTP response.- Specified by:
send
in interfaceHttpRequestBuilder<T extends HttpRequestBuilder<?>>
- Returns:
- A object containg the parsed information of the response.
-
createMethodSpecificHttpRequest
protected abstract org.spincast.shaded.org.apache.http.client.methods.HttpRequestBase createMethodSpecificHttpRequest(String url) Creates the HttpRequestBase depending on the HTTP method.
-