index.d.ts 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. // Definitions by: Carlos Ballesteros Velasco <https://github.com/soywiz>
  2. // Leon Yu <https://github.com/leonyu>
  3. // BendingBender <https://github.com/BendingBender>
  4. // Maple Miao <https://github.com/mapleeit>
  5. /// <reference types="node" />
  6. import * as stream from 'stream';
  7. import * as http from 'http';
  8. export = FormData;
  9. interface Options {
  10. writable?: boolean;
  11. readable?: boolean;
  12. dataSize?: number;
  13. maxDataSize?: number;
  14. pauseStreams?: boolean;
  15. }
  16. declare class FormData extends stream.Readable {
  17. constructor(options?: Options);
  18. append(key: string, value: any, options?: FormData.AppendOptions | string): void;
  19. getHeaders(): FormData.Headers;
  20. submit(
  21. params: string | FormData.SubmitOptions,
  22. callback?: (error: Error | null, response: http.IncomingMessage) => void
  23. ): http.ClientRequest;
  24. getBuffer(): Buffer;
  25. getBoundary(): string;
  26. getLength(callback: (err: Error | null, length: number) => void): void;
  27. getLengthSync(): number;
  28. hasKnownLength(): boolean;
  29. }
  30. declare namespace FormData {
  31. interface Headers {
  32. [key: string]: any;
  33. }
  34. interface AppendOptions {
  35. header?: string | Headers;
  36. knownLength?: number;
  37. filename?: string;
  38. filepath?: string;
  39. contentType?: string;
  40. }
  41. interface SubmitOptions extends http.RequestOptions {
  42. protocol?: 'https:' | 'http:';
  43. }
  44. }