Class Request.Body

java.lang.Object
com.squareup.okhttp.Request.Body
Enclosing class:
Request

public abstract static class Request.Body
extends Object
  • Constructor Details

    • Body

      public Body()
  • Method Details

    • contentType

      public MediaType contentType()
      Returns the Content-Type header for this body, or null if the content type is unknown.
    • contentLength

      public long contentLength()
      Returns the number of bytes in this body, or -1 if that count is unknown.
    • writeTo

      public abstract void writeTo​(OutputStream out) throws IOException
      Writes the content of this request to out.
      Throws:
      IOException
    • create

      public static Request.Body create​(MediaType contentType, String content)
      Returns a new request body that transmits content. If contentType lacks a charset, this will use UTF-8.
    • create

      public static Request.Body create​(MediaType contentType, byte[] content)
      Returns a new request body that transmits content.
    • create

      public static Request.Body create​(MediaType contentType, File file)
      Returns a new request body that transmits the content of file.