@jnode/request 2.1.1 → 2.1.3
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/package.json +1 -1
- package/src/index.js +6 -3
package/package.json
CHANGED
package/src/index.js
CHANGED
|
@@ -49,7 +49,10 @@ function request(method = 'GET', url = '', body, headers = {}, options = {}) {
|
|
|
49
49
|
|
|
50
50
|
// set Content-Disposition header
|
|
51
51
|
if (!req.getHeader('content-disposition') && (part.name || part.filename || part.disposition)) {
|
|
52
|
-
|
|
52
|
+
part.filename = part.filename ? encodeURIComponent(part.filename) : part.filename;
|
|
53
|
+
partHeaders['Content-Disposition'] = (part.disposition || 'form-data') +
|
|
54
|
+
(part.name ? `; name="${part.name}"` : '') +
|
|
55
|
+
(part.filename ? `; filename="${part.filename}"; filename*=UTF-8''${part.filename}` : '');
|
|
53
56
|
}
|
|
54
57
|
|
|
55
58
|
// write headers and body
|
|
@@ -139,11 +142,11 @@ class RequestResponse {
|
|
|
139
142
|
}
|
|
140
143
|
|
|
141
144
|
async text(encoding = 'utf8') {
|
|
142
|
-
return this['_text_' + encoding]
|
|
145
|
+
return this['_text_' + encoding] ?? (this['_text_' + encoding] = (await this.buffer()).toString(encoding));
|
|
143
146
|
}
|
|
144
147
|
|
|
145
148
|
async json(encoding = 'utf8') {
|
|
146
|
-
return this['_json_' + encoding]
|
|
149
|
+
return this['_json_' + encoding] ?? (this['_json_' + encoding] = JSON.parse(await this.text(encoding)));
|
|
147
150
|
}
|
|
148
151
|
|
|
149
152
|
rl() {
|