/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */

#include "nsISupports.idl"

interface nsIInputStream;

[scriptable, uuid(62e6529a-5cf6-491a-82ef-b3a8273cdd19)]
interface nsIUploadChannel2 : nsISupports
{
    /**
     * Sets a stream to be uploaded by this channel with the specified
     * Content-Type and Content-Length header values.
     *
     * Most implementations of this interface require that the stream:
     *   (1) implement threadsafe addRef and release
     *   (2) implement nsIInputStream::readSegments
     *   (3) implement nsISeekableStream::seek
     *
     * @param aStream
     *        The stream to be uploaded by this channel.
     * @param aContentType
     *        This value will replace any existing Content-Type
     *        header on the HTTP request, regardless of whether
     *        or not its empty.
     * @param aContentLength
     *        A value of -1 indicates that the length of the stream should be
     *        determined by calling the stream's |available| method.
     * @param aMethod
     *        The HTTP request method to set on the stream.
     * @param aStreamHasHeaders
     *        True if the stream already contains headers for the HTTP request.
     */
    void explicitSetUploadStream(in nsIInputStream aStream,
                                 in ACString aContentType,
                                 in long long aContentLength,
                                 in ACString aMethod,
                                 in boolean aStreamHasHeaders);

    /**
     * Value of aStreamHasHeaders from the last successful call to
     * explicitSetUploadStream.  TRUE indicates the attached upload stream
     * contians request headers.
     */
    readonly attribute boolean uploadStreamHasHeaders;

    /**
     * Clones the upload stream and returns an equivalent stream.
     */
    [noscript]
    nsIInputStream cloneUploadStream();
};
