aem-plugin / com.cognifide.gradle.aem.common.http / HttpClient

HttpClient

open class HttpClient : Serializable

Constructors

<init>

HttpClient(aem: AemExtension)

Properties

authorizationPreemptive

var authorizationPreemptive: Boolean

baseUrl

var baseUrl: String

basicCredentials

var basicCredentials: Pair<String?, String?>

basicPassword

var basicPassword: String?

basicUser

var basicUser: String?

client

val client: CloseableHttpClient!

clientBuilder

var clientBuilder: HttpClientBuilder.() -> Unit

connectionIgnoreSsl

var connectionIgnoreSsl: Boolean

connectionRetries

var connectionRetries: Boolean

connectionTimeout

var connectionTimeout: Int

proxyHost

var proxyHost: String?

proxyPort

var proxyPort: Int?

proxyScheme

var proxyScheme: String?

requestConfigurer

var requestConfigurer: HttpRequestBase.() -> Unit

responseChecker

var responseChecker: (HttpResponse) -> Unit

responseChecks

var responseChecks: Boolean

responseHandler

var responseHandler: (HttpResponse) -> Unit

Functions

asJson

fun asJson(response: HttpResponse): DocumentContext
fun asJson(jsonString: String): DocumentContext

asObjectFromJson

fun <T : Any> asObjectFromJson(response: HttpResponse): T
fun <T> asObjectFromJson(response: HttpResponse, clazz: Class<T>): T

asStream

fun asStream(response: HttpResponse): InputStream

asString

fun asString(response: HttpResponse): String

baseUrl

Fix for HttpClient's: 'escaped absolute path not valid' https://stackoverflow.com/questions/13652681/httpclient-invalid-uri-escaped-absolute-path-not-valid

open fun baseUrl(uri: String): String

checkHtml

fun checkHtml(response: HttpResponse, validator: Document.() -> Boolean): Unit

checkStatus

fun checkStatus(response: HttpResponse, statusCodes: IntRange = STATUS_CODE_VALID): Unit
fun checkStatus(response: HttpResponse, statusCode: Int): Unit
fun checkStatus(response: HttpResponse, statusCodes: List<Int>): Unit

checkText

fun checkText(response: HttpResponse, containedText: String, ignoreCase: Boolean = true): Unit

createEntityMultipart

open fun createEntityMultipart(params: Map<String, Any?>): HttpEntity

createEntityUrlencoded

open fun createEntityUrlencoded(params: Map<String, Any?>): HttpEntity

delete

fun delete(uri: String): Unit
fun <T> delete(uri: String, handler: HttpClient.(HttpResponse) -> T): T
fun <T> delete(uri: String, handler: HttpClient.(HttpResponse) -> T, options: HttpDelete.() -> Unit): T

execute

open fun <T> execute(method: HttpRequestBase, handler: HttpClient.(HttpResponse) -> T): T
fun execute(method: HttpRequestBase): Unit

fileTransfer

fun <T> fileTransfer(operation: HttpFileTransfer.() -> T): T

get

fun get(uri: String): Unit
fun <T> get(uri: String, handler: HttpClient.(HttpResponse) -> T): T
fun <T> get(uri: String, handler: HttpClient.(HttpResponse) -> T, options: HttpGet.() -> Unit): T

head

fun head(uri: String): Unit
fun <T> head(uri: String, handler: HttpClient.(HttpResponse) -> T): T
fun <T> head(uri: String, handler: HttpClient.(HttpResponse) -> T, options: HttpHead.() -> Unit): T

patch

fun patch(path: String): Unit
fun <T> patch(uri: String, handler: HttpClient.(HttpResponse) -> T): T
fun <T> patch(uri: String, handler: HttpClient.(HttpResponse) -> T, options: HttpPatch.() -> Unit): T

post

fun post(url: String, params: Map<String, Any?> = mapOf()): Unit
fun <T> post(uri: String, params: Map<String, Any?> = mapOf(), handler: HttpClient.(HttpResponse) -> T): T
fun <T> post(uri: String, handler: HttpClient.(HttpResponse) -> T): T
fun <T> post(uri: String, handler: HttpClient.(HttpResponse) -> T, options: HttpPost.() -> Unit): T

postMultipart

fun postMultipart(uri: String, params: Map<String, Any?> = mapOf()): Unit
fun <T> postMultipart(uri: String, params: Map<String, Any?> = mapOf(), handler: HttpClient.(HttpResponse) -> T): T

postUrlencoded

fun postUrlencoded(uri: String, params: Map<String, Any?> = mapOf()): Unit
fun <T> postUrlencoded(uri: String, params: Map<String, Any?> = mapOf(), handler: HttpClient.(HttpResponse) -> T): T

put

fun put(uri: String): Unit
fun <T> put(uri: String, handler: HttpClient.(HttpResponse) -> T): T
fun <T> put(uri: String, handler: HttpClient.(HttpResponse) -> T, options: HttpPut.() -> Unit): T

request

fun <T> request(method: String, uri: String, handler: HttpClient.(HttpResponse) -> T): T

throwStatusException

open fun throwStatusException(response: HttpResponse): Unit

Companion Object Properties

STATUS_CODE_VALID

val STATUS_CODE_VALID: IntRange

Inheritors

InstanceHttpClient

open class InstanceHttpClient : HttpClient