Merge pull request #19 from Microsoft/markda/WebTransportResponse

0.1.4: Exposing WebTransportResopnse for the original interfaces (without request bits)…
This commit is contained in:
David de Regt 2017-11-21 17:19:13 -08:00 коммит произвёл GitHub
Родитель ef5c8d3341 512e061157
Коммит b7f96806eb
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
2 изменённых файлов: 19 добавлений и 7 удалений

Просмотреть файл

@ -1,6 +1,6 @@
{
"name": "simplerestclients",
"version": "0.1.3",
"version": "0.1.4",
"description": "A library of components for accessing RESTful services with javascript/typescript.",
"author": "David de Regt <David.de.Regt@microsoft.com>",
"scripts": {

Просмотреть файл

@ -12,26 +12,38 @@ import SyncTasks = require('synctasks');
import { ExponentialTime } from './ExponentialTime';
export interface WebResponseBase {
export interface WebTransportResponseBase {
url: string;
method: string;
requestOptions: WebRequestOptions;
requestHeaders: _.Dictionary<string>;
statusCode: number;
statusText: string|undefined;
headers: _.Dictionary<string>;
}
export interface WebResponse<T> extends WebResponseBase {
export interface WebTransportResponse<T> extends WebTransportResponseBase {
body: T;
}
export interface WebErrorResponse extends WebResponseBase {
export interface WebTransportErrorResponse extends WebTransportResponseBase {
body: any;
canceled: boolean;
timedOut: boolean;
}
export interface RestRequestInResponse {
requestOptions: WebRequestOptions;
requestHeaders: _.Dictionary<string>;
}
export interface WebResponseBase extends RestRequestInResponse, WebTransportResponseBase {
}
export interface WebResponse<T> extends RestRequestInResponse, WebTransportResponse<T> {
}
export interface WebErrorResponse extends RestRequestInResponse, WebTransportErrorResponse {
}
export enum WebRequestPriority {
DontCare = 0,
Low = 1,
@ -133,7 +145,7 @@ export let SimpleWebRequestOptions: ISimpleWebRequestOptions = {
clearTimeout: (id: number) => window.clearTimeout(id)
};
export function DefaultErrorHandler(webRequest: SimpleWebRequestBase, errResp: WebErrorResponse) {
export function DefaultErrorHandler(webRequest: SimpleWebRequestBase, errResp: WebTransportErrorResponse) {
if (errResp.canceled || !errResp.statusCode || errResp.statusCode >= 400 && errResp.statusCode < 600) {
// Fail canceled/0/4xx/5xx requests immediately. These are permenent failures, and shouldn't have retry logic applied to them.
return ErrorHandlingType.DoNotRetry;