Package sonia.scm.net.ahc
Class AdvancedHttpRequestWithBody
java.lang.Object
sonia.scm.net.ahc.BaseHttpRequest<AdvancedHttpRequestWithBody>
sonia.scm.net.ahc.AdvancedHttpRequestWithBody
Http request with body.
- Since:
- 1.46
-
Field Summary
Fields inherited from class sonia.scm.net.ahc.BaseHttpRequest
client
-
Method Summary
Modifier and TypeMethodDescriptioncontentLength
(long length) Sets the content length for the request.contentType
(String contentType) Sets the content type for the request.fileContent
(File file) Sets the content of the file as request content.Returns aFormContentBuilder
.Returns the content or the request.jsonContent
(Object object) Transforms the given object to a json string and set this string as request content.rawContent
(byte[] data) Sets the raw data as request content.rawContent
(com.google.common.io.ByteSource source) Sets the raw data as request content.protected AdvancedHttpRequestWithBody
self()
Implementing classes should returnthis
.stringContent
(String content) Sets the string as request content.stringContent
(String content, Charset charset) Sets the string as request content.transformedContent
(String contentType, Object object) Transforms the given object to a string and set this string as request content.xmlContent
(Object object) Transforms the given object to a xml string and set this string as request content.Methods inherited from class sonia.scm.net.ahc.BaseHttpRequest
acceptStatusCodes, basicAuth, bearerAuth, decodeGZip, disableCertificateValidation, disableHostnameValidation, disableTracing, encoded, getAcceptedStatus, getHeaders, getMethod, getSpanKind, getUrl, header, headers, ignoreProxySettings, isDecodeGZip, isDisableCertificateValidation, isDisableHostnameValidation, isIgnoreProxySettings, queryString, queryStrings, request, spanKind, toString
-
Method Details
-
contentLength
Sets the content length for the request.- Returns:
this
-
contentType
Sets the content type for the request.- Returns:
this
-
fileContent
Sets the content of the file as request content.- Returns:
this
-
formContent
Returns aFormContentBuilder
. The builder can be used to add form parameters as content for the request. Note: you have to callFormContentBuilder.build()
in order to apply the form content to the request.- Returns:
- form content builder
-
jsonContent
Transforms the given object to a json string and set this string as request content.- Parameters:
object
- object to transform- Returns:
this
- Throws:
ContentTransformerNotFoundException
- if noContentTransformer
could be found for the json content-type
-
rawContent
Sets the raw data as request content.- Returns:
this
-
rawContent
Sets the raw data as request content.- Returns:
this
-
stringContent
Sets the string as request content.- Returns:
this
-
stringContent
Sets the string as request content.- Parameters:
content
- string contentcharset
- charset of content- Returns:
this
-
transformedContent
Transforms the given object to a string and set this string as request content. The content-type is used to pick the rightContentTransformer
. The method will throw an exception if noContentTransformer
for the content-type could be found.- Parameters:
contentType
- content-typeobject
- object to transform- Returns:
this
- Throws:
ContentTransformerNotFoundException
- if noContentTransformer
could be found for the given content-type
-
xmlContent
Transforms the given object to a xml string and set this string as request content.- Parameters:
object
- object to transform- Returns:
this
- Throws:
ContentTransformerNotFoundException
- if noContentTransformer
could be found for the xml content-type
-
getContent
Returns the content or the request. -
self
Description copied from class:BaseHttpRequest
Implementing classes should returnthis
.- Specified by:
self
in classBaseHttpRequest<AdvancedHttpRequestWithBody>
- Returns:
- request instance
-