2015-06-29 15:30:48 -07:00
|
|
|
/// <reference path="../../typings/rx/rx.d.ts" />
|
2015-04-28 23:07:55 -07:00
|
|
|
|
|
|
|
import {
|
|
|
|
ReadyStates,
|
|
|
|
RequestModesOpts,
|
|
|
|
RequestMethods,
|
|
|
|
RequestCacheOpts,
|
|
|
|
RequestCredentialsOpts,
|
|
|
|
ResponseTypes
|
|
|
|
} from './enums';
|
|
|
|
import {Headers} from './headers';
|
2015-06-19 12:14:12 -07:00
|
|
|
import {BaseException} from 'angular2/src/facade/lang';
|
|
|
|
import {EventEmitter} from 'angular2/src/facade/async';
|
|
|
|
import {Request} from './static_request';
|
|
|
|
|
|
|
|
export class ConnectionBackend {
|
|
|
|
constructor() {}
|
|
|
|
createConnection(request: any): Connection { throw new BaseException('Abstract!'); }
|
|
|
|
}
|
|
|
|
|
|
|
|
export class Connection {
|
|
|
|
readyState: ReadyStates;
|
|
|
|
request: Request;
|
|
|
|
response: EventEmitter; //<IResponse>;
|
|
|
|
dispose(): void { throw new BaseException('Abstract!'); }
|
|
|
|
}
|
2015-04-28 23:07:55 -07:00
|
|
|
|
2015-06-13 19:48:40 -07:00
|
|
|
export interface IRequestOptions {
|
2015-06-19 12:14:12 -07:00
|
|
|
url?: string;
|
2015-04-28 23:07:55 -07:00
|
|
|
method?: RequestMethods;
|
|
|
|
headers?: Headers;
|
2015-06-19 12:14:12 -07:00
|
|
|
// TODO: Support Blob, ArrayBuffer, JSON, URLSearchParams, FormData
|
|
|
|
body?: string;
|
2015-04-28 23:07:55 -07:00
|
|
|
mode?: RequestModesOpts;
|
|
|
|
credentials?: RequestCredentialsOpts;
|
|
|
|
cache?: RequestCacheOpts;
|
|
|
|
}
|
|
|
|
|
|
|
|
export interface ResponseOptions {
|
2015-06-19 12:14:12 -07:00
|
|
|
// TODO: Support Blob, ArrayBuffer, JSON
|
|
|
|
body?: string | Object | FormData;
|
2015-04-28 23:07:55 -07:00
|
|
|
status?: number;
|
|
|
|
statusText?: string;
|
|
|
|
headers?: Headers | Object;
|
|
|
|
type?: ResponseTypes;
|
|
|
|
url?: string;
|
|
|
|
}
|
|
|
|
|
2015-06-16 10:46:12 -07:00
|
|
|
export interface IResponse {
|
2015-04-28 23:07:55 -07:00
|
|
|
headers: Headers;
|
|
|
|
ok: boolean;
|
|
|
|
status: number;
|
|
|
|
statusText: string;
|
|
|
|
type: ResponseTypes;
|
|
|
|
url: string;
|
|
|
|
totalBytes: number;
|
|
|
|
bytesLoaded: number;
|
2015-06-23 20:46:03 -07:00
|
|
|
blob(): any; // TODO: Blob
|
2015-06-19 12:14:12 -07:00
|
|
|
arrayBuffer(): any; // TODO: ArrayBuffer
|
2015-04-28 23:07:55 -07:00
|
|
|
text(): string;
|
|
|
|
json(): Object;
|
|
|
|
}
|