Skip to content

Commit

Permalink
Partial implementation of HTTP module
Browse files Browse the repository at this point in the history
  • Loading branch information
Fritz committed Dec 19, 2014
1 parent ce3f18f commit 925a0bc
Showing 1 changed file with 40 additions and 8 deletions.
48 changes: 40 additions & 8 deletions lib/node.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,9 +101,9 @@ type child_process$spawnOpts = {
}

type child_process$ChildProcess = {
stdin: Stream;
stdout: Stream;
stderr: Stream;
stdin: stream$Stream;
stdout: stream$Stream;
stderr: stream$Stream;
pid: number;
connected: boolean;

Expand Down Expand Up @@ -402,7 +402,7 @@ declare class events$EventEmitter {
addListener(event: string, listener: Function): events$EventEmitter;
emit(event: string, ...args:Array): boolean;
listeners(event: string): Array<Function>;
on(event: string, listener: Function): events$EventEmitter;
on(event: string, listener: (data: any) => void): events$EventEmitter;
once(event: string, listener: Function): events$EventEmitter;
removeAllListeners(events?: Array<string>): events$EventEmitter;
removeListener(event: string, listener: Function): events$EventEmitter;
Expand All @@ -419,7 +419,30 @@ declare module "fs" {
}

declare module "http" {
// TODO
declare class IncomingMessage extends stream$Readable {
headers: Object;
httpVersion: string;
method: string;
trailers: Object;
setTimeout(msecs: number, callback: Function): void;
socket: any; // TODO net.Socket
statusCode: number;
url: String;
}

declare class OutgoingMessage extends stream$Stream {
write(ins: string): void;
end(): void;
}

declare class ClientRequest extends OutgoingMessage {
// TODO
}

declare function request(
options: Object | string,
callback: (response: IncomingMessage) => void
): ClientRequest;
}

declare module "https" {
Expand Down Expand Up @@ -450,12 +473,21 @@ declare module "readline" {
// TODO
}

type Stream = {
// TODO
declare class stream$Stream extends events$EventEmitter {
pipe(dest: any, options: any): void;
}

declare class stream$Readable extends stream$Stream {
setEncoding(): void;
}

declare class stream$Writable extends stream$Stream {
close(): void;
finish(): void;
}

declare module "stream" {
// TODO
declare class Stream extends stream$Stream {}
}

declare module "string_decoder" {
Expand Down

0 comments on commit 925a0bc

Please sign in to comment.