@opra/client 1.4.3 → 1.5.0
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.
- package/cjs/http/fetch-backend.js +6 -2
- package/cjs/http/http-client-base.js +5 -1
- package/cjs/http/http-request-observable.js +5 -2
- package/cjs/http/http-response.js +4 -1
- package/esm/http/fetch-backend.js +6 -2
- package/esm/http/http-client-base.js +6 -2
- package/esm/http/http-request-observable.js +5 -2
- package/esm/http/http-response.js +4 -1
- package/package.json +2 -2
|
@@ -167,7 +167,9 @@ class FetchBackend extends http_backend_js_1.HttpBackend {
|
|
|
167
167
|
const body = requestInit.body;
|
|
168
168
|
if (body) {
|
|
169
169
|
let contentType = '';
|
|
170
|
-
if (typeof body === 'string' ||
|
|
170
|
+
if (typeof body === 'string' ||
|
|
171
|
+
typeof body === 'number' ||
|
|
172
|
+
typeof body === 'boolean') {
|
|
171
173
|
contentType = 'text/plain; charset="UTF-8"';
|
|
172
174
|
requestInit.body = new Blob([String(body)], { type: contentType });
|
|
173
175
|
headers.set('Content-Length', String(requestInit.body.size));
|
|
@@ -192,7 +194,9 @@ class FetchBackend extends http_backend_js_1.HttpBackend {
|
|
|
192
194
|
}
|
|
193
195
|
else {
|
|
194
196
|
contentType = 'application/json;charset="UTF-8"';
|
|
195
|
-
requestInit.body = new Blob([JSON.stringify(body)], {
|
|
197
|
+
requestInit.body = new Blob([JSON.stringify(body)], {
|
|
198
|
+
type: contentType,
|
|
199
|
+
});
|
|
196
200
|
headers.set('Content-Length', String(requestInit.body.size));
|
|
197
201
|
delete requestInit.duplex;
|
|
198
202
|
}
|
|
@@ -29,7 +29,11 @@ class HttpClientBase {
|
|
|
29
29
|
if (documentId)
|
|
30
30
|
req.param('id', documentId);
|
|
31
31
|
const body = await req.getBody().catch(e => {
|
|
32
|
-
e.message =
|
|
32
|
+
e.message =
|
|
33
|
+
'Error fetching api schema from url (' +
|
|
34
|
+
this.serviceUrl +
|
|
35
|
+
').\n' +
|
|
36
|
+
e.message;
|
|
33
37
|
throw e;
|
|
34
38
|
});
|
|
35
39
|
if (body.references) {
|
|
@@ -18,13 +18,16 @@ class HttpRequestObservable extends rxjs_1.Observable {
|
|
|
18
18
|
constructor(backend, init) {
|
|
19
19
|
super(subscriber => {
|
|
20
20
|
const observe = this[constants_js_1.kContext].observe;
|
|
21
|
-
new http_interceptor_handler_js_1.HttpInterceptorHandler(backend.interceptors || [], this[constants_js_1.kBackend])
|
|
21
|
+
new http_interceptor_handler_js_1.HttpInterceptorHandler(backend.interceptors || [], this[constants_js_1.kBackend])
|
|
22
|
+
.handle(this[constants_js_1.kContext])
|
|
23
|
+
.subscribe({
|
|
22
24
|
next(event) {
|
|
23
25
|
if (observe === http_observable_type_enum_js_1.HttpObserveType.Events) {
|
|
24
26
|
subscriber.next(event);
|
|
25
27
|
return;
|
|
26
28
|
}
|
|
27
|
-
if (observe === http_observable_type_enum_js_1.HttpObserveType.ResponseHeader &&
|
|
29
|
+
if (observe === http_observable_type_enum_js_1.HttpObserveType.ResponseHeader &&
|
|
30
|
+
event.type === http_event_js_1.HttpEventType.ResponseHeader) {
|
|
28
31
|
subscriber.next(event.response);
|
|
29
32
|
subscriber.complete();
|
|
30
33
|
return;
|
|
@@ -8,7 +8,10 @@ class HttpResponse {
|
|
|
8
8
|
* Returns true if response has body to be received
|
|
9
9
|
*/
|
|
10
10
|
this.hasBody = false;
|
|
11
|
-
this.headers =
|
|
11
|
+
this.headers =
|
|
12
|
+
init?.headers instanceof Headers
|
|
13
|
+
? init?.headers
|
|
14
|
+
: new Headers(init?.headers);
|
|
12
15
|
this.status = init?.status || 200;
|
|
13
16
|
this.statusText = init?.statusText || 'OK';
|
|
14
17
|
this.url = init?.url || null;
|
|
@@ -163,7 +163,9 @@ export class FetchBackend extends HttpBackend {
|
|
|
163
163
|
const body = requestInit.body;
|
|
164
164
|
if (body) {
|
|
165
165
|
let contentType = '';
|
|
166
|
-
if (typeof body === 'string' ||
|
|
166
|
+
if (typeof body === 'string' ||
|
|
167
|
+
typeof body === 'number' ||
|
|
168
|
+
typeof body === 'boolean') {
|
|
167
169
|
contentType = 'text/plain; charset="UTF-8"';
|
|
168
170
|
requestInit.body = new Blob([String(body)], { type: contentType });
|
|
169
171
|
headers.set('Content-Length', String(requestInit.body.size));
|
|
@@ -188,7 +190,9 @@ export class FetchBackend extends HttpBackend {
|
|
|
188
190
|
}
|
|
189
191
|
else {
|
|
190
192
|
contentType = 'application/json;charset="UTF-8"';
|
|
191
|
-
requestInit.body = new Blob([JSON.stringify(body)], {
|
|
193
|
+
requestInit.body = new Blob([JSON.stringify(body)], {
|
|
194
|
+
type: contentType,
|
|
195
|
+
});
|
|
192
196
|
headers.set('Content-Length', String(requestInit.body.size));
|
|
193
197
|
delete requestInit.duplex;
|
|
194
198
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ApiDocumentFactory } from '@opra/common';
|
|
1
|
+
import { ApiDocumentFactory, } from '@opra/common';
|
|
2
2
|
import { kBackend } from '../constants.js';
|
|
3
3
|
import { HttpRequestObservable } from './http-request-observable.js';
|
|
4
4
|
const SPLIT_BACKSLASH_PATTERN = /^(\/*)(.+)/;
|
|
@@ -26,7 +26,11 @@ export class HttpClientBase {
|
|
|
26
26
|
if (documentId)
|
|
27
27
|
req.param('id', documentId);
|
|
28
28
|
const body = await req.getBody().catch(e => {
|
|
29
|
-
e.message =
|
|
29
|
+
e.message =
|
|
30
|
+
'Error fetching api schema from url (' +
|
|
31
|
+
this.serviceUrl +
|
|
32
|
+
').\n' +
|
|
33
|
+
e.message;
|
|
30
34
|
throw e;
|
|
31
35
|
});
|
|
32
36
|
if (body.references) {
|
|
@@ -14,13 +14,16 @@ export class HttpRequestObservable extends Observable {
|
|
|
14
14
|
constructor(backend, init) {
|
|
15
15
|
super(subscriber => {
|
|
16
16
|
const observe = this[kContext].observe;
|
|
17
|
-
new HttpInterceptorHandler(backend.interceptors || [], this[kBackend])
|
|
17
|
+
new HttpInterceptorHandler(backend.interceptors || [], this[kBackend])
|
|
18
|
+
.handle(this[kContext])
|
|
19
|
+
.subscribe({
|
|
18
20
|
next(event) {
|
|
19
21
|
if (observe === HttpObserveType.Events) {
|
|
20
22
|
subscriber.next(event);
|
|
21
23
|
return;
|
|
22
24
|
}
|
|
23
|
-
if (observe === HttpObserveType.ResponseHeader &&
|
|
25
|
+
if (observe === HttpObserveType.ResponseHeader &&
|
|
26
|
+
event.type === HttpEventType.ResponseHeader) {
|
|
24
27
|
subscriber.next(event.response);
|
|
25
28
|
subscriber.complete();
|
|
26
29
|
return;
|
|
@@ -5,7 +5,10 @@ export class HttpResponse {
|
|
|
5
5
|
* Returns true if response has body to be received
|
|
6
6
|
*/
|
|
7
7
|
this.hasBody = false;
|
|
8
|
-
this.headers =
|
|
8
|
+
this.headers =
|
|
9
|
+
init?.headers instanceof Headers
|
|
10
|
+
? init?.headers
|
|
11
|
+
: new Headers(init?.headers);
|
|
9
12
|
this.status = init?.status || 200;
|
|
10
13
|
this.statusText = init?.statusText || 'OK';
|
|
11
14
|
this.url = init?.url || null;
|
package/package.json
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@opra/client",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.5.0",
|
|
4
4
|
"description": "Opra Client package",
|
|
5
5
|
"author": "Panates",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"dependencies": {
|
|
8
|
-
"@opra/common": "^1.
|
|
8
|
+
"@opra/common": "^1.5.0",
|
|
9
9
|
"accepts": "^1.3.8",
|
|
10
10
|
"rxjs": ">=7.0.0",
|
|
11
11
|
"ts-gems": "^3.11.2",
|