How to use head method of com.github.kittinunf.fuel.core.RequestFactory class

Best Fuel code snippet using com.github.kittinunf.fuel.core.RequestFactory.head

RequestTest.kt

Source:RequestTest.kt Github

copy

Full Screen

...263 fun httpHeadRequest() {264 val paramKey = "foo"265 val paramValue = "bar"266 mock.chain(267 request = mock.request().withMethod(Method.HEAD.value).withPath("/head"),268 response = mock.response().withStatusCode(HttpURLConnection.HTTP_OK)269 )270 val (request, response, result) = manager.request(Method.HEAD, mock.path("head"), listOf(paramKey to paramValue)).responseString()271 val (data, error) = result272 val string = data as String273 assertThat(request, notNullValue())274 assertThat(response, notNullValue())275 assertThat(error, nullValue())276 assertThat(data, notNullValue())277 assertThat(response.statusCode, equalTo(HttpURLConnection.HTTP_OK))278 assertThat(string, equalTo(""))279 }280 @Test281 fun httpOptionsRequest() {282 mock.chain(283 request = mock.request().withMethod(Method.OPTIONS.value).withPath("/options"),284 response = mock.response().withStatusCode(HttpURLConnection.HTTP_OK)...

Full Screen

Full Screen

FuelManager.kt

Source:FuelManager.kt Github

copy

Full Screen

...161 responseInterceptors.clear()162 return this163 }164 private fun applyOptions(request: Request): Request {165 // Sets base headers ONLY if they are not set166 val unsetBaseHeaders = request.headers.keys.fold(Headers.from(baseHeaders.orEmpty())) {167 result, it -> result.remove(it); result168 }169 return request.header(unsetBaseHeaders).apply {170 executionOptions = RequestExecutionOptions(171 client = client,172 socketFactory = socketFactory,173 hostnameVerifier = hostnameVerifier,174 callbackExecutor = callbackExecutor,175 requestTransformer = requestInterceptors.foldRight({ r: Request -> r }) { f, acc -> f(acc) },176 responseTransformer = responseInterceptors.foldRight({ _: Request, res: Response -> res }) { f, acc -> f(acc) },177 executorService = executorService178 ).also { executor ->179 executor.timeoutInMillisecond = timeoutInMillisecond180 executor.timeoutReadInMillisecond = timeoutReadInMillisecond181 executor.forceMethods = forceMethods182 }183 }184 }185 companion object {186 // manager187 var instance by readWriteLazy { FuelManager() }188 val progressBufferSize: Int get() = instance.progressBufferSize189 }190 /**191 * Create a [Method.GET] [Request] to [path] with [parameters]192 *193 * @param path [String] the absolute or relative to [FuelManager.instance]' base-path path194 * @param parameters [Parameters] the optional parameters195 * @return [Request] the request196 */197 override fun get(path: String, parameters: Parameters?): Request =198 request(Method.GET, path, parameters)199 /**200 * Create a [Method.GET] [Request] to [PathStringConvertible.path] with [parameters]201 *202 * @param convertible [PathStringConvertible] the absolute or relative to [FuelManager.instance]' base-path path203 * @param parameters [Parameters] the optional parameters204 * @return [Request] the request205 */206 override fun get(convertible: PathStringConvertible, parameters: Parameters?): Request =207 request(Method.GET, convertible, parameters)208 /**209 * Create a [Method.POST] [Request] to [path] with [parameters]210 *211 * @param path [String] the absolute or relative to [FuelManager.instance]' base-path path212 * @param parameters [Parameters] the optional parameters213 * @return [Request] the request214 */215 override fun post(path: String, parameters: Parameters?): Request =216 request(Method.POST, path, parameters)217 /**218 * Create a [Method.POST] [Request] to [PathStringConvertible.path] with [parameters]219 *220 * @param convertible [PathStringConvertible] the absolute or relative to [FuelManager.instance]' base-path path221 * @param parameters [Parameters] the optional parameters222 * @return [Request] the request223 */224 override fun post(convertible: PathStringConvertible, parameters: Parameters?): Request =225 request(Method.POST, convertible, parameters)226 /**227 * Create a [Method.PUT] [Request] to [path] with [parameters]228 *229 * @param path [String] the absolute or relative to [FuelManager.instance]' base-path path230 * @param parameters [Parameters] the optional parameters231 * @return [Request] the request232 */233 override fun put(path: String, parameters: Parameters?): Request =234 request(Method.PUT, path, parameters)235 /**236 * Create a [Method.PUT] [Request] to [PathStringConvertible.path] with [parameters]237 *238 * @param convertible [PathStringConvertible] the absolute or relative to [FuelManager.instance]' base-path path239 * @param parameters [Parameters] the optional parameters240 * @return [Request] the request241 */242 override fun put(convertible: PathStringConvertible, parameters: Parameters?): Request =243 request(Method.PUT, convertible, parameters)244 /**245 * Create a [Method.PATCH] [Request] to [path] with [parameters]246 *247 * @param path [String] the absolute or relative to [FuelManager.instance]' base-path path248 * @param parameters [Parameters] the optional parameters249 * @return [Request] the request250 */251 override fun patch(path: String, parameters: Parameters?): Request =252 request(Method.PATCH, path, parameters)253 /**254 * Create a [Method.PATCH] [Request] to [PathStringConvertible.path] with [parameters]255 *256 * @param convertible [PathStringConvertible] the absolute or relative to [FuelManager.instance]' base-path path257 * @param parameters [Parameters] the optional parameters258 * @return [Request] the request259 */260 override fun patch(convertible: PathStringConvertible, parameters: Parameters?): Request =261 request(Method.PATCH, convertible, parameters)262 /**263 * Create a [Method.DELETE] [Request] to [path] with [parameters]264 *265 * @param path [String] the absolute or relative to [FuelManager.instance]' base-path path266 * @param parameters [Parameters] the optional parameters267 * @return [Request] the request268 */269 override fun delete(path: String, parameters: Parameters?): Request =270 request(Method.DELETE, path, parameters)271 /**272 * Create a [Method.DELETE] [Request] to [PathStringConvertible.path] with [parameters]273 *274 * @param convertible [PathStringConvertible] the absolute or relative to [FuelManager.instance]' base-path path275 * @param parameters [Parameters] the optional parameters276 * @return [Request] the request277 */278 override fun delete(convertible: PathStringConvertible, parameters: Parameters?): Request =279 request(Method.DELETE, convertible, parameters)280 /**281 * Create a [method] [Request] to [PathStringConvertible.path] with [parameters], which can download to a file282 *283 * @param convertible [PathStringConvertible] the absolute or relative to [FuelManager.instance]' base-path path284 * @param method [Method] the method to download with, defaults to [Method.GET]285 * @param parameters [Parameters] the optional parameters286 * @return [DownloadRequest] the request (extended for download)287 */288 override fun download(convertible: PathStringConvertible, method: Method, parameters: Parameters?): DownloadRequest =289 download(convertible.path, method, parameters)290 /**291 * Create a [method] [Request] to [PathStringConvertible.path] with [parameters], which can upload blobs and292 * Data Parts293 *294 * @param convertible [PathStringConvertible] the absolute or relative to [FuelManager.instance]' base-path path295 * @param method [Method] the method to upload with, defaults to [Method.POST]296 * @param parameters [Parameters] the optional parameters297 * @return [UploadRequest] the request (extended for upload)298 */299 override fun upload(convertible: PathStringConvertible, method: Method, parameters: Parameters?): UploadRequest =300 upload(convertible.path, method, parameters)301 /**302 * Create a [Method.HEAD] [Request] to [path] with [parameters]303 *304 * @param path [String] the absolute or relative to [FuelManager.instance]' base-path path305 * @param parameters [Parameters] the optional parameters306 * @return [Request] the request307 */308 override fun head(path: String, parameters: Parameters?): Request =309 request(Method.HEAD, path, parameters)310 /**311 * Create a [Method.HEAD] [Request] to [PathStringConvertible.path] with [parameters]312 *313 * @param convertible [PathStringConvertible] the absolute or relative to [FuelManager.instance]' base-path path314 * @param parameters [Parameters] the optional parameters315 * @return [Request] the request316 */317 override fun head(convertible: PathStringConvertible, parameters: Parameters?): Request =318 request(Method.HEAD, convertible, parameters)319 /**320 * Resets this FuelManager to a clean instance321 */322 fun reset(): FuelManager {323 val clean = FuelManager()324 client = clean.client325 proxy = clean.proxy326 basePath = clean.basePath327 timeoutInMillisecond = clean.timeoutInMillisecond328 timeoutReadInMillisecond = clean.timeoutReadInMillisecond329 baseHeaders = clean.baseHeaders330 baseParams = clean.baseParams331 keystore = clean.keystore...

Full Screen

Full Screen

RequestFactory.kt

Source:RequestFactory.kt Github

copy

Full Screen

...172 * @param path [String] the absolute or relative to [FuelManager.instance]' base-path path173 * @param parameters [Parameters] the optional parameters174 * @return [Request] the request175 */176 fun head(path: String, parameters: Parameters? = null): Request177 /**178 * Create a [Method.HEAD] [Request] to [PathStringConvertible.path] with [parameters]179 *180 * @param convertible [PathStringConvertible] the absolute or relative to [FuelManager.instance]' base-path path181 * @param parameters [Parameters] the optional parameters182 * @return [Request] the request183 */184 fun head(convertible: PathStringConvertible, parameters: Parameters? = null): Request185 }186}...

Full Screen

Full Screen

FuelClient.kt

Source:FuelClient.kt Github

copy

Full Screen

...40 }41 val requestBody = body?.let { KrotoHttpJson.encodeToString(endPoint.requestBodySerializer, it) }42 var request =43 fuel.request(endPoint.method.fuelType, baseEndPoint + endPoint.getPath(pathParameter), queryParameter)44 .header(Headers.CONTENT_TYPE, "application/json")45 if (requestBody != null) {46 request = request.body(requestBody)47 }48 return request.awaitResponse(Deserializable(endPoint.responseBodySerializer))49 }50 private class Deserializable<T : Any>(private val serializer: DeserializationStrategy<T>) :51 ResponseDeserializable<T> {52 override fun deserialize(content: String): T? = KrotoHttpJson.decodeFromString(serializer, content)53 override fun deserialize(reader: Reader): T? = deserialize(reader.readText())54 override fun deserialize(bytes: ByteArray): T? = deserialize(String(bytes))55 override fun deserialize(inputStream: InputStream): T? {56 inputStream.bufferedReader().use {57 return deserialize(it)58 }...

Full Screen

Full Screen

Fuel.kt

Source:Fuel.kt Github

copy

Full Screen

...42 Fuel.upload(this, method, parameters)43fun RequestFactory.PathStringConvertible.httpUpload(parameters: Parameters? = null, method: Method = Method.POST): UploadRequest =44 this.path.httpUpload(parameters, method)45fun String.httpHead(parameters: Parameters? = null): Request =46 Fuel.head(this, parameters)47fun RequestFactory.PathStringConvertible.httpHead(parameters: Parameters? = null): Request =48 this.path.httpHead(parameters)...

Full Screen

Full Screen

head

Using AI Code Generation

copy

Full Screen

1.header("header1" to "value1", "header2" to "value2")2.header(mapOf("header3" to "value3", "header4" to "value4"))3.header(mapOf("header5" to "value5", "header6" to "value6"))4.header("header7" to "value7", "header8" to "value8")5.header(mapOf("header9" to "value9", "header10" to "value10"))6.header(mapOf("header11" to "value11", "header12" to "value12"))7.header("header13" to "value13", "header14" to "value14")8.header(mapOf("header15" to "value15", "header16" to "value16"))9.header(mapOf("header17" to "value17", "header18" to "value18"))10.header("header19" to "value19", "header20" to "value20")11.header(mapOf("header21" to "value21", "header22" to "value22"))12.header(mapOf("header23" to "value23", "header24" to "value24"))13.header("header25" to "value25", "header26" to "value26")14.header(mapOf("header27" to "value27", "header28" to "value28"))15.header(mapOf("header29" to "value29", "header30" to "value30"))16.header("header31" to "value31", "header32" to "value32")17.header(mapOf("header33" to "value33", "header34" to "value34"))18.header(mapOf("header35" to "value35", "header36" to "value36"))19.header("header37" to "value37", "header38" to "value38")20.header(mapOf("header39" to "value39", "header40" to "value40"))21.header(mapOf("header41" to "value41", "header42" to "value42"))22.header("header43" to "value43", "header44" to "value44")23.header(mapOf("header45" to "value45", "header46" to "value46"))24.header(mapOf("header47" to "value47", "header

Full Screen

Full Screen

head

Using AI Code Generation

copy

Full Screen

1val (request, response, result) = request.head()2val text = result.get()3val (request, response, result) = request.response()4val text = result.get()5val (request, response, result) = request.head()6val text = result.get()7val (request, response, result) = request.head()8val text = result.get()9val (request, response, result) = request.head()10val text = result.get()11val (request, response, result) = request.head()12val text = result.get()13val (request, response, result) = request.head()14val text = result.get()15val (request, response, result) = request.head()16val text = result.get()17val (request, response, result) = request.head()18val text = result.get()

Full Screen

Full Screen

head

Using AI Code Generation

copy

Full Screen

1 val (request, response, result) = request.head()2 val body = response.body()3 headers.forEach { println(it) }4 println(statusCode)5 println(body)6 if (response.isSuccessful) {7 }8}9val (request, response, result) = request.head()10val body = response.body()11headers.forEach { println(it) }12println(statusCode)13println(body)14if (response.isSuccessful) {15}16val (request, response, result) = request.delete()

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run Fuel automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Most used method in RequestFactory

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful