@jayfong/x-server 2.12.4 → 2.12.5
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.
|
@@ -87,6 +87,8 @@ class RequestService {
|
|
|
87
87
|
gotOptions.cookieJar = options.cookieJar;
|
|
88
88
|
}
|
|
89
89
|
|
|
90
|
+
gotOptions.headers = gotOptions.headers || {};
|
|
91
|
+
gotOptions.headers['User-Agent'] = options.userAgent || 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.127 Safari/537.36';
|
|
90
92
|
return gotOptions;
|
|
91
93
|
}
|
|
92
94
|
|
|
@@ -185,14 +187,24 @@ class RequestService {
|
|
|
185
187
|
}
|
|
186
188
|
|
|
187
189
|
getRaw(options, responseType) {
|
|
190
|
+
var _this$options;
|
|
191
|
+
|
|
188
192
|
return RequestService.getRaw({ ...this.options,
|
|
189
|
-
...options
|
|
193
|
+
...options,
|
|
194
|
+
headers: { ...((_this$options = this.options) == null ? void 0 : _this$options.headers),
|
|
195
|
+
...options.headers
|
|
196
|
+
}
|
|
190
197
|
}, responseType);
|
|
191
198
|
}
|
|
192
199
|
|
|
193
200
|
postRaw(options, responseType) {
|
|
201
|
+
var _this$options2;
|
|
202
|
+
|
|
194
203
|
return RequestService.postRaw({ ...this.options,
|
|
195
|
-
...options
|
|
204
|
+
...options,
|
|
205
|
+
headers: { ...((_this$options2 = this.options) == null ? void 0 : _this$options2.headers),
|
|
206
|
+
...options.headers
|
|
207
|
+
}
|
|
196
208
|
}, responseType);
|
|
197
209
|
}
|
|
198
210
|
|
|
@@ -17,6 +17,10 @@ export interface RequestServiceOptions {
|
|
|
17
17
|
*/
|
|
18
18
|
encoding?: BufferEncoding;
|
|
19
19
|
cookieJar?: CookieJar;
|
|
20
|
+
/**
|
|
21
|
+
* @default "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.127 Safari/537.36"
|
|
22
|
+
*/
|
|
23
|
+
userAgent?: string;
|
|
20
24
|
}
|
|
21
25
|
export interface RequestServiceResponse<T> {
|
|
22
26
|
status: number;
|
package/lib/services/request.js
CHANGED
|
@@ -67,6 +67,8 @@ export class RequestService {
|
|
|
67
67
|
gotOptions.cookieJar = options.cookieJar;
|
|
68
68
|
}
|
|
69
69
|
|
|
70
|
+
gotOptions.headers = gotOptions.headers || {};
|
|
71
|
+
gotOptions.headers['User-Agent'] = options.userAgent || 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.127 Safari/537.36';
|
|
70
72
|
return gotOptions;
|
|
71
73
|
}
|
|
72
74
|
|
|
@@ -165,14 +167,24 @@ export class RequestService {
|
|
|
165
167
|
}
|
|
166
168
|
|
|
167
169
|
getRaw(options, responseType) {
|
|
170
|
+
var _this$options;
|
|
171
|
+
|
|
168
172
|
return RequestService.getRaw({ ...this.options,
|
|
169
|
-
...options
|
|
173
|
+
...options,
|
|
174
|
+
headers: { ...((_this$options = this.options) == null ? void 0 : _this$options.headers),
|
|
175
|
+
...options.headers
|
|
176
|
+
}
|
|
170
177
|
}, responseType);
|
|
171
178
|
}
|
|
172
179
|
|
|
173
180
|
postRaw(options, responseType) {
|
|
181
|
+
var _this$options2;
|
|
182
|
+
|
|
174
183
|
return RequestService.postRaw({ ...this.options,
|
|
175
|
-
...options
|
|
184
|
+
...options,
|
|
185
|
+
headers: { ...((_this$options2 = this.options) == null ? void 0 : _this$options2.headers),
|
|
186
|
+
...options.headers
|
|
187
|
+
}
|
|
176
188
|
}, responseType);
|
|
177
189
|
}
|
|
178
190
|
|