Package sonia.scm.net.ahc
Class BaseHttpRequest<T extends BaseHttpRequest>
java.lang.Object
sonia.scm.net.ahc.BaseHttpRequest<T>
- Type Parameters:
T
- request implementation
- Direct Known Subclasses:
AdvancedHttpRequest
,AdvancedHttpRequestWithBody
Base class for http requests.
- Since:
- 1.46
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionacceptStatusCodes
(int... codes) Sets the response codes which should be traced as successful.Enabled http basic authentication.bearerAuth
(String bearerToken) Enable authentication with a bearer token.decodeGZip
(boolean decodeGZip) Enable or disabled gzip decoding.disableCertificateValidation
(boolean disableCertificateValidation) Enable or disable certificate validation of ssl certificates.disableHostnameValidation
(boolean disableHostnameValidation) Enable or disable the validation of ssl hostnames.Disables tracing for the request.protected String
Returns the value url encoded.int[]
Returns the response codes which are accepted as successful by tracer.Return a map with http headers used for the request.Returns the http method for the request.Returns the kind of span which is used for the trace api.getUrl()
Returns the url for the request.Add http headers to request.Add http headers to request.ignoreProxySettings
(boolean ignoreProxySettings) Ignore proxy settings.boolean
Returns true if the request decodes gzip compression.boolean
Returns true if the verification of ssl certificates is disabled.boolean
Returns true if the ssl hostname validation is disabled.boolean
Returns true if the proxy settings are ignored.queryString
(String name, Object... values) Appends a query parameter to the request.queryStrings
(String name, Iterable<? extends Object> values) Appends a query parameter to the request.request()
Executes the request and returns the http response.protected abstract T
self()
Implementing classes should returnthis
.Sets the kind of span for tracing api.protected String
Returns string representation of the given object ornull
, if the object isnull
.
-
Field Details
-
client
-
-
Constructor Details
-
BaseHttpRequest
-
-
Method Details
-
request
Executes the request and returns the http response.- Returns:
- http response
- Throws:
IOException
-
self
Implementing classes should returnthis
.- Returns:
- request instance
-
basicAuth
Enabled http basic authentication.- Parameters:
username
- username for http basic authenticationpassword
- password for http basic authentication- Returns:
- http request instance
-
bearerAuth
Enable authentication with a bearer token.- Parameters:
bearerToken
- bearer token- Returns:
- http request instance
- Since:
- 2.28.0
-
decodeGZip
Enable or disabled gzip decoding. The default value is false.- Parameters:
decodeGZip
- true to enable gzip decoding- Returns:
- request instance
-
disableCertificateValidation
Enable or disable certificate validation of ssl certificates. The default value is false.- Parameters:
disableCertificateValidation
- true to disable certificate validation- Returns:
- request instance
-
disableHostnameValidation
Enable or disable the validation of ssl hostnames. The default value is false.- Parameters:
disableHostnameValidation
- true to disable ssl hostname validation- Returns:
- request instance
-
header
Add http headers to request.- Parameters:
name
- header namevalues
- header values- Returns:
- request instance
-
headers
Add http headers to request.- Parameters:
name
- header namevalues
- header values- Returns:
- request instance
-
ignoreProxySettings
Ignore proxy settings. The default value is false.- Parameters:
ignoreProxySettings
- true to ignore proxy settings.- Returns:
- request instance
-
queryString
Appends a query parameter to the request.- Parameters:
name
- name of query parametervalues
- query parameter values- Returns:
- request instance
-
queryStrings
Appends a query parameter to the request.- Parameters:
name
- name of query parametervalues
- query parameter values- Returns:
- request instance
-
spanKind
Sets the kind of span for tracing api.- Parameters:
spanKind
- kind of span- Returns:
- request instance
- Since:
- 2.9.0
-
acceptStatusCodes
Sets the response codes which should be traced as successful. Example: If 400 is set asacceptedStatusCodes
then all requests which get a response with status code 400 will be traced as successful (not failed) request- Parameters:
codes
- status codes which should be traced as successful- Returns:
- request instance
- Since:
- 2.10.0
-
disableTracing
Disables tracing for the request. This should only be done for internal requests.- Returns:
- request instance
-
getHeaders
Return a map with http headers used for the request. -
getMethod
Returns the http method for the request. -
getUrl
Returns the url for the request. -
getSpanKind
Returns the kind of span which is used for the trace api.- Since:
- 2.9.0
-
getAcceptedStatus
public int[] getAcceptedStatus()Returns the response codes which are accepted as successful by tracer.- Returns:
- codes
- Since:
- 2.10.0
-
isDecodeGZip
public boolean isDecodeGZip()Returns true if the request decodes gzip compression. -
isDisableCertificateValidation
public boolean isDisableCertificateValidation()Returns true if the verification of ssl certificates is disabled. -
isDisableHostnameValidation
public boolean isDisableHostnameValidation()Returns true if the ssl hostname validation is disabled. -
isIgnoreProxySettings
public boolean isIgnoreProxySettings()Returns true if the proxy settings are ignored. -
encoded
Returns the value url encoded.- Parameters:
value
- value to encode- Returns:
- encoded value
-
toString
Returns string representation of the given object ornull
, if the object isnull
.
-