nsIUploadChannel2.idl 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  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. interface nsIRunnable;
  8. [scriptable, uuid(2f712b52-19c5-4e0c-9e8f-b5c7c3b67049)]
  9. interface nsIUploadChannel2 : nsISupports
  10. {
  11. /**
  12. * Sets a stream to be uploaded by this channel with the specified
  13. * Content-Type and Content-Length header values.
  14. *
  15. * Most implementations of this interface require that the stream:
  16. * (1) implement threadsafe addRef and release
  17. * (2) implement nsIInputStream::readSegments
  18. * (3) implement nsISeekableStream::seek
  19. *
  20. * @param aStream
  21. * The stream to be uploaded by this channel.
  22. * @param aContentType
  23. * This value will replace any existing Content-Type
  24. * header on the HTTP request, regardless of whether
  25. * or not its empty.
  26. * @param aContentLength
  27. * A value of -1 indicates that the length of the stream should be
  28. * determined by calling the stream's |available| method.
  29. * @param aMethod
  30. * The HTTP request method to set on the stream.
  31. * @param aStreamHasHeaders
  32. * True if the stream already contains headers for the HTTP request.
  33. */
  34. void explicitSetUploadStream(in nsIInputStream aStream,
  35. in ACString aContentType,
  36. in long long aContentLength,
  37. in ACString aMethod,
  38. in boolean aStreamHasHeaders);
  39. /**
  40. * Value of aStreamHasHeaders from the last successful call to
  41. * explicitSetUploadStream. TRUE indicates the attached upload stream
  42. * contians request headers.
  43. */
  44. readonly attribute boolean uploadStreamHasHeaders;
  45. /**
  46. * Ensure the upload stream, if any, is cloneable. This may involve
  47. * async copying, so a callback runnable must be provided. It will
  48. * invoked on the current thread when the upload stream is ready
  49. * for cloning. If the stream is already cloneable, then the callback
  50. * will be invoked synchronously.
  51. */
  52. [noscript]
  53. void ensureUploadStreamIsCloneable(in nsIRunnable aCallback);
  54. /**
  55. * Clones the upload stream. May return failure if the upload stream
  56. * is not cloneable. If this is not acceptable, use the
  57. * ensureUploadStreamIsCloneable() method first.
  58. */
  59. [noscript]
  60. nsIInputStream cloneUploadStream();
  61. };