2009-09-09 03:29:41 +04:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
2012-05-21 15:12:37 +04:00
|
|
|
/* 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/. */
|
2009-09-09 03:29:41 +04:00
|
|
|
|
|
|
|
#include "nsISupports.idl"
|
|
|
|
|
|
|
|
interface nsIInputStream;
|
2015-09-15 20:15:45 +03:00
|
|
|
interface nsIRunnable;
|
2009-09-09 03:29:41 +04:00
|
|
|
|
2015-09-15 20:15:45 +03:00
|
|
|
[scriptable, uuid(2f712b52-19c5-4e0c-9e8f-b5c7c3b67049)]
|
2009-09-09 03:29:41 +04:00
|
|
|
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);
|
2011-05-29 17:55:38 +04:00
|
|
|
|
|
|
|
/**
|
2011-05-29 18:14:21 +04:00
|
|
|
* Value of aStreamHasHeaders from the last successful call to
|
|
|
|
* explicitSetUploadStream. TRUE indicates the attached upload stream
|
2019-12-17 13:05:56 +03:00
|
|
|
* contains request headers.
|
2011-05-29 17:55:38 +04:00
|
|
|
*/
|
|
|
|
readonly attribute boolean uploadStreamHasHeaders;
|
2015-05-04 23:53:40 +03:00
|
|
|
|
|
|
|
/**
|
2015-09-15 20:15:45 +03:00
|
|
|
* Ensure the upload stream, if any, is cloneable. This may involve
|
|
|
|
* async copying, so a callback runnable must be provided. It will
|
|
|
|
* invoked on the current thread when the upload stream is ready
|
|
|
|
* for cloning. If the stream is already cloneable, then the callback
|
|
|
|
* will be invoked synchronously.
|
|
|
|
*/
|
|
|
|
[noscript]
|
|
|
|
void ensureUploadStreamIsCloneable(in nsIRunnable aCallback);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Clones the upload stream. May return failure if the upload stream
|
|
|
|
* is not cloneable. If this is not acceptable, use the
|
|
|
|
* ensureUploadStreamIsCloneable() method first.
|
2017-12-13 03:38:19 +03:00
|
|
|
* aContentLength could be -1 in case the size of the stream is unknown,
|
|
|
|
* otherwise it will contain the known size of the stream.
|
2015-05-04 23:53:40 +03:00
|
|
|
*/
|
|
|
|
[noscript]
|
2017-12-13 03:38:19 +03:00
|
|
|
nsIInputStream cloneUploadStream(out long long aContentLength);
|
2009-09-09 03:29:41 +04:00
|
|
|
};
|