Class ParseHttpBody


  • public abstract class ParseHttpBody
    extends java.lang.Object
    The base interface of a http body. It can be implemented by different http libraries such as Apache http, Android URLConnection, Square OKHttp and so on.
    • Constructor Summary

      Constructors 
      Constructor Description
      ParseHttpBody​(java.lang.String contentType, long contentLength)
      Creates an ParseHttpBody with given Content-Type and Content-Length.
    • Method Summary

      All Methods Instance Methods Abstract Methods Concrete Methods 
      Modifier and Type Method Description
      abstract java.io.InputStream getContent()
      Returns the content of this body.
      long getContentLength()
      Returns the number of bytes which will be written to out when writeTo(java.io.OutputStream) is called, or -1 if that count is unknown.
      java.lang.String getContentType()
      Returns the Content-Type of this body.
      abstract void writeTo​(java.io.OutputStream out)
      Writes the content of this request to out.
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • ParseHttpBody

        public ParseHttpBody​(java.lang.String contentType,
                             long contentLength)
        Creates an ParseHttpBody with given Content-Type and Content-Length.
        Parameters:
        contentType - The Content-Type of the ParseHttpBody.
        contentLength - The Content-Length of the ParseHttpBody.
    • Method Detail

      • getContent

        public abstract java.io.InputStream getContent()
                                                throws java.io.IOException
        Returns the content of this body.
        Returns:
        The content of this body.
        Throws:
        java.io.IOException - Throws an exception if the content of this body is inaccessible.
      • writeTo

        public abstract void writeTo​(java.io.OutputStream out)
                              throws java.io.IOException
        Writes the content of this request to out.
        Parameters:
        out - The outputStream the content of this body needs to be written to.
        Throws:
        java.io.IOException - Throws an exception if the content of this body can not be written to out.
      • getContentLength

        public long getContentLength()
        Returns the number of bytes which will be written to out when writeTo(java.io.OutputStream) is called, or -1 if that count is unknown.
        Returns:
        The Content-Length of this body.
      • getContentType

        public java.lang.String getContentType()
        Returns the Content-Type of this body.
        Returns:
        The Content-Type of this body.