okhttp / okhttp3 / RequestBody


abstract class RequestBody


Name Summary
<init> RequestBody()


Name Summary
contentLength Returns the number of bytes that will be written to sink in a call to writeTo, or -1 if that count is unknown.open fun contentLength():Long
contentType Returns the Content-Type header for this body.abstract fun contentType():MediaType?
isDuplex A duplex request body is special in how it is transmitted on the network and in the API contract between OkHttp and the application.open fun isDuplex():Boolean
isOneShot Returns true if this body expects at most one call to writeTo and can be transmitted at most once. This is typically used when writing the request body is destructive and it is not possible to recreate the request body after it has been sent.open fun isOneShot():Boolean
writeTo Writes the content of this request to sink.abstract fun writeTo(sink:BufferedSink):Unit

Companion Object Functions

Name Summary
asRequestBody Returns a new request body that transmits the content of this.funFile.asRequestBody(contentType:MediaType? = null):RequestBody
toRequestBody Returns a new request body that transmits this string. If contentType is non-null and lacks a charset, this will use UTF-8.funString.toRequestBody(contentType:MediaType? = null):RequestBody
Returns a new request body that transmits this.funByteString.toRequestBody(contentType:MediaType? = null):RequestBody
funByteArray.toRequestBody(contentType:MediaType? = null, offset:Int= 0, byteCount:Int= size):RequestBody


Name Summary
FormBody class FormBody :RequestBody
MultipartBody An RFC 2387-compliant request body.class MultipartBody :RequestBody