/*
 * Copyright (c) 2015-present, Parse, LLC.
 * All rights reserved.
 *
 * This source code is licensed under the BSD-style license found in the
 * LICENSE file in the root directory of this source tree. An additional grant
 * of patent rights can be found in the PATENTS file in the same directory.
 */
package com.parse;

import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;

/**
 * The base interface of a http body.It can be implemented by different http library such as
 * Apache http, Android URLConnection, Square OKHttp and so on.
 */
/** package */ abstract class ParseHttpBody {
  protected final String contentType;
  protected final long contentLength;

  public abstract InputStream getContent() throws IOException;
  public abstract void writeTo(OutputStream out) throws IOException;

  public ParseHttpBody(String contentType, long contentLength) {
    this.contentType = contentType;
    this.contentLength = contentLength;
  }

  public long getContentLength() {
    return contentLength;
  }

  public String getContentType() {
    return contentType;
  }
}

/*
 * Copyright (c) 2015-present, Parse, LLC.
 * All rights reserved.
 *
 * This source code is licensed under the BSD-style license found in the
 * LICENSE file in the root directory of this source tree. An additional grant
 * of patent rights can be found in the PATENTS file in the same directory.
 */
package com.parse;

import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;

/**
 * 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.
 */
/** package */ abstract class ParseHttpBody {
  protected final String contentType;
  protected final long contentLength;

  /**
   * Returns the content of this body.
   *
   * @return The content of this body.
   * @throws IOException
   *           Throws an exception if the content of this body is inaccessible.
   */
  public abstract InputStream getContent() throws IOException;

  /**
   * Writes the content of this request to {@code out}.
   *
   * @param out
   *          The outputStream the content of this body needs to be written to.
   * @throws IOException
   *           Throws an exception if the content of this body can not be written to {@code out}.
   */
  public abstract void writeTo(OutputStream out) throws IOException;

  public ParseHttpBody(String contentType, long contentLength) {
    this.contentType = contentType;
    this.contentLength = contentLength;
  }

  /**
   * Returns the number of bytes which will be written to {@code out} when {@link #writeTo} is
   * called, or -1 if that count is unknown.
   *
   * @return The Content-Length of this body.
   */
  public long getContentLength() {
    return contentLength;
  }

  /**
   * Returns the Content-Type of this body.
   *
   * @return The Content-Type of this body.
   */
  public String getContentType() {
    return contentType;
  }
}

Add comment for ParseHttpBody