(Quick Reference)

2 Configuration - Reference Documentation

Authors: Bud Byrd

Version: 2.0.2

2 Configuration

The Jersey Request Builder can be configured to apply default values, or set a specific behavior, to each new request. These configurations can be placed in the grails-app/conf/Config.groovy file.

These values can be overidden within specific request.

There are four configurations that declare the behavior of how the Jersey Request Builder returns responses, and some override the others:
  • convertJson will automatically convert response payloads using JsonSlurper if the response's content-type is JSON-compatible.
  • convertXML will automatically convert response payloads using XmlSlurper if the response's content-type is XML-compatible.
  • binaryResponse will return the response payload as a byte[]. This overrides all above behavior.
  • rawClientResponse will return the ClientResponse Object. This overrides all above behavior.

If useBasicAuth is set, then the basicAuthUserName and basicAuthPassword must be set for every request, either through configuration, or per request.

To override this behavior for a specific request, set useBasicAuth to false for that request (it will not include the BasicAuth information).

The configuration values are as follows:

Config ValueDatatypeDescription
connectionTimeoutIntegerThe default connection timeout (in milliseconds).
readTimeoutIntegerThe default read timeout (in milliseconds).
contentTypeString, MediaTypeThe default value of the content-type header.
acceptString, MediaTypeThe default value of the accept header.
convertJsonBooleanAutomatically converts JSON when the content-type in the Response header is a JSON-compatible type.
convertXMLBooleanAutomatically converts XML when the content-type in the Response header is an XML-compatible type.
binaryResponseBooleanResponse payloads will be returned as byte[].
rawClientResponseBooleanThe Jersey Request Builder will return ClientResponse.
skipStatusCheckBooleanIf set to true, then the Jersey Request Builder will not throw ResponseStatusException on an HTTP/1.1 error code.
followRedirectsBooleanIf set to true, then the Jersey Request Builder will automatically follow redirects in 3xx responses.
debugBooleanIf set to true, then the HTTP conversation will be printed to log4j (debug level).
ignoreInvalidSSLBooleanIf set to true, then the Jersey Request Builder will ignore invalid SSL identities.
useBasicAuthBooleanIf set to true, then the Jersey Request Builder will automatically include Basic Auth in the request, provided the basicAuthUserName and basicAuthPassword are set.
basicAuthUserNameStringThe BasicAuth Username.
basicAuthPasswordStringThe BasicAuth Password.
chunkSizeIntegerAutomatically set Chunked Encoding on the request.
encodeGzipBooleanAutomatically set GZIP Encoding on the request.

Default Configuration

jerseyRequestBuilder {
    connectionTimeout = null
    readTimeout = null

contentType = null accept = null

convertJson = true convertXML = true binaryResponse = false rawClientResponse = false

skipStatusCheck = false

followRedirects = true debug = false ignoreInvalidSSL = false

useBasicAuth = false basicAuthUserName = null basicAuthPassword = null

chunkSize = null encodeGzip = false }