mirror of
https://github.com/microsoft/vscode.git
synced 2026-04-21 09:08:53 +01:00
implement IRequestFunction with xhr
This commit is contained in:
@@ -31,11 +31,19 @@ export interface IRequestOptions {
|
||||
}
|
||||
|
||||
export interface IRequestContext {
|
||||
req: http.ClientRequest;
|
||||
res: http.ClientResponse;
|
||||
// req: http.ClientRequest;
|
||||
// res: http.ClientResponse;
|
||||
res: {
|
||||
headers: { [n: string]: string };
|
||||
statusCode?: number;
|
||||
};
|
||||
stream: Stream;
|
||||
}
|
||||
|
||||
export interface IRequestFunction {
|
||||
(options: IRequestOptions): TPromise<IRequestContext>;
|
||||
}
|
||||
|
||||
export function request(options: IRequestOptions): TPromise<IRequestContext> {
|
||||
let req: http.ClientRequest;
|
||||
|
||||
@@ -71,7 +79,7 @@ export function request(options: IRequestOptions): TPromise<IRequestContext> {
|
||||
stream = stream.pipe(createGunzip());
|
||||
}
|
||||
|
||||
c({ req, res, stream });
|
||||
c({ res, stream });
|
||||
}
|
||||
});
|
||||
|
||||
@@ -144,4 +152,4 @@ export function asJson<T>(context: IRequestContext): TPromise<T> {
|
||||
context.stream.on('end', () => c(JSON.parse(buffer.join(''))));
|
||||
context.stream.on('error', e);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user