Source code

Revision control

Other Tools

1
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2
/* This Source Code Form is subject to the terms of the Mozilla Public
3
* License, v. 2.0. If a copy of the MPL was not distributed with this
4
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
5
6
#include "nsISupports.idl"
7
8
interface nsIInputStream;
9
interface nsIRunnable;
10
11
[scriptable, uuid(2f712b52-19c5-4e0c-9e8f-b5c7c3b67049)]
12
interface nsIUploadChannel2 : nsISupports
13
{
14
/**
15
* Sets a stream to be uploaded by this channel with the specified
16
* Content-Type and Content-Length header values.
17
*
18
* Most implementations of this interface require that the stream:
19
* (1) implement threadsafe addRef and release
20
* (2) implement nsIInputStream::readSegments
21
* (3) implement nsISeekableStream::seek
22
*
23
* @param aStream
24
* The stream to be uploaded by this channel.
25
* @param aContentType
26
* This value will replace any existing Content-Type
27
* header on the HTTP request, regardless of whether
28
* or not its empty.
29
* @param aContentLength
30
* A value of -1 indicates that the length of the stream should be
31
* determined by calling the stream's |available| method.
32
* @param aMethod
33
* The HTTP request method to set on the stream.
34
* @param aStreamHasHeaders
35
* True if the stream already contains headers for the HTTP request.
36
*/
37
void explicitSetUploadStream(in nsIInputStream aStream,
38
in ACString aContentType,
39
in long long aContentLength,
40
in ACString aMethod,
41
in boolean aStreamHasHeaders);
42
43
/**
44
* Value of aStreamHasHeaders from the last successful call to
45
* explicitSetUploadStream. TRUE indicates the attached upload stream
46
* contians request headers.
47
*/
48
readonly attribute boolean uploadStreamHasHeaders;
49
50
/**
51
* Ensure the upload stream, if any, is cloneable. This may involve
52
* async copying, so a callback runnable must be provided. It will
53
* invoked on the current thread when the upload stream is ready
54
* for cloning. If the stream is already cloneable, then the callback
55
* will be invoked synchronously.
56
*/
57
[noscript]
58
void ensureUploadStreamIsCloneable(in nsIRunnable aCallback);
59
60
/**
61
* Clones the upload stream. May return failure if the upload stream
62
* is not cloneable. If this is not acceptable, use the
63
* ensureUploadStreamIsCloneable() method first.
64
* aContentLength could be -1 in case the size of the stream is unknown,
65
* otherwise it will contain the known size of the stream.
66
*/
67
[noscript]
68
nsIInputStream cloneUploadStream(out long long aContentLength);
69
};