Completely updated React, fixed #11, (hopefully)

This commit is contained in:
2018-03-04 19:11:49 -05:00
parent 6e0afd6e2a
commit 34e5f5139a
13674 changed files with 333464 additions and 473223 deletions

View File

@@ -493,6 +493,22 @@ Or piping the response to a file:
const req = request.get('/some.json');
req.pipe(stream);
Note that you should **NOT** attempt to pipe the result of `.end()` or the `Response` object:
// Don't do either of these:
const stream = getAWritableStream();
const req = request
.get('/some.json')
// this pipes garbage to the stream and fails in unexpected ways
.end((err, response) => response.pipe(stream))
const req = request
.get('/some.json')
.end()
// this is also unsupported, .pipe calls .end for you.
.pipe(stream);
In a [future version](https://github.com/visionmedia/superagent/issues/1188) of superagent, improper calls to `pipe()` will fail.
## Multipart requests
SuperAgent is also great for _building_ multipart requests for which it provides methods `.attach()` and `.field()`.

View File

@@ -243,7 +243,9 @@ function parseHeader(str) {
*/
function isJSON(mime) {
return /[\/+]json\b/.test(mime);
// should match /json or +json
// but not /json-seq
return /[\/+]json($|[^-\w])/.test(mime);
}
/**

View File

@@ -164,7 +164,7 @@ RequestBase(Request.prototype);
*
* ``` js
* request.post('http://localhost/upload')
* .attach(new Buffer('<b>Hello world</b>'), 'hello.html')
* .attach('field', Buffer.from('<b>Hello world</b>'), 'hello.html')
* .end(callback);
* ```
*
@@ -688,20 +688,23 @@ Request.prototype.callback = function(err, res){
if (!err) {
try {
if (this._isResponseOK(res)) {
return fn(err, res);
if (!this._isResponseOK(res)) {
let msg = 'Unsuccessful HTTP response';
if (res) {
msg = http.STATUS_CODES[res.status] || msg;
}
err = new Error(msg);
err.status = res ? res.status : undefined;
}
let msg = 'Unsuccessful HTTP response';
if (res) {
msg = http.STATUS_CODES[res.status] || msg;
}
err = new Error(msg);
err.status = res ? res.status : undefined;
} catch (new_err) {
err = new_err;
}
}
// It's important that the callback is called outside try/catch
// to avoid double callback
if (!err) {
return fn(null, res);
}
err.response = res;
if (this._maxRetries) err.retries = this._retries - 1;
@@ -1064,7 +1067,9 @@ function isImageOrVideo(mime) {
*/
function isJSON(mime) {
return /[\/+]json\b/.test(mime);
// should match /json or +json
// but not /json-seq
return /[\/+]json($|[^-\w])/.test(mime);
}
/**

View File

@@ -1,31 +1,31 @@
{
"_args": [
[
"superagent@3.8.1",
"superagent@3.8.2",
"C:\\Users\\deranjer\\go\\src\\github.com\\deranjer\\goTorrent\\goTorrentWebUI"
]
],
"_from": "superagent@3.8.1",
"_id": "superagent@3.8.1",
"_from": "superagent@3.8.2",
"_id": "superagent@3.8.2",
"_inBundle": false,
"_integrity": "sha512-VMBFLYgFuRdfeNQSMLbxGSLfmXL/xc+OO+BZp41Za/NRDBet/BNbkRJrYzCUu0u4GU0i/ml2dtT8b9qgkw9z6Q==",
"_integrity": "sha512-gVH4QfYHcY3P0f/BZzavLreHW3T1v7hG9B+hpMQotGQqurOvhv87GcMCd6LWySmBuf+BDR44TQd0aISjVHLeNQ==",
"_location": "/superagent",
"_phantomChildren": {},
"_requested": {
"type": "version",
"registry": true,
"raw": "superagent@3.8.1",
"raw": "superagent@3.8.2",
"name": "superagent",
"escapedName": "superagent",
"rawSpec": "3.8.1",
"rawSpec": "3.8.2",
"saveSpec": null,
"fetchSpec": "3.8.1"
"fetchSpec": "3.8.2"
},
"_requiredBy": [
"/"
],
"_resolved": "https://registry.npmjs.org/superagent/-/superagent-3.8.1.tgz",
"_spec": "3.8.1",
"_resolved": "https://registry.npmjs.org/superagent/-/superagent-3.8.2.tgz",
"_spec": "3.8.2",
"_where": "C:\\Users\\deranjer\\go\\src\\github.com\\deranjer\\goTorrent\\goTorrentWebUI",
"author": {
"name": "TJ Holowaychuk",
@@ -106,5 +106,5 @@
"prepare": "make all",
"test": "make test"
},
"version": "3.8.1"
"version": "3.8.2"
}

View File

@@ -1353,7 +1353,9 @@ function parseHeader(str) {
*/
function isJSON(mime) {
return /[\/+]json\b/.test(mime);
// should match /json or +json
// but not /json-seq
return /[\/+]json($|[^-\w])/.test(mime);
}
/**

File diff suppressed because it is too large Load Diff