Package com.squareup.okhttp
Class RequestBody
- java.lang.Object
-
- com.squareup.okhttp.RequestBody
-
public abstract class RequestBody extends Object
-
-
Constructor Summary
Constructors Constructor Description RequestBody()
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description longcontentLength()Returns the number of bytes that will be written tooutin a call towriteTo(okio.BufferedSink), or -1 if that count is unknown.abstract MediaTypecontentType()Returns the Content-Type header for this body.static RequestBodycreate(MediaType contentType, byte[] content)Returns a new request body that transmitscontent.static RequestBodycreate(MediaType contentType, byte[] content, int offset, int byteCount)Returns a new request body that transmitscontent.static RequestBodycreate(MediaType contentType, File file)Returns a new request body that transmits the content offile.static RequestBodycreate(MediaType contentType, String content)Returns a new request body that transmitscontent.static RequestBodycreate(MediaType contentType, ByteString content)Returns a new request body that transmitscontent.abstract voidwriteTo(BufferedSink sink)Writes the content of this request toout.
-
-
-
Method Detail
-
contentType
public abstract MediaType contentType()
Returns the Content-Type header for this body.
-
contentLength
public long contentLength() throws IOExceptionReturns the number of bytes that will be written tooutin a call towriteTo(okio.BufferedSink), or -1 if that count is unknown.- Throws:
IOException
-
writeTo
public abstract void writeTo(BufferedSink sink) throws IOException
Writes the content of this request toout.- Throws:
IOException
-
create
public static RequestBody create(MediaType contentType, String content)
Returns a new request body that transmitscontent. IfcontentTypeis non-null and lacks a charset, this will use UTF-8.
-
create
public static RequestBody create(MediaType contentType, ByteString content)
Returns a new request body that transmitscontent.
-
create
public static RequestBody create(MediaType contentType, byte[] content)
Returns a new request body that transmitscontent.
-
create
public static RequestBody create(MediaType contentType, byte[] content, int offset, int byteCount)
Returns a new request body that transmitscontent.
-
create
public static RequestBody create(MediaType contentType, File file)
Returns a new request body that transmits the content offile.
-
-