Remove redundant methods from Body class
This patch: - removes Body.arrayBuffer. This method is redundant since there's already a Body.buffer() method - removes Body.bodyUsed getter. References #106
This commit is contained in:
parent
847504c53e
commit
c26d2c8271
11
docs/api.md
11
docs/api.md
@ -112,8 +112,6 @@
|
|||||||
+ [interceptedRequest.postData](#interceptedrequestpostdata)
|
+ [interceptedRequest.postData](#interceptedrequestpostdata)
|
||||||
+ [interceptedRequest.url](#interceptedrequesturl)
|
+ [interceptedRequest.url](#interceptedrequesturl)
|
||||||
* [class: Body](#class-body)
|
* [class: Body](#class-body)
|
||||||
+ [body.arrayBuffer()](#bodyarraybuffer)
|
|
||||||
+ [body.bodyUsed](#bodybodyused)
|
|
||||||
+ [body.buffer()](#bodybuffer)
|
+ [body.buffer()](#bodybuffer)
|
||||||
+ [body.json()](#bodyjson)
|
+ [body.json()](#bodyjson)
|
||||||
+ [body.text()](#bodytext)
|
+ [body.text()](#bodytext)
|
||||||
@ -1031,12 +1029,6 @@ Contains `POST` data for `POST` requests.
|
|||||||
If changed, the request url will be modified in a way that's not observable by page. Must not be changed in response to an authChallenge.
|
If changed, the request url will be modified in a way that's not observable by page. Must not be changed in response to an authChallenge.
|
||||||
|
|
||||||
### class: Body
|
### class: Body
|
||||||
#### body.arrayBuffer()
|
|
||||||
- returns: <Promise<[ArrayBuffer]>>
|
|
||||||
|
|
||||||
|
|
||||||
#### body.bodyUsed
|
|
||||||
- returns: <[boolean]>
|
|
||||||
|
|
||||||
#### body.buffer()
|
#### body.buffer()
|
||||||
- returns: <Promise<[Buffer]>>
|
- returns: <Promise<[Buffer]>>
|
||||||
@ -1048,7 +1040,6 @@ If changed, the request url will be modified in a way that's not observable by p
|
|||||||
- returns: <Promise<[text]>>
|
- returns: <Promise<[text]>>
|
||||||
|
|
||||||
[Array]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array "Array"
|
[Array]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array "Array"
|
||||||
[ArrayBuffer]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer "ArrayBuffer"
|
|
||||||
[boolean]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Boolean_type "Boolean"
|
[boolean]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Boolean_type "Boolean"
|
||||||
[Buffer]: https://nodejs.org/api/buffer.html#buffer_class_buffer "Buffer"
|
[Buffer]: https://nodejs.org/api/buffer.html#buffer_class_buffer "Buffer"
|
||||||
[function]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function "Function"
|
[function]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function "Function"
|
||||||
@ -1070,4 +1061,4 @@ If changed, the request url will be modified in a way that's not observable by p
|
|||||||
[Dialog]: https://github.com/GoogleChrome/puppeteer/blob/master/docs/api.md#class-dialog "Dialog"
|
[Dialog]: https://github.com/GoogleChrome/puppeteer/blob/master/docs/api.md#class-dialog "Dialog"
|
||||||
[Mouse]: https://github.com/GoogleChrome/puppeteer/blob/master/docs/api.md#class-mouse "Mouse"
|
[Mouse]: https://github.com/GoogleChrome/puppeteer/blob/master/docs/api.md#class-mouse "Mouse"
|
||||||
[Map]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map "Map"
|
[Map]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map "Map"
|
||||||
[selector]: https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Selectors "selector"
|
[selector]: https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Selectors "selector"
|
||||||
|
@ -156,13 +156,6 @@ class Body {
|
|||||||
return this._contentPromise;
|
return this._contentPromise;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @return {boolean}
|
|
||||||
*/
|
|
||||||
get bodyUsed() {
|
|
||||||
return !!this._contentPromise;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return {!Promise<string>}
|
* @return {!Promise<string>}
|
||||||
*/
|
*/
|
||||||
@ -178,14 +171,6 @@ class Body {
|
|||||||
let content = await this.text();
|
let content = await this.text();
|
||||||
return JSON.parse(content);
|
return JSON.parse(content);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @return {!Promise<!ArrayBuffer>}
|
|
||||||
*/
|
|
||||||
async arrayBuffer() {
|
|
||||||
let content = await this.buffer();
|
|
||||||
return content.buffer;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
helper.tracePublicAPI(Body);
|
helper.tracePublicAPI(Body);
|
||||||
|
|
||||||
|
@ -1071,10 +1071,8 @@ describe('Puppeteer', function() {
|
|||||||
page.on('request', r => request = r);
|
page.on('request', r => request = r);
|
||||||
await page.evaluate(() => fetch('./post', { method: 'POST', body: JSON.stringify({foo: 'bar'})}));
|
await page.evaluate(() => fetch('./post', { method: 'POST', body: JSON.stringify({foo: 'bar'})}));
|
||||||
expect(request).toBeTruthy();
|
expect(request).toBeTruthy();
|
||||||
expect(request.bodyUsed).toBe(false);
|
|
||||||
expect(await request.text()).toBe('{"foo":"bar"}');
|
expect(await request.text()).toBe('{"foo":"bar"}');
|
||||||
expect(await request.json()).toEqual({foo: 'bar'});
|
expect(await request.json()).toEqual({foo: 'bar'});
|
||||||
expect(request.bodyUsed).toBe(true);
|
|
||||||
}));
|
}));
|
||||||
});
|
});
|
||||||
describe('Response implements Body', function() {
|
describe('Response implements Body', function() {
|
||||||
@ -1083,10 +1081,8 @@ describe('Puppeteer', function() {
|
|||||||
page.on('response', r => response = r);
|
page.on('response', r => response = r);
|
||||||
await page.navigate(PREFIX + '/simple.json');
|
await page.navigate(PREFIX + '/simple.json');
|
||||||
expect(response).toBeTruthy();
|
expect(response).toBeTruthy();
|
||||||
expect(response.bodyUsed).toBe(false);
|
|
||||||
expect(await response.text()).toBe('{"foo": "bar"}\n');
|
expect(await response.text()).toBe('{"foo": "bar"}\n');
|
||||||
expect(await response.json()).toEqual({foo: 'bar'});
|
expect(await response.json()).toEqual({foo: 'bar'});
|
||||||
expect(response.bodyUsed).toBe(true);
|
|
||||||
}));
|
}));
|
||||||
});
|
});
|
||||||
describe('Network Events', function() {
|
describe('Network Events', function() {
|
||||||
|
Loading…
Reference in New Issue
Block a user