def http = HttpBuilder.configure {
request.uri = 'http://localhost:10101'
request.contentType = 'text/json'
}
http.post {
request.uri.path = '/bar'
request.contentType = 'text/csv'
}
public static class HttpConfigs.BasicRequest extends HttpConfigs.BaseRequest
Modifier | Constructor and Description |
---|---|
protected |
BasicRequest(ChainedHttpConfig.ChainedRequest parent) |
Modifier and Type | Method and Description |
---|---|
HttpConfigs.BasicAuth |
getAuth()
Retrieves the authentication information for the request.
|
java.lang.Object |
getBody() |
java.nio.charset.Charset |
getCharset() |
java.lang.String |
getContentType() |
java.util.List<java.net.HttpCookie> |
getCookies() |
java.util.Map<java.lang.String,java.util.function.BiConsumer<ChainedHttpConfig,ToServer>> |
getEncoderMap() |
java.util.Map<java.lang.String,java.lang.CharSequence> |
getHeaders()
Used to retrieve the request headers.
|
UriBuilder |
getUri()
Retrieves the
UriBuilder for the request, which provides methods for more fine-grained URI specification. |
void |
setBody(java.lang.Object val)
The
body property is used to configure the body content for the request. |
void |
setCharset(java.nio.charset.Charset val)
The
charset property is used to specify the character set (as a Charset ) used by the request. |
void |
setContentType(java.lang.String val)
The
contentType property is used to specify the Content-Type header value for the request. |
cookie, cookie, cookie, encoder, encoder, encoder, getParent, getVerb, setAccept, setAccept, setCharset, setHeaders, setRaw, setUri, setUri, setUri, setVerb
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
actualAuth, actualBody, actualCharset, actualContentType, actualCookies, actualEncoder, actualHeaders
cookie
protected BasicRequest(ChainedHttpConfig.ChainedRequest parent)
public java.util.Map<java.lang.String,java.util.function.BiConsumer<ChainedHttpConfig,ToServer>> getEncoderMap()
public java.util.List<java.net.HttpCookie> getCookies()
public java.lang.String getContentType()
public void setContentType(java.lang.String val)
HttpConfig.Request
The contentType
property is used to specify the Content-Type
header value for the request.
def http = HttpBuilder.configure {
request.uri = 'http://localhost:10101'
request.contentType = 'text/json'
}
http.post {
request.uri.path = '/bar'
request.contentType = 'text/csv'
}
By default, the value will be text/plain
. The ContentTypes
class provides a helper for some of the more common content type values.
val
- the content type value to be usedpublic void setCharset(java.nio.charset.Charset val)
HttpConfig.Request
The charset
property is used to specify the character set (as a Charset
) used by the request. This value will be reflected in
the Content-Type
header value (e.g. Content-Type: text/plain; charset=utf-8
). A content-type value must be specified in order for this
value to be applied.
def http = HttpBuilder.configure {
request.uri = 'http://localhost:10101'
request.charset = 'utf-16'
}
http.post {
request.uri.path = '/bar'
request.charset = 'utf-8'
}
val
- the content type character set value to be usedpublic java.nio.charset.Charset getCharset()
public UriBuilder getUri()
HttpConfig.Request
Retrieves the UriBuilder
for the request, which provides methods for more fine-grained URI specification.
def http = HttpBuilder.configure {
request.uri = 'http://localhost:10101'
}
http.get {
request.uri.path = '/foo'
}
UriBuilder
for the requestpublic java.util.Map<java.lang.String,java.lang.CharSequence> getHeaders()
HttpConfig.Request
Used to retrieve the request headers.
Map
of request headerspublic java.lang.Object getBody()
public void setBody(java.lang.Object val)
HttpConfig.Request
The body
property is used to configure the body content for the request. The request body content may be altered by configured encoders
internally or may be passed on unmodified. See HttpConfig
and HttpObjectConfig
for content-altering methods (encoders,
decoders and interceptors).
val
- the request body contentpublic HttpConfigs.BasicAuth getAuth()
HttpConfig.Request
Retrieves the authentication information for the request.