chore: rename rawHeaders to allHeaders (#8659)
This commit is contained in:
parent
f9312061bf
commit
94170dacbd
|
|
@ -1,6 +1,6 @@
|
||||||
# class: Headers
|
# class: Headers
|
||||||
|
|
||||||
HTTP request and response raw headers collection.
|
HTTP request and response all headers collection.
|
||||||
|
|
||||||
## method: Headers.get
|
## method: Headers.get
|
||||||
- returns: <[string|null]>
|
- returns: <[string|null]>
|
||||||
|
|
|
||||||
|
|
@ -16,6 +16,11 @@ with `'requestfinished'` event.
|
||||||
If request gets a 'redirect' response, the request is successfully finished with the 'requestfinished' event, and a new
|
If request gets a 'redirect' response, the request is successfully finished with the 'requestfinished' event, and a new
|
||||||
request is issued to a redirected url.
|
request is issued to a redirected url.
|
||||||
|
|
||||||
|
## async method: Request.allHeaders
|
||||||
|
- returns: <[Headers]>
|
||||||
|
|
||||||
|
An object with all the request HTTP headers associated with this request.
|
||||||
|
|
||||||
## method: Request.failure
|
## method: Request.failure
|
||||||
- returns: <[null]|[string]>
|
- returns: <[null]|[string]>
|
||||||
|
|
||||||
|
|
@ -54,7 +59,7 @@ Returns the [Frame] that initiated this request.
|
||||||
## method: Request.headers
|
## method: Request.headers
|
||||||
- returns: <[Object]<[string], [string]>>
|
- returns: <[Object]<[string], [string]>>
|
||||||
|
|
||||||
**DEPRECATED** Use [`method: Request.rawHeaders`] instead.
|
**DEPRECATED** Incomplete list of headers as seen by the rendering engine. Use [`method: Request.allHeaders`] instead.
|
||||||
|
|
||||||
## method: Request.isNavigationRequest
|
## method: Request.isNavigationRequest
|
||||||
- returns: <[boolean]>
|
- returns: <[boolean]>
|
||||||
|
|
@ -85,11 +90,6 @@ Returns parsed request's body for `form-urlencoded` and JSON as a fallback if an
|
||||||
When the response is `application/x-www-form-urlencoded` then a key/value object of the values will be returned.
|
When the response is `application/x-www-form-urlencoded` then a key/value object of the values will be returned.
|
||||||
Otherwise it will be parsed as JSON.
|
Otherwise it will be parsed as JSON.
|
||||||
|
|
||||||
## async method: Request.rawHeaders
|
|
||||||
- returns: <[Headers]>
|
|
||||||
|
|
||||||
An object with the raw request HTTP headers associated with the request. All headers are as seen in the network stack.
|
|
||||||
|
|
||||||
## method: Request.redirectedFrom
|
## method: Request.redirectedFrom
|
||||||
- returns: <[null]|[Request]>
|
- returns: <[null]|[Request]>
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,11 @@
|
||||||
|
|
||||||
[Response] class represents responses which are received by page.
|
[Response] class represents responses which are received by page.
|
||||||
|
|
||||||
|
## async method: Response.allHeaders
|
||||||
|
- returns: <[Headers]>
|
||||||
|
|
||||||
|
An object with all the response HTTP headers associated with this response.
|
||||||
|
|
||||||
## async method: Response.body
|
## async method: Response.body
|
||||||
- returns: <[Buffer]>
|
- returns: <[Buffer]>
|
||||||
|
|
||||||
|
|
@ -20,7 +25,7 @@ Returns the [Frame] that initiated this response.
|
||||||
## method: Response.headers
|
## method: Response.headers
|
||||||
- returns: <[Object]<[string], [string]>>
|
- returns: <[Object]<[string], [string]>>
|
||||||
|
|
||||||
**DEPRECATED** Use [`method: Response.rawHeaders`] instead.
|
**DEPRECATED** Incomplete list of headers as seen by the rendering engine. Use [`method: Response.allHeaders`] instead.
|
||||||
|
|
||||||
## async method: Response.json
|
## async method: Response.json
|
||||||
* langs: js, python
|
* langs: js, python
|
||||||
|
|
@ -43,11 +48,6 @@ This method will throw if the response body is not parsable via `JSON.parse`.
|
||||||
|
|
||||||
Contains a boolean stating whether the response was successful (status in the range 200-299) or not.
|
Contains a boolean stating whether the response was successful (status in the range 200-299) or not.
|
||||||
|
|
||||||
## async method: Response.rawHeaders
|
|
||||||
- returns: <[Headers]>
|
|
||||||
|
|
||||||
An object with the raw response HTTP headers associated with the request. All headers are as seen in the network stack.
|
|
||||||
|
|
||||||
## method: Response.request
|
## method: Response.request
|
||||||
- returns: <[Request]>
|
- returns: <[Request]>
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -139,7 +139,7 @@ export class Request extends ChannelOwner<channels.RequestChannel, channels.Requ
|
||||||
return { ...this._headers };
|
return { ...this._headers };
|
||||||
}
|
}
|
||||||
|
|
||||||
async rawHeaders(): Promise<RawHeaders> {
|
async allHeaders(): Promise<RawHeaders> {
|
||||||
if (this._rawHeadersPromise)
|
if (this._rawHeadersPromise)
|
||||||
return this._rawHeadersPromise;
|
return this._rawHeadersPromise;
|
||||||
this._rawHeadersPromise = this.response().then(response => {
|
this._rawHeadersPromise = this.response().then(response => {
|
||||||
|
|
@ -254,7 +254,7 @@ export class InterceptedResponse implements api.Response {
|
||||||
return { ...this._headers };
|
return { ...this._headers };
|
||||||
}
|
}
|
||||||
|
|
||||||
async rawHeaders(): Promise<RawHeaders> {
|
async allHeaders(): Promise<RawHeaders> {
|
||||||
return this._rawHeaders;
|
return this._rawHeaders;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -454,7 +454,7 @@ export class Response extends ChannelOwner<channels.ResponseChannel, channels.Re
|
||||||
return { ...this._headers };
|
return { ...this._headers };
|
||||||
}
|
}
|
||||||
|
|
||||||
async rawHeaders(): Promise<RawHeaders> {
|
async allHeaders(): Promise<RawHeaders> {
|
||||||
if (this._rawHeadersPromise)
|
if (this._rawHeadersPromise)
|
||||||
return this._rawHeadersPromise;
|
return this._rawHeadersPromise;
|
||||||
this._rawHeadersPromise = this._wrapApiCall(async (channel: channels.ResponseChannel) => {
|
this._rawHeadersPromise = this._wrapApiCall(async (channel: channels.ResponseChannel) => {
|
||||||
|
|
|
||||||
|
|
@ -89,7 +89,7 @@ it('should get the same headers as the server', async ({ page, server, browserNa
|
||||||
response.end('done');
|
response.end('done');
|
||||||
});
|
});
|
||||||
const response = await page.goto(server.PREFIX + '/empty.html');
|
const response = await page.goto(server.PREFIX + '/empty.html');
|
||||||
const headers = await response.request().rawHeaders();
|
const headers = await response.request().allHeaders();
|
||||||
const result = {};
|
const result = {};
|
||||||
for (const header of headers.headers())
|
for (const header of headers.headers())
|
||||||
result[header.name.toLowerCase()] = header.value;
|
result[header.name.toLowerCase()] = header.value;
|
||||||
|
|
@ -113,7 +113,7 @@ it('should get the same headers as the server CORS', async ({page, server, brows
|
||||||
}, server.CROSS_PROCESS_PREFIX + '/something');
|
}, server.CROSS_PROCESS_PREFIX + '/something');
|
||||||
expect(text).toBe('done');
|
expect(text).toBe('done');
|
||||||
const response = await responsePromise;
|
const response = await responsePromise;
|
||||||
const headers = await response.request().rawHeaders();
|
const headers = await response.request().allHeaders();
|
||||||
const result = {};
|
const result = {};
|
||||||
for (const header of headers.headers())
|
for (const header of headers.headers())
|
||||||
result[header.name.toLowerCase()] = header.value;
|
result[header.name.toLowerCase()] = header.value;
|
||||||
|
|
@ -275,12 +275,12 @@ it('should return navigation bit when navigating to image', async ({page, server
|
||||||
|
|
||||||
it('should report raw headers', async ({ page, server, browserName }) => {
|
it('should report raw headers', async ({ page, server, browserName }) => {
|
||||||
const response = await page.goto(server.EMPTY_PAGE);
|
const response = await page.goto(server.EMPTY_PAGE);
|
||||||
const requestHeaders = await response.request().rawHeaders();
|
const requestHeaders = await response.request().allHeaders();
|
||||||
expect(requestHeaders.headerNames().map(h => h.toLowerCase())).toContain('accept');
|
expect(requestHeaders.headerNames().map(h => h.toLowerCase())).toContain('accept');
|
||||||
expect(requestHeaders.getAll('host')).toHaveLength(1);
|
expect(requestHeaders.getAll('host')).toHaveLength(1);
|
||||||
expect(requestHeaders.get('host')).toBe(`localhost:${server.PORT}`);
|
expect(requestHeaders.get('host')).toBe(`localhost:${server.PORT}`);
|
||||||
|
|
||||||
const responseHeaders = await response.rawHeaders();
|
const responseHeaders = await response.allHeaders();
|
||||||
expect(responseHeaders.headerNames().map(h => h.toLowerCase())).toContain('content-type');
|
expect(responseHeaders.headerNames().map(h => h.toLowerCase())).toContain('content-type');
|
||||||
expect(responseHeaders.getAll('content-type')).toHaveLength(1);
|
expect(responseHeaders.getAll('content-type')).toHaveLength(1);
|
||||||
expect(responseHeaders.get('content-type')).toBe('text/html; charset=utf-8');
|
expect(responseHeaders.get('content-type')).toBe('text/html; charset=utf-8');
|
||||||
|
|
@ -303,7 +303,7 @@ it('should report raw response headers in redirects', async ({ page, server, bro
|
||||||
for (let req = response.request(); req; req = req.redirectedFrom()) {
|
for (let req = response.request(); req; req = req.redirectedFrom()) {
|
||||||
redirectChain.unshift(req.url());
|
redirectChain.unshift(req.url());
|
||||||
const res = await req.response();
|
const res = await req.response();
|
||||||
const headers = await res.rawHeaders();
|
const headers = await res.allHeaders();
|
||||||
headersChain.unshift(headers.get('sec-test-header'));
|
headersChain.unshift(headers.get('sec-test-header'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
29
types/types.d.ts
vendored
29
types/types.d.ts
vendored
|
|
@ -12662,7 +12662,7 @@ export interface FileChooser {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* HTTP request and response raw headers collection.
|
* HTTP request and response all headers collection.
|
||||||
*/
|
*/
|
||||||
export interface Headers {
|
export interface Headers {
|
||||||
/**
|
/**
|
||||||
|
|
@ -13017,6 +13017,11 @@ export interface Mouse {
|
||||||
* request is issued to a redirected url.
|
* request is issued to a redirected url.
|
||||||
*/
|
*/
|
||||||
export interface Request {
|
export interface Request {
|
||||||
|
/**
|
||||||
|
* An object with all the request HTTP headers associated with this request.
|
||||||
|
*/
|
||||||
|
allHeaders(): Promise<Headers>;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The method returns `null` unless this request has failed, as reported by `requestfailed` event.
|
* The method returns `null` unless this request has failed, as reported by `requestfailed` event.
|
||||||
*
|
*
|
||||||
|
|
@ -13042,7 +13047,8 @@ export interface Request {
|
||||||
frame(): Frame;
|
frame(): Frame;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* **DEPRECATED** Use [request.rawHeaders()](https://playwright.dev/docs/api/class-request#request-raw-headers) instead.
|
* **DEPRECATED** Incomplete list of headers as seen by the rendering engine. Use
|
||||||
|
* [request.allHeaders()](https://playwright.dev/docs/api/class-request#request-all-headers) instead.
|
||||||
* @deprecated
|
* @deprecated
|
||||||
*/
|
*/
|
||||||
headers(): { [key: string]: string; };
|
headers(): { [key: string]: string; };
|
||||||
|
|
@ -13075,11 +13081,6 @@ export interface Request {
|
||||||
*/
|
*/
|
||||||
postDataJSON(): null|any;
|
postDataJSON(): null|any;
|
||||||
|
|
||||||
/**
|
|
||||||
* An object with the raw request HTTP headers associated with the request. All headers are as seen in the network stack.
|
|
||||||
*/
|
|
||||||
rawHeaders(): Promise<Headers>;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Request that was redirected by the server to this one, if any.
|
* Request that was redirected by the server to this one, if any.
|
||||||
*
|
*
|
||||||
|
|
@ -13239,6 +13240,11 @@ export interface Request {
|
||||||
* [Response] class represents responses which are received by page.
|
* [Response] class represents responses which are received by page.
|
||||||
*/
|
*/
|
||||||
export interface Response {
|
export interface Response {
|
||||||
|
/**
|
||||||
|
* An object with all the response HTTP headers associated with this response.
|
||||||
|
*/
|
||||||
|
allHeaders(): Promise<Headers>;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the buffer with response body.
|
* Returns the buffer with response body.
|
||||||
*/
|
*/
|
||||||
|
|
@ -13255,8 +13261,8 @@ export interface Response {
|
||||||
frame(): Frame;
|
frame(): Frame;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* **DEPRECATED** Use [response.rawHeaders()](https://playwright.dev/docs/api/class-response#response-raw-headers)
|
* **DEPRECATED** Incomplete list of headers as seen by the rendering engine. Use
|
||||||
* instead.
|
* [response.allHeaders()](https://playwright.dev/docs/api/class-response#response-all-headers) instead.
|
||||||
* @deprecated
|
* @deprecated
|
||||||
*/
|
*/
|
||||||
headers(): { [key: string]: string; };
|
headers(): { [key: string]: string; };
|
||||||
|
|
@ -13273,11 +13279,6 @@ export interface Response {
|
||||||
*/
|
*/
|
||||||
ok(): boolean;
|
ok(): boolean;
|
||||||
|
|
||||||
/**
|
|
||||||
* An object with the raw response HTTP headers associated with the request. All headers are as seen in the network stack.
|
|
||||||
*/
|
|
||||||
rawHeaders(): Promise<Headers>;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the matching [Request] object.
|
* Returns the matching [Request] object.
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue