nsIUploadChannel.idl 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  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. #include "nsISupports.idl"
  6. interface nsIInputStream;
  7. /**
  8. * nsIUploadChannel
  9. *
  10. * A channel may optionally implement this interface if it supports the
  11. * notion of uploading a data stream. The upload stream may only be set
  12. * prior to the invocation of asyncOpen on the channel.
  13. */
  14. [scriptable, uuid(5cfe15bd-5adb-4a7f-9e55-4f5a67d15794)]
  15. interface nsIUploadChannel : nsISupports
  16. {
  17. /**
  18. * Sets a stream to be uploaded by this channel.
  19. *
  20. * Most implementations of this interface require that the stream:
  21. * (1) implement threadsafe addRef and release
  22. * (2) implement nsIInputStream::readSegments
  23. * (3) implement nsISeekableStream::seek
  24. *
  25. * History here is that we need to support both streams that already have
  26. * headers (e.g., Content-Type and Content-Length) information prepended to
  27. * the stream (by plugins) as well as clients (composer, uploading
  28. * application) that want to upload data streams without any knowledge of
  29. * protocol specifications. For this reason, we have a special meaning
  30. * for the aContentType parameter (see below).
  31. *
  32. * @param aStream
  33. * The stream to be uploaded by this channel.
  34. * @param aContentType
  35. * If aContentType is empty, the protocol will assume that no
  36. * content headers are to be added to the uploaded stream and that
  37. * any required headers are already encoded in the stream. In the
  38. * case of HTTP, if this parameter is non-empty, then its value will
  39. * replace any existing Content-Type header on the HTTP request.
  40. * In the case of FTP and FILE, this parameter is ignored.
  41. * @param aContentLength
  42. * A value of -1 indicates that the length of the stream should be
  43. * determined by calling the stream's |available| method.
  44. */
  45. void setUploadStream(in nsIInputStream aStream,
  46. in ACString aContentType,
  47. in long long aContentLength);
  48. /**
  49. * Get the stream (to be) uploaded by this channel.
  50. */
  51. readonly attribute nsIInputStream uploadStream;
  52. };