mirror of
https://github.com/puppeteer/puppeteer
synced 2024-06-14 14:02:48 +00:00
parent
84c2621dd4
commit
7f9e276733
@ -269,6 +269,7 @@
|
|||||||
* [response.request()](#responserequest)
|
* [response.request()](#responserequest)
|
||||||
* [response.securityDetails()](#responsesecuritydetails)
|
* [response.securityDetails()](#responsesecuritydetails)
|
||||||
* [response.status()](#responsestatus)
|
* [response.status()](#responsestatus)
|
||||||
|
* [response.statusText()](#responsestatustext)
|
||||||
* [response.text()](#responsetext)
|
* [response.text()](#responsetext)
|
||||||
* [response.url()](#responseurl)
|
* [response.url()](#responseurl)
|
||||||
- [class: SecurityDetails](#class-securitydetails)
|
- [class: SecurityDetails](#class-securitydetails)
|
||||||
@ -3089,6 +3090,11 @@ Contains a boolean stating whether the response was successful (status in the ra
|
|||||||
|
|
||||||
Contains the status code of the response (e.g., 200 for a success).
|
Contains the status code of the response (e.g., 200 for a success).
|
||||||
|
|
||||||
|
#### response.statusText()
|
||||||
|
- returns: <[string]>
|
||||||
|
|
||||||
|
Contains the status text of the response (e.g. usually an "OK" for a success).
|
||||||
|
|
||||||
#### response.text()
|
#### response.text()
|
||||||
- returns: <[Promise]<[string]>> Promise which resolves to a text representation of response body.
|
- returns: <[Promise]<[string]>> Promise which resolves to a text representation of response body.
|
||||||
|
|
||||||
|
@ -507,6 +507,7 @@ class Response {
|
|||||||
port: responsePayload.remotePort,
|
port: responsePayload.remotePort,
|
||||||
};
|
};
|
||||||
this._status = responsePayload.status;
|
this._status = responsePayload.status;
|
||||||
|
this._statusText = responsePayload.statusText;
|
||||||
this._url = request.url();
|
this._url = request.url();
|
||||||
this._fromDiskCache = !!responsePayload.fromDiskCache;
|
this._fromDiskCache = !!responsePayload.fromDiskCache;
|
||||||
this._fromServiceWorker = !!responsePayload.fromServiceWorker;
|
this._fromServiceWorker = !!responsePayload.fromServiceWorker;
|
||||||
@ -544,6 +545,13 @@ class Response {
|
|||||||
return this._status;
|
return this._status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return {string}
|
||||||
|
*/
|
||||||
|
statusText() {
|
||||||
|
return this._statusText;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return {!Object}
|
* @return {!Object}
|
||||||
*/
|
*/
|
||||||
|
@ -62,6 +62,15 @@ module.exports.addTests = function({testRunner, expect}) {
|
|||||||
expect(remoteAddress.port).toBe(server.PORT);
|
expect(remoteAddress.port).toBe(server.PORT);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('Response.statusText', async({page, server}) => {
|
||||||
|
server.setRoute('/cool', (req, res) => {
|
||||||
|
res.writeHead(200, 'cool!');
|
||||||
|
res.end();
|
||||||
|
});
|
||||||
|
const response = await page.goto(server.PREFIX + '/cool');
|
||||||
|
expect(response.statusText()).toBe('cool!');
|
||||||
|
});
|
||||||
|
|
||||||
it('Response.fromCache()', async({page, server}) => {
|
it('Response.fromCache()', async({page, server}) => {
|
||||||
const responses = new Map();
|
const responses = new Map();
|
||||||
page.on('response', r => responses.set(r.url().split('/').pop(), r));
|
page.on('response', r => responses.set(r.url().split('/').pop(), r));
|
||||||
|
Loading…
Reference in New Issue
Block a user