def http = HttpBuilder.configure {
request.uri = 'http://localhost:10101'
request.charset = 'utf-16'
}
http.post {
request.uri.path = '/bar'
request.charset = 'utf-8'
}
public abstract static class HttpConfigs.BaseRequest extends java.lang.Object implements ChainedHttpConfig.ChainedRequest
Constructor and Description |
---|
BaseRequest(ChainedHttpConfig.ChainedRequest parent) |
Modifier and Type | Method and Description |
---|---|
void |
cookie(java.lang.String name,
java.lang.String value,
java.util.Date date)
The
cookie configuration options provide a means of adding HTTP Cookies to the request. |
void |
cookie(java.lang.String name,
java.lang.String value,
java.time.Instant instant) |
void |
cookie(java.lang.String name,
java.lang.String value,
java.time.LocalDateTime dateTime)
The
cookie configuration options provide a means of adding HTTP Cookies to the request. |
void |
encoder(java.lang.Iterable<java.lang.String> contentTypes,
java.util.function.BiConsumer<ChainedHttpConfig,ToServer> val)
Specifies the request encoder (
ToServer instance) to be used when encoding the given list of content types. |
java.util.function.BiConsumer<ChainedHttpConfig,ToServer> |
encoder(java.lang.String contentType)
Retrieves the request encoder (
ToServer instance) for the specified content type wrapped in a BiConsumer function. |
void |
encoder(java.lang.String contentType,
java.util.function.BiConsumer<ChainedHttpConfig,ToServer> val)
Specifies the request encoder (
ToServer instance) to be used when encoding the given content type. |
ChainedHttpConfig.ChainedRequest |
getParent() |
HttpVerb |
getVerb() |
void |
setAccept(java.lang.Iterable<java.lang.String> values)
The
accept property allows configuration of the request Accept header, which may be used to specify certain media types which are
acceptable for the response. |
void |
setAccept(java.lang.String[] values)
The
accept property allows configuration of the request Accept header, which may be used to specify certain media types which are
acceptable for the response. |
void |
setCharset(java.lang.String val)
The
charset property is used to specify the character set (as a String) used by the request. |
void |
setHeaders(java.util.Map<java.lang.String,java.lang.CharSequence> toAdd)
The
headers property allows the direct specification of the request headers as a Map<String,String> . |
void |
setRaw(java.lang.String val)
The
request.raw is the means of specifying a "raw" URI as the HTTP endpoint for the request, specified as a String . |
void |
setUri(java.lang.String val)
The
request.uri is the URI of the HTTP endpoint for the request, specified as a String in this case. |
void |
setUri(java.net.URI val)
The
request.uri is the URI of the HTTP endpoint for the request, specified as a URI in this case. |
void |
setUri(java.net.URL val)
The
request.uri is the URI of the HTTP endpoint for the request, specified as a URL in this case. |
void |
setVerb(HttpVerb verb) |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
actualAuth, actualBody, actualCharset, actualContentType, actualCookies, actualEncoder, actualHeaders, getBody, getCharset, getContentType, getCookies, getEncoderMap
cookie, getAuth, getHeaders, getUri, setBody, setCharset, setContentType
public BaseRequest(ChainedHttpConfig.ChainedRequest parent)
public ChainedHttpConfig.ChainedRequest getParent()
getParent
in interface ChainedHttpConfig.ChainedRequest
public void setCharset(java.lang.String val)
HttpConfig.Request
The charset
property is used to specify the character set (as a String) used by the request.
def http = HttpBuilder.configure {
request.uri = 'http://localhost:10101'
request.charset = 'utf-16'
}
http.post {
request.uri.path = '/bar'
request.charset = 'utf-8'
}
setCharset
in interface HttpConfig.Request
val
- the content type character set value to be usedpublic void setUri(java.lang.String val)
HttpConfig.Request
The request.uri
is the URI of the HTTP endpoint for the request, specified as a String
in this case.
def http = HttpBuilder.configure {
request.uri = 'http://localhost:10101'
}
http.get {
request.uri.path = '/foo'
}
http.post {
request.uri.path = '/bar'
}
Which allows multiple verb requests to be configured against the same HttpBuilder
. See the UriBuilder
documentation for
more details.
The uri
is the only required configuration property.
setUri
in interface HttpConfig.Request
val
- the URI to be used for the request, as a Stringpublic void setRaw(java.lang.String val)
HttpConfig.Request
The request.raw
is the means of specifying a "raw" URI as the HTTP endpoint for the request, specified as a String
. No encoding or decoding is performed on a "raw" URI. Any such
encoding or decoding of URI content must be done in the provided string itself, as it will be used "as is" in the resulting URI. This functionality is useful in the case where
there are encoded entities in the URI path, since the standard uri
method will decode these on building the URI
.
setRaw
in interface HttpConfig.Request
val
- the raw URI stringpublic void setUri(java.net.URI val)
HttpConfig.Request
The request.uri
is the URI of the HTTP endpoint for the request, specified as a URI
in this case.
def http = HttpBuilder.configure {
request.uri = new URI('http://localhost:10101')
}
http.get {
request.uri.path = '/foo'
}
http.post {
request.uri.path = '/bar'
}
Which allows multiple verb requests to be configured against the same HttpBuilder
. See the UriBuilder
documentation for
more details.
The uri
is the only required configuration property.
setUri
in interface HttpConfig.Request
val
- the URI to be used for the request, as a URIpublic void setUri(java.net.URL val) throws java.net.URISyntaxException
HttpConfig.Request
The request.uri
is the URI of the HTTP endpoint for the request, specified as a URL
in this case.
def http = HttpBuilder.configure {
request.uri = new URL('http://localhost:10101')
}
http.get {
request.uri.path = '/foo'
}
http.post {
request.uri.path = '/bar'
}
Which allows multiple verb requests to be configured against the same HttpBuilder
. See the UriBuilder
documentation for
more details.
The uri
is the only required configuration property.
setUri
in interface HttpConfig.Request
val
- the URI to be used for the request, as a URLjava.net.URISyntaxException
public java.util.function.BiConsumer<ChainedHttpConfig,ToServer> encoder(java.lang.String contentType)
HttpConfig.Request
Retrieves the request encoder (ToServer
instance) for the specified content type wrapped in a BiConsumer
function.
encoder
in interface HttpConfig.Request
contentType
- the content type of the encoder to be retrievedBiConsumer
function)public void encoder(java.lang.String contentType, java.util.function.BiConsumer<ChainedHttpConfig,ToServer> val)
HttpConfig.Request
Specifies the request encoder (ToServer
instance) to be used when encoding the given content type.
encoder
in interface HttpConfig.Request
contentType
- the content typeval
- the request encoder (wrapped in a BiConsumer
function)public void encoder(java.lang.Iterable<java.lang.String> contentTypes, java.util.function.BiConsumer<ChainedHttpConfig,ToServer> val)
HttpConfig.Request
Specifies the request encoder (ToServer
instance) to be used when encoding the given list of content types.
encoder
in interface HttpConfig.Request
contentTypes
- the content typesval
- the request encoder (wrapped in a BiConsumer
function)public void setAccept(java.lang.String[] values)
HttpConfig.Request
The accept
property allows configuration of the request Accept
header, which may be used to specify certain media types which are
acceptable for the response.
def http = HttpBuilder.configure {
request.uri = 'http://localhost:10101'
request.accept = ['image/jpeg']
}
http.post {
request.uri.path = '/bar'
request.accept = ['image/tiff', 'image/png']
}
setAccept
in interface HttpConfig.Request
values
- the accept header values as a String arraypublic void setAccept(java.lang.Iterable<java.lang.String> values)
HttpConfig.Request
The accept
property allows configuration of the request Accept
header, which may be used to specify certain media types which are
acceptable for the response.
def http = HttpBuilder.configure {
request.uri = 'http://localhost:10101'
request.accept = ['image/jpeg']
}
http.post {
request.uri.path = '/bar'
request.accept = ['image/tiff', 'image/png']
}
setAccept
in interface HttpConfig.Request
values
- the accept header values as a Listpublic void setHeaders(java.util.Map<java.lang.String,java.lang.CharSequence> toAdd)
HttpConfig.Request
The headers
property allows the direct specification of the request headers as a Map<String,String>
. Be aware that Content-Type
and
Accept
are actually header values and it is up to the implementation to determine which configuration will win out if both are configured.
def http = HttpBuilder.configure {
request.uri = 'http://localhost:10101'
request.headers = [
ClientId: '987sdfsdf9uh'
]
}
http.post {
request.uri.path = '/bar'
request.headers = [
AccessCode: '99887766'
]
}
Warning
|
The headers are additive; however, a header specified in the verb configuration may overwrite one defined in the global configuration. |
setHeaders
in interface HttpConfig.Request
toAdd
- the headers to be added to the request headerspublic void cookie(java.lang.String name, java.lang.String value, java.time.Instant instant)
public void cookie(java.lang.String name, java.lang.String value, java.util.Date date)
HttpConfig.Request
The cookie
configuration options provide a means of adding HTTP Cookies to the request. Cookies are defined with a name
, value
, and
expires
Date.
def http = HttpBuilder.configure {
request.uri = 'http://localhost:10101'
request.cookie 'seen-before', 'true'
}
http.post {
request.uri.path = '/bar'
request.cookie 'last-page', 'item-list', Date.parse('MM/dd/yyyy', '12/31/2016')
}
Warning
|
Cookies are additive, once a Cookie is defined (e.g. in the global configuration), you cannot overwrite it in per-verb configurations. |
As noted in the HttpObjectConfig.Client
configuration, the default Cookie version supported is 0
, but this may
be modified.
cookie
in interface HttpConfig.Request
name
- the cookie namevalue
- the cookie valuedate
- the cookie expiration datepublic void cookie(java.lang.String name, java.lang.String value, java.time.LocalDateTime dateTime)
HttpConfig.Request
The cookie
configuration options provide a means of adding HTTP Cookies to the request. Cookies are defined with a name
, value
, and
an expiration date as LocalDateTime
.
HttpBuilder.configure {
request.uri = 'http://localhost:10101'
}.post {
request.uri.path = '/bar'
request.cookie 'last-page', 'item-list', LocalDateTime.now().plus(1, ChronoUnit.MONTHS)
}
Warning
|
Cookies are additive, once a Cookie is defined (e.g. in the global configuration), you cannot overwrite it in per-verb configurations. |
As noted in the HttpObjectConfig.Client
configuration, the default Cookie version supported is 0
, but this may
be modified.
cookie
in interface HttpConfig.Request
name
- the cookie namevalue
- the cookie valuedateTime
- the cookie expiration datepublic HttpVerb getVerb()
getVerb
in interface ChainedHttpConfig.ChainedRequest
public void setVerb(HttpVerb verb)
setVerb
in interface ChainedHttpConfig.ChainedRequest