@alterior/http 3.11.1 → 3.13.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (156) hide show
  1. package/dist/backend.d.ts +38 -38
  2. package/dist/backend.js +38 -38
  3. package/dist/client.d.ts +2108 -2108
  4. package/dist/client.js +265 -265
  5. package/dist/client.js.map +1 -1
  6. package/dist/headers.d.ts +57 -57
  7. package/dist/headers.js +187 -187
  8. package/dist/headers.js.map +1 -1
  9. package/dist/index.d.ts +18 -18
  10. package/dist/index.js +42 -42
  11. package/dist/interceptor.d.ts +63 -63
  12. package/dist/interceptor.js +43 -43
  13. package/dist/interceptor.js.map +1 -1
  14. package/dist/module.d.ts +101 -101
  15. package/dist/module.js +188 -188
  16. package/dist/module.js.map +1 -1
  17. package/dist/params.d.ts +98 -98
  18. package/dist/params.js +184 -184
  19. package/dist/params.js.map +1 -1
  20. package/dist/request.d.ts +130 -130
  21. package/dist/request.js +260 -260
  22. package/dist/request.js.map +1 -1
  23. package/dist/response.d.ts +267 -267
  24. package/dist/response.js +165 -165
  25. package/dist/response.js.map +1 -1
  26. package/dist/server.d.ts +28 -28
  27. package/dist/server.js +119 -119
  28. package/dist/server.js.map +1 -1
  29. package/dist/test/client.test.d.ts +8 -8
  30. package/dist/test/client.test.js +163 -163
  31. package/dist/test/client.test.js.map +1 -1
  32. package/dist/test/headers.test.d.ts +1 -1
  33. package/dist/test/headers.test.js +126 -126
  34. package/dist/test/module.test.d.ts +1 -1
  35. package/dist/test/module.test.js +117 -117
  36. package/dist/test/module.test.js.map +1 -1
  37. package/dist/test/params.test.d.ts +1 -1
  38. package/dist/test/params.test.js +63 -63
  39. package/dist/test/request.test.d.ts +8 -8
  40. package/dist/test/request.test.js +159 -159
  41. package/dist/test/request.test.js.map +1 -1
  42. package/dist/test/response.test.d.ts +1 -1
  43. package/dist/test/response.test.js +79 -79
  44. package/dist/test/response.test.js.map +1 -1
  45. package/dist/test/test.d.ts +1 -1
  46. package/dist/test/test.js +16 -16
  47. package/dist/test/xhr.mock.d.ts +48 -48
  48. package/dist/test/xhr.mock.js +94 -94
  49. package/dist/test/xhr.mock.js.map +1 -1
  50. package/dist/test/xhr.test.d.ts +1 -1
  51. package/dist/test/xhr.test.js +344 -344
  52. package/dist/test/xhr.test.js.map +1 -1
  53. package/dist/test/xsrf.test.d.ts +1 -1
  54. package/dist/test/xsrf.test.js +63 -63
  55. package/dist/test/xsrf.test.js.map +1 -1
  56. package/dist/testing/api.d.ts +102 -102
  57. package/dist/testing/api.js +19 -19
  58. package/dist/testing/backend.d.ts +63 -63
  59. package/dist/testing/backend.js +141 -141
  60. package/dist/testing/backend.js.map +1 -1
  61. package/dist/testing/index.d.ts +10 -10
  62. package/dist/testing/index.js +16 -16
  63. package/dist/testing/module.d.ts +16 -16
  64. package/dist/testing/module.js +38 -38
  65. package/dist/testing/module.js.map +1 -1
  66. package/dist/testing/request.d.ts +56 -56
  67. package/dist/testing/request.js +177 -177
  68. package/dist/testing/request.js.map +1 -1
  69. package/dist/testing/request.test.d.ts +8 -8
  70. package/dist/testing/request.test.js +24 -24
  71. package/dist/xhr.d.ts +42 -42
  72. package/dist/xhr.js +298 -298
  73. package/dist/xhr.js.map +1 -1
  74. package/dist/xsrf.d.ts +37 -37
  75. package/dist/xsrf.js +55 -55
  76. package/dist/xsrf.js.map +1 -1
  77. package/dist.esm/backend.d.ts +38 -38
  78. package/dist.esm/backend.js +33 -33
  79. package/dist.esm/client.d.ts +2108 -2108
  80. package/dist.esm/client.js +262 -262
  81. package/dist.esm/client.js.map +1 -1
  82. package/dist.esm/headers.d.ts +57 -57
  83. package/dist.esm/headers.js +183 -183
  84. package/dist.esm/headers.js.map +1 -1
  85. package/dist.esm/index.d.ts +18 -18
  86. package/dist.esm/index.js +18 -18
  87. package/dist.esm/interceptor.d.ts +63 -63
  88. package/dist.esm/interceptor.js +39 -39
  89. package/dist.esm/interceptor.js.map +1 -1
  90. package/dist.esm/module.d.ts +101 -101
  91. package/dist.esm/module.js +183 -183
  92. package/dist.esm/module.js.map +1 -1
  93. package/dist.esm/params.d.ts +98 -98
  94. package/dist.esm/params.js +179 -179
  95. package/dist.esm/params.js.map +1 -1
  96. package/dist.esm/request.d.ts +130 -130
  97. package/dist.esm/request.js +256 -256
  98. package/dist.esm/request.js.map +1 -1
  99. package/dist.esm/response.d.ts +267 -267
  100. package/dist.esm/response.js +158 -158
  101. package/dist.esm/response.js.map +1 -1
  102. package/dist.esm/server.d.ts +28 -28
  103. package/dist.esm/server.js +113 -113
  104. package/dist.esm/server.js.map +1 -1
  105. package/dist.esm/test/client.test.d.ts +8 -8
  106. package/dist.esm/test/client.test.js +161 -161
  107. package/dist.esm/test/client.test.js.map +1 -1
  108. package/dist.esm/test/headers.test.d.ts +1 -1
  109. package/dist.esm/test/headers.test.js +124 -124
  110. package/dist.esm/test/module.test.d.ts +1 -1
  111. package/dist.esm/test/module.test.js +115 -115
  112. package/dist.esm/test/module.test.js.map +1 -1
  113. package/dist.esm/test/params.test.d.ts +1 -1
  114. package/dist.esm/test/params.test.js +61 -61
  115. package/dist.esm/test/request.test.d.ts +8 -8
  116. package/dist.esm/test/request.test.js +157 -157
  117. package/dist.esm/test/request.test.js.map +1 -1
  118. package/dist.esm/test/response.test.d.ts +1 -1
  119. package/dist.esm/test/response.test.js +77 -77
  120. package/dist.esm/test/response.test.js.map +1 -1
  121. package/dist.esm/test/test.d.ts +1 -1
  122. package/dist.esm/test/test.js +14 -14
  123. package/dist.esm/test/xhr.mock.d.ts +48 -48
  124. package/dist.esm/test/xhr.mock.js +88 -88
  125. package/dist.esm/test/xhr.mock.js.map +1 -1
  126. package/dist.esm/test/xhr.test.d.ts +1 -1
  127. package/dist.esm/test/xhr.test.js +342 -342
  128. package/dist.esm/test/xhr.test.js.map +1 -1
  129. package/dist.esm/test/xsrf.test.d.ts +1 -1
  130. package/dist.esm/test/xsrf.test.js +61 -61
  131. package/dist.esm/test/xsrf.test.js.map +1 -1
  132. package/dist.esm/testing/api.d.ts +102 -102
  133. package/dist.esm/testing/api.js +15 -15
  134. package/dist.esm/testing/backend.d.ts +63 -63
  135. package/dist.esm/testing/backend.js +138 -138
  136. package/dist.esm/testing/backend.js.map +1 -1
  137. package/dist.esm/testing/index.d.ts +10 -10
  138. package/dist.esm/testing/index.js +10 -10
  139. package/dist.esm/testing/module.d.ts +16 -16
  140. package/dist.esm/testing/module.js +35 -35
  141. package/dist.esm/testing/module.js.map +1 -1
  142. package/dist.esm/testing/request.d.ts +56 -56
  143. package/dist.esm/testing/request.js +173 -173
  144. package/dist.esm/testing/request.js.map +1 -1
  145. package/dist.esm/testing/request.test.d.ts +8 -8
  146. package/dist.esm/testing/request.test.js +22 -22
  147. package/dist.esm/xhr.d.ts +42 -42
  148. package/dist.esm/xhr.js +294 -294
  149. package/dist.esm/xhr.js.map +1 -1
  150. package/dist.esm/xsrf.d.ts +37 -37
  151. package/dist.esm/xsrf.js +51 -51
  152. package/dist.esm/xsrf.js.map +1 -1
  153. package/package.json +11 -11
  154. package/tsconfig.esm.tsbuildinfo +1 -0
  155. package/tsconfig.json +0 -2
  156. package/tsconfig.tsbuildinfo +1 -8046
@@ -1,174 +1,174 @@
1
- /**
2
- * @license
3
- * Copyright Google Inc. All Rights Reserved.
4
- *
5
- * Use of this source code is governed by an MIT-style license that can be
6
- * found in the LICENSE file at https://angular.io/license
7
- */
8
- import { HttpResponse, HttpErrorResponse } from '../response';
9
- import { HttpHeaders } from '../headers';
10
- /**
11
- * A mock requests that was received and is ready to be answered.
12
- *
13
- * This interface allows access to the underlying `HttpRequest`, and allows
14
- * responding with `HttpEvent`s or `HttpErrorResponse`s.
15
- *
16
- *
17
- */
18
- export class TestRequest {
19
- /**
20
- * Whether the request was cancelled after it was sent.
21
- */
22
- get cancelled() { return this._cancelled; }
23
- constructor(request, observer) {
24
- this.request = request;
25
- this.observer = observer;
26
- /**
27
- * @internal set by `HttpClientTestingBackend`
28
- */
29
- this._cancelled = false;
30
- }
31
- /**
32
- * Resolve the request by returning a body plus additional HTTP information (such as response
33
- * headers) if provided.
34
- *
35
- * Both successful and unsuccessful responses can be delivered via `flush()`.
36
- */
37
- flush(body, opts = {}) {
38
- if (this.cancelled) {
39
- throw new Error(`Cannot flush a cancelled request.`);
40
- }
41
- const url = this.request.urlWithParams;
42
- const headers = (opts.headers instanceof HttpHeaders) ? opts.headers : new HttpHeaders(opts.headers);
43
- body = _maybeConvertBody(this.request.responseType, body);
44
- let statusText = opts.statusText;
45
- let status = opts.status !== undefined ? opts.status : 200;
46
- if (opts.status === undefined) {
47
- if (body === null) {
48
- status = 204;
49
- statusText = statusText || 'No Content';
50
- }
51
- else {
52
- statusText = statusText || 'OK';
53
- }
54
- }
55
- if (statusText === undefined) {
56
- throw new Error('statusText is required when setting a custom status.');
57
- }
58
- if (status >= 200 && status < 300) {
59
- this.observer.next(new HttpResponse({ body, headers, status, statusText, url }));
60
- this.observer.complete();
61
- }
62
- else {
63
- this.observer.error(new HttpErrorResponse({ error: body, headers, status, statusText, url }));
64
- }
65
- }
66
- /**
67
- * Resolve the request by returning an `ErrorEvent` (e.g. simulating a network failure).
68
- */
69
- error(error, opts = {}) {
70
- if (this.cancelled) {
71
- throw new Error(`Cannot return an error for a cancelled request.`);
72
- }
73
- if (opts.status && opts.status >= 200 && opts.status < 300) {
74
- throw new Error(`error() called with a successful status.`);
75
- }
76
- const headers = (opts.headers instanceof HttpHeaders) ? opts.headers : new HttpHeaders(opts.headers);
77
- this.observer.error(new HttpErrorResponse({
78
- error,
79
- headers,
80
- status: opts.status || 0,
81
- statusText: opts.statusText || '',
82
- url: this.request.urlWithParams,
83
- }));
84
- }
85
- /**
86
- * Deliver an arbitrary `HttpEvent` (such as a progress event) on the response stream for this
87
- * request.
88
- */
89
- event(event) {
90
- if (this.cancelled) {
91
- throw new Error(`Cannot send events to a cancelled request.`);
92
- }
93
- this.observer.next(event);
94
- }
95
- }
96
- /**
97
- * Helper function to convert a response body to an ArrayBuffer.
98
- */
99
- function _toArrayBufferBody(body) {
100
- if (typeof ArrayBuffer === 'undefined') {
101
- throw new Error('ArrayBuffer responses are not supported on this platform.');
102
- }
103
- if (body instanceof ArrayBuffer) {
104
- return body;
105
- }
106
- throw new Error('Automatic conversion to ArrayBuffer is not supported for response type.');
107
- }
108
- /**
109
- * Helper function to convert a response body to a Blob.
110
- */
111
- function _toBlob(body) {
112
- if (typeof Blob === 'undefined') {
113
- throw new Error('Blob responses are not supported on this platform.');
114
- }
115
- if (body instanceof Blob) {
116
- return body;
117
- }
118
- if (ArrayBuffer && body instanceof ArrayBuffer) {
119
- return new Blob([body]);
120
- }
121
- throw new Error('Automatic conversion to Blob is not supported for response type.');
122
- }
123
- /**
124
- * Helper function to convert a response body to JSON data.
125
- */
126
- function _toJsonBody(body, format = 'JSON') {
127
- if (typeof ArrayBuffer !== 'undefined' && body instanceof ArrayBuffer) {
128
- throw new Error(`Automatic conversion to ${format} is not supported for ArrayBuffers.`);
129
- }
130
- if (typeof Blob !== 'undefined' && body instanceof Blob) {
131
- throw new Error(`Automatic conversion to ${format} is not supported for Blobs.`);
132
- }
133
- if (typeof body === 'string' || typeof body === 'number' || typeof body === 'object' ||
134
- Array.isArray(body)) {
135
- return body;
136
- }
137
- throw new Error(`Automatic conversion to ${format} is not supported for response type.`);
138
- }
139
- /**
140
- * Helper function to convert a response body to a string.
141
- */
142
- function _toTextBody(body) {
143
- if (typeof body === 'string') {
144
- return body;
145
- }
146
- if (typeof ArrayBuffer !== 'undefined' && body instanceof ArrayBuffer) {
147
- throw new Error('Automatic conversion to text is not supported for ArrayBuffers.');
148
- }
149
- if (typeof Blob !== 'undefined' && body instanceof Blob) {
150
- throw new Error('Automatic conversion to text is not supported for Blobs.');
151
- }
152
- return JSON.stringify(_toJsonBody(body, 'text'));
153
- }
154
- /**
155
- * Convert a response body to the requested type.
156
- */
157
- function _maybeConvertBody(responseType, body) {
158
- if (body === null) {
159
- return null;
160
- }
161
- switch (responseType) {
162
- case 'arraybuffer':
163
- return _toArrayBufferBody(body);
164
- case 'blob':
165
- return _toBlob(body);
166
- case 'json':
167
- return _toJsonBody(body);
168
- case 'text':
169
- return _toTextBody(body);
170
- default:
171
- throw new Error(`Unsupported responseType: ${responseType}`);
172
- }
173
- }
1
+ /**
2
+ * @license
3
+ * Copyright Google Inc. All Rights Reserved.
4
+ *
5
+ * Use of this source code is governed by an MIT-style license that can be
6
+ * found in the LICENSE file at https://angular.io/license
7
+ */
8
+ import { HttpResponse, HttpErrorResponse } from '../response';
9
+ import { HttpHeaders } from '../headers';
10
+ /**
11
+ * A mock requests that was received and is ready to be answered.
12
+ *
13
+ * This interface allows access to the underlying `HttpRequest`, and allows
14
+ * responding with `HttpEvent`s or `HttpErrorResponse`s.
15
+ *
16
+ *
17
+ */
18
+ export class TestRequest {
19
+ /**
20
+ * Whether the request was cancelled after it was sent.
21
+ */
22
+ get cancelled() { return this._cancelled; }
23
+ constructor(request, observer) {
24
+ this.request = request;
25
+ this.observer = observer;
26
+ /**
27
+ * @internal set by `HttpClientTestingBackend`
28
+ */
29
+ this._cancelled = false;
30
+ }
31
+ /**
32
+ * Resolve the request by returning a body plus additional HTTP information (such as response
33
+ * headers) if provided.
34
+ *
35
+ * Both successful and unsuccessful responses can be delivered via `flush()`.
36
+ */
37
+ flush(body, opts = {}) {
38
+ if (this.cancelled) {
39
+ throw new Error(`Cannot flush a cancelled request.`);
40
+ }
41
+ const url = this.request.urlWithParams;
42
+ const headers = (opts.headers instanceof HttpHeaders) ? opts.headers : new HttpHeaders(opts.headers);
43
+ body = _maybeConvertBody(this.request.responseType, body);
44
+ let statusText = opts.statusText;
45
+ let status = opts.status !== undefined ? opts.status : 200;
46
+ if (opts.status === undefined) {
47
+ if (body === null) {
48
+ status = 204;
49
+ statusText = statusText || 'No Content';
50
+ }
51
+ else {
52
+ statusText = statusText || 'OK';
53
+ }
54
+ }
55
+ if (statusText === undefined) {
56
+ throw new Error('statusText is required when setting a custom status.');
57
+ }
58
+ if (status >= 200 && status < 300) {
59
+ this.observer.next(new HttpResponse({ body, headers, status, statusText, url }));
60
+ this.observer.complete();
61
+ }
62
+ else {
63
+ this.observer.error(new HttpErrorResponse({ error: body, headers, status, statusText, url }));
64
+ }
65
+ }
66
+ /**
67
+ * Resolve the request by returning an `ErrorEvent` (e.g. simulating a network failure).
68
+ */
69
+ error(error, opts = {}) {
70
+ if (this.cancelled) {
71
+ throw new Error(`Cannot return an error for a cancelled request.`);
72
+ }
73
+ if (opts.status && opts.status >= 200 && opts.status < 300) {
74
+ throw new Error(`error() called with a successful status.`);
75
+ }
76
+ const headers = (opts.headers instanceof HttpHeaders) ? opts.headers : new HttpHeaders(opts.headers);
77
+ this.observer.error(new HttpErrorResponse({
78
+ error,
79
+ headers,
80
+ status: opts.status || 0,
81
+ statusText: opts.statusText || '',
82
+ url: this.request.urlWithParams,
83
+ }));
84
+ }
85
+ /**
86
+ * Deliver an arbitrary `HttpEvent` (such as a progress event) on the response stream for this
87
+ * request.
88
+ */
89
+ event(event) {
90
+ if (this.cancelled) {
91
+ throw new Error(`Cannot send events to a cancelled request.`);
92
+ }
93
+ this.observer.next(event);
94
+ }
95
+ }
96
+ /**
97
+ * Helper function to convert a response body to an ArrayBuffer.
98
+ */
99
+ function _toArrayBufferBody(body) {
100
+ if (typeof ArrayBuffer === 'undefined') {
101
+ throw new Error('ArrayBuffer responses are not supported on this platform.');
102
+ }
103
+ if (body instanceof ArrayBuffer) {
104
+ return body;
105
+ }
106
+ throw new Error('Automatic conversion to ArrayBuffer is not supported for response type.');
107
+ }
108
+ /**
109
+ * Helper function to convert a response body to a Blob.
110
+ */
111
+ function _toBlob(body) {
112
+ if (typeof Blob === 'undefined') {
113
+ throw new Error('Blob responses are not supported on this platform.');
114
+ }
115
+ if (body instanceof Blob) {
116
+ return body;
117
+ }
118
+ if (ArrayBuffer && body instanceof ArrayBuffer) {
119
+ return new Blob([body]);
120
+ }
121
+ throw new Error('Automatic conversion to Blob is not supported for response type.');
122
+ }
123
+ /**
124
+ * Helper function to convert a response body to JSON data.
125
+ */
126
+ function _toJsonBody(body, format = 'JSON') {
127
+ if (typeof ArrayBuffer !== 'undefined' && body instanceof ArrayBuffer) {
128
+ throw new Error(`Automatic conversion to ${format} is not supported for ArrayBuffers.`);
129
+ }
130
+ if (typeof Blob !== 'undefined' && body instanceof Blob) {
131
+ throw new Error(`Automatic conversion to ${format} is not supported for Blobs.`);
132
+ }
133
+ if (typeof body === 'string' || typeof body === 'number' || typeof body === 'object' ||
134
+ Array.isArray(body)) {
135
+ return body;
136
+ }
137
+ throw new Error(`Automatic conversion to ${format} is not supported for response type.`);
138
+ }
139
+ /**
140
+ * Helper function to convert a response body to a string.
141
+ */
142
+ function _toTextBody(body) {
143
+ if (typeof body === 'string') {
144
+ return body;
145
+ }
146
+ if (typeof ArrayBuffer !== 'undefined' && body instanceof ArrayBuffer) {
147
+ throw new Error('Automatic conversion to text is not supported for ArrayBuffers.');
148
+ }
149
+ if (typeof Blob !== 'undefined' && body instanceof Blob) {
150
+ throw new Error('Automatic conversion to text is not supported for Blobs.');
151
+ }
152
+ return JSON.stringify(_toJsonBody(body, 'text'));
153
+ }
154
+ /**
155
+ * Convert a response body to the requested type.
156
+ */
157
+ function _maybeConvertBody(responseType, body) {
158
+ if (body === null) {
159
+ return null;
160
+ }
161
+ switch (responseType) {
162
+ case 'arraybuffer':
163
+ return _toArrayBufferBody(body);
164
+ case 'blob':
165
+ return _toBlob(body);
166
+ case 'json':
167
+ return _toJsonBody(body);
168
+ case 'text':
169
+ return _toTextBody(body);
170
+ default:
171
+ throw new Error(`Unsupported responseType: ${responseType}`);
172
+ }
173
+ }
174
174
  //# sourceMappingURL=request.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"request.js","sourceRoot":"","sources":["../../src/testing/request.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAIH,OAAO,EAAa,YAAY,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AACzE,OAAO,EAAE,WAAW,EAAE,MAAM,YAA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AAC,CAAC;QACvB,KAAK,MAAM;YACT,OAAO,WAAW,CAAC,IAAI,CAAC,CAAC;QAC3B,KAAK,MAAM;YACT,OAAO,WAAW,CAAC,IAAI,CAAC,CAAC;QAC3B;YACE,MAAM,IAAI,KAAK,CAAC,6BAA6B,YAAY,EAAE,CAAC,CAAC;IACjE,CAAC;AACH,CAAC"}
@@ -1,9 +1,9 @@
1
- /**
2
- * @license
3
- * Copyright Google Inc. All Rights Reserved.
4
- *
5
- * Use of this source code is governed by an MIT-style license that can be
6
- * found in the LICENSE file at https://angular.io/license
7
- */
8
- export {};
1
+ /**
2
+ * @license
3
+ * Copyright Google Inc. All Rights Reserved.
4
+ *
5
+ * Use of this source code is governed by an MIT-style license that can be
6
+ * found in the LICENSE file at https://angular.io/license
7
+ */
8
+ export {};
9
9
  //# sourceMappingURL=request.test.d.ts.map
@@ -1,23 +1,23 @@
1
- /**
2
- * @license
3
- * Copyright Google Inc. All Rights Reserved.
4
- *
5
- * Use of this source code is governed by an MIT-style license that can be
6
- * found in the LICENSE file at https://angular.io/license
7
- */
8
- import { describe, it } from 'razmin';
9
- import { HttpClient } from '../../src/client';
10
- import { HttpClientTestingBackend } from './backend';
11
- import { expect } from 'chai';
12
- describe('HttpClient TestRequest', () => {
13
- it('accepts a null body', () => {
14
- const mock = new HttpClientTestingBackend();
15
- const client = new HttpClient(mock);
16
- let resp;
17
- client.post('/some-url', { test: 'test' }).subscribe(body => { resp = body; });
18
- const req = mock.expectOne('/some-url');
19
- req.flush(null);
20
- expect(resp).to.be.null;
21
- });
22
- });
1
+ /**
2
+ * @license
3
+ * Copyright Google Inc. All Rights Reserved.
4
+ *
5
+ * Use of this source code is governed by an MIT-style license that can be
6
+ * found in the LICENSE file at https://angular.io/license
7
+ */
8
+ import { describe, it } from 'razmin';
9
+ import { HttpClient } from '../../src/client';
10
+ import { HttpClientTestingBackend } from './backend';
11
+ import { expect } from 'chai';
12
+ describe('HttpClient TestRequest', () => {
13
+ it('accepts a null body', () => {
14
+ const mock = new HttpClientTestingBackend();
15
+ const client = new HttpClient(mock);
16
+ let resp;
17
+ client.post('/some-url', { test: 'test' }).subscribe(body => { resp = body; });
18
+ const req = mock.expectOne('/some-url');
19
+ req.flush(null);
20
+ expect(resp).to.be.null;
21
+ });
22
+ });
23
23
  //# sourceMappingURL=request.test.js.map
package/dist.esm/xhr.d.ts CHANGED
@@ -1,43 +1,43 @@
1
- /**
2
- * @license
3
- * Copyright Google Inc. All Rights Reserved.
4
- *
5
- * Use of this source code is governed by an MIT-style license that can be
6
- * found in the LICENSE file at https://angular.io/license
7
- */
8
- import { Observable } from 'rxjs';
9
- import { HttpBackend } from './backend';
10
- import { HttpRequest } from './request';
11
- import { HttpEvent } from './response';
12
- /**
13
- * A wrapper around the `XMLHttpRequest` constructor.
14
- *
15
- *
16
- */
17
- export declare abstract class XhrFactory {
18
- abstract build(): XMLHttpRequest;
19
- }
20
- /**
21
- * A factory for @{link HttpXhrBackend} that uses the `XMLHttpRequest` browser API.
22
- *
23
- *
24
- */
25
- export declare class BrowserXhr implements XhrFactory {
26
- constructor();
27
- build(): any;
28
- }
29
- /**
30
- * An `HttpBackend` which uses the XMLHttpRequest API to send
31
- * requests to a backend server.
32
- *
33
- *
34
- */
35
- export declare class HttpXhrBackend implements HttpBackend {
36
- private xhrFactory;
37
- constructor(xhrFactory: XhrFactory);
38
- /**
39
- * Process a request and return a stream of response events.
40
- */
41
- handle(req: HttpRequest<any>): Observable<HttpEvent<any>>;
42
- }
1
+ /**
2
+ * @license
3
+ * Copyright Google Inc. All Rights Reserved.
4
+ *
5
+ * Use of this source code is governed by an MIT-style license that can be
6
+ * found in the LICENSE file at https://angular.io/license
7
+ */
8
+ import { Observable } from 'rxjs';
9
+ import { HttpBackend } from './backend';
10
+ import { HttpRequest } from './request';
11
+ import { HttpEvent } from './response';
12
+ /**
13
+ * A wrapper around the `XMLHttpRequest` constructor.
14
+ *
15
+ *
16
+ */
17
+ export declare abstract class XhrFactory {
18
+ abstract build(): XMLHttpRequest;
19
+ }
20
+ /**
21
+ * A factory for @{link HttpXhrBackend} that uses the `XMLHttpRequest` browser API.
22
+ *
23
+ *
24
+ */
25
+ export declare class BrowserXhr implements XhrFactory {
26
+ constructor();
27
+ build(): any;
28
+ }
29
+ /**
30
+ * An `HttpBackend` which uses the XMLHttpRequest API to send
31
+ * requests to a backend server.
32
+ *
33
+ *
34
+ */
35
+ export declare class HttpXhrBackend implements HttpBackend {
36
+ private xhrFactory;
37
+ constructor(xhrFactory: XhrFactory);
38
+ /**
39
+ * Process a request and return a stream of response events.
40
+ */
41
+ handle(req: HttpRequest<any>): Observable<HttpEvent<any>>;
42
+ }
43
43
  //# sourceMappingURL=xhr.d.ts.map