Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 28 additions & 7 deletions docs/src/api/class-apirequestcontext.md
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,10 @@ context cookies from the response. The method will automatically follow redirect
### option: APIRequestContext.delete.headers = %%-js-python-csharp-fetch-option-headers-%%
* since: v1.16

### option: APIRequestContext.delete.data = %%-js-python-csharp-fetch-option-data-%%
### option: APIRequestContext.delete.data = %%-js-fetch-option-data-%%
* since: v1.17

### option: APIRequestContext.delete.data = %%-python-csharp-fetch-option-data-%%
* since: v1.17

### option: APIRequestContext.delete.form = %%-js-fetch-option-form-%%
Expand Down Expand Up @@ -451,7 +454,10 @@ If set changes the fetch method (e.g. [PUT](https://developer.mozilla.org/en-US/
### option: APIRequestContext.fetch.headers = %%-js-python-csharp-fetch-option-headers-%%
* since: v1.16

### option: APIRequestContext.fetch.data = %%-js-python-csharp-fetch-option-data-%%
### option: APIRequestContext.fetch.data = %%-js-fetch-option-data-%%
* since: v1.16

### option: APIRequestContext.fetch.data = %%-python-csharp-fetch-option-data-%%
* since: v1.16

### option: APIRequestContext.fetch.form = %%-js-fetch-option-form-%%
Expand Down Expand Up @@ -566,7 +572,10 @@ await request.GetAsync("https://example.com/api/getText", new() { Params = query
### option: APIRequestContext.get.headers = %%-js-python-csharp-fetch-option-headers-%%
* since: v1.16

### option: APIRequestContext.get.data = %%-js-python-csharp-fetch-option-data-%%
### option: APIRequestContext.get.data = %%-js-fetch-option-data-%%
* since: v1.26

### option: APIRequestContext.get.data = %%-python-csharp-fetch-option-data-%%
* since: v1.26

### option: APIRequestContext.get.form = %%-js-fetch-option-form-%%
Expand Down Expand Up @@ -633,7 +642,10 @@ context cookies from the response. The method will automatically follow redirect
### option: APIRequestContext.head.headers = %%-js-python-csharp-fetch-option-headers-%%
* since: v1.16

### option: APIRequestContext.head.data = %%-js-python-csharp-fetch-option-data-%%
### option: APIRequestContext.head.data = %%-js-fetch-option-data-%%
* since: v1.26

### option: APIRequestContext.head.data = %%-python-csharp-fetch-option-data-%%
* since: v1.26

### option: APIRequestContext.head.form = %%-python-fetch-option-form-%%
Expand Down Expand Up @@ -700,7 +712,10 @@ context cookies from the response. The method will automatically follow redirect
### option: APIRequestContext.patch.headers = %%-js-python-csharp-fetch-option-headers-%%
* since: v1.16

### option: APIRequestContext.patch.data = %%-js-python-csharp-fetch-option-data-%%
### option: APIRequestContext.patch.data = %%-js-fetch-option-data-%%
* since: v1.16

### option: APIRequestContext.patch.data = %%-python-csharp-fetch-option-data-%%
* since: v1.16

### option: APIRequestContext.patch.form = %%-js-fetch-option-form-%%
Expand Down Expand Up @@ -888,7 +903,10 @@ await request.PostAsync("https://example.com/api/uploadScript", new() { Multipar
### option: APIRequestContext.post.headers = %%-js-python-csharp-fetch-option-headers-%%
* since: v1.16

### option: APIRequestContext.post.data = %%-js-python-csharp-fetch-option-data-%%
### option: APIRequestContext.post.data = %%-js-fetch-option-data-%%
* since: v1.16

### option: APIRequestContext.post.data = %%-python-csharp-fetch-option-data-%%
* since: v1.16

### option: APIRequestContext.post.form = %%-js-fetch-option-form-%%
Expand Down Expand Up @@ -955,7 +973,10 @@ context cookies from the response. The method will automatically follow redirect
### option: APIRequestContext.put.headers = %%-js-python-csharp-fetch-option-headers-%%
* since: v1.16

### option: APIRequestContext.put.data = %%-js-python-csharp-fetch-option-data-%%
### option: APIRequestContext.put.data = %%-js-fetch-option-data-%%
* since: v1.16

### option: APIRequestContext.put.data = %%-python-csharp-fetch-option-data-%%
* since: v1.16

### option: APIRequestContext.put.form = %%-python-fetch-option-form-%%
Expand Down
20 changes: 18 additions & 2 deletions docs/src/api/params.md
Original file line number Diff line number Diff line change
Expand Up @@ -579,8 +579,24 @@ unless explicitly provided. File values can be passed as file-like object contai

An instance of [FormData] can be created via [`method: APIRequestContext.createFormData`].

## js-python-csharp-fetch-option-data
* langs: js, python, csharp
## js-fetch-option-data
* langs: js
- `data` <[string]|[Buffer]|[Serializable]>

Allows to set post data of the request. If the data parameter is an object other than a [Buffer], it will be serialized to JSON
and the `content-type` header will be set to `application/json` if not explicitly set.

If the data parameter is a string and the explicitly set `content-type` is `application/json` (case-insensitive,
with optional parameters such as `charset=utf-8`), the string is sent as is if it parses as JSON.
Otherwise, it is JSON-encoded as a string, including quotes and escaping. Strings with other content types
are sent as is.

Pass a [Buffer], such as `Buffer.from(body, 'utf8')`, to send exact bytes without JSON encoding,
for example to send deliberately malformed JSON or a body used to compute a signature.
For strings and buffers, the `content-type` header defaults to `application/octet-stream` if not explicitly set.

## python-csharp-fetch-option-data
* langs: python, csharp
- `data` <[string]|[Buffer]|[Serializable]>

Allows to set post data of the request. If the data parameter is an object, it will be serialized to json string
Expand Down
2 changes: 2 additions & 0 deletions docs/src/release-notes-js.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,8 @@ export default defineConfig({

- String and `URLSearchParams` values of the `params` option in [APIRequestContext] requests are now appended to the query that the URL already has, instead of replacing it.

- [APIRequestContext] now matches `application/json` content types case-insensitively and with parameters, such as `application/json;charset=UTF-8`, when serializing string `data`. Previously, only the exact value `application/json` triggered JSON encoding. With these content types, a string that does not parse as JSON is now JSON-encoded, including quotes and escaping, instead of being sent as is. This changes malformed JSON bodies and can invalidate signatures computed over the original string. Pass `data: Buffer.from(body, 'utf8')` to send exact bytes without JSON encoding. Strings that already parse as JSON and `Buffer` data are unchanged.

- `.css`, `.less` and `.scss` imports in test files now load as empty modules instead of being removed, so the imported file must exist.

- The blob reporter again deletes the content of its output directory before it writes the report. Playwright 1.64 kept reports with other names.
Expand Down
91 changes: 70 additions & 21 deletions packages/playwright-client/types/types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19879,9 +19879,16 @@ export interface APIRequestContext {
*/
delete<T = any>(url: string, options?: {
/**
* Allows to set post data of the request. If the data parameter is an object, it will be serialized to json string
* and `content-type` header will be set to `application/json` if not explicitly set. Otherwise the `content-type`
* header will be set to `application/octet-stream` if not explicitly set.
* Allows to set post data of the request. If the data parameter is an object other than a [Buffer], it will be
* serialized to JSON and the `content-type` header will be set to `application/json` if not explicitly set.
*
* If the data parameter is a string and the explicitly set `content-type` is `application/json` (case-insensitive,
* with optional parameters such as `charset=utf-8`), the string is sent as is if it parses as JSON. Otherwise, it is
* JSON-encoded as a string, including quotes and escaping. Strings with other content types are sent as is.
*
* Pass a [Buffer], such as `Buffer.from(body, 'utf8')`, to send exact bytes without JSON encoding, for example to
* send deliberately malformed JSON or a body used to compute a signature. For strings and buffers, the `content-type`
* header defaults to `application/octet-stream` if not explicitly set.
*/
data?: string|Buffer|Serializable;

Expand Down Expand Up @@ -20021,9 +20028,16 @@ export interface APIRequestContext {
*/
fetch<T = any>(urlOrRequest: string|Request, options?: {
/**
* Allows to set post data of the request. If the data parameter is an object, it will be serialized to json string
* and `content-type` header will be set to `application/json` if not explicitly set. Otherwise the `content-type`
* header will be set to `application/octet-stream` if not explicitly set.
* Allows to set post data of the request. If the data parameter is an object other than a [Buffer], it will be
* serialized to JSON and the `content-type` header will be set to `application/json` if not explicitly set.
*
* If the data parameter is a string and the explicitly set `content-type` is `application/json` (case-insensitive,
* with optional parameters such as `charset=utf-8`), the string is sent as is if it parses as JSON. Otherwise, it is
* JSON-encoded as a string, including quotes and escaping. Strings with other content types are sent as is.
*
* Pass a [Buffer], such as `Buffer.from(body, 'utf8')`, to send exact bytes without JSON encoding, for example to
* send deliberately malformed JSON or a body used to compute a signature. For strings and buffers, the `content-type`
* header defaults to `application/octet-stream` if not explicitly set.
*/
data?: string|Buffer|Serializable;

Expand Down Expand Up @@ -20150,9 +20164,16 @@ export interface APIRequestContext {
*/
get<T = any>(url: string, options?: {
/**
* Allows to set post data of the request. If the data parameter is an object, it will be serialized to json string
* and `content-type` header will be set to `application/json` if not explicitly set. Otherwise the `content-type`
* header will be set to `application/octet-stream` if not explicitly set.
* Allows to set post data of the request. If the data parameter is an object other than a [Buffer], it will be
* serialized to JSON and the `content-type` header will be set to `application/json` if not explicitly set.
*
* If the data parameter is a string and the explicitly set `content-type` is `application/json` (case-insensitive,
* with optional parameters such as `charset=utf-8`), the string is sent as is if it parses as JSON. Otherwise, it is
* JSON-encoded as a string, including quotes and escaping. Strings with other content types are sent as is.
*
* Pass a [Buffer], such as `Buffer.from(body, 'utf8')`, to send exact bytes without JSON encoding, for example to
* send deliberately malformed JSON or a body used to compute a signature. For strings and buffers, the `content-type`
* header defaults to `application/octet-stream` if not explicitly set.
*/
data?: string|Buffer|Serializable;

Expand Down Expand Up @@ -20247,9 +20268,16 @@ export interface APIRequestContext {
*/
head<T = any>(url: string, options?: {
/**
* Allows to set post data of the request. If the data parameter is an object, it will be serialized to json string
* and `content-type` header will be set to `application/json` if not explicitly set. Otherwise the `content-type`
* header will be set to `application/octet-stream` if not explicitly set.
* Allows to set post data of the request. If the data parameter is an object other than a [Buffer], it will be
* serialized to JSON and the `content-type` header will be set to `application/json` if not explicitly set.
*
* If the data parameter is a string and the explicitly set `content-type` is `application/json` (case-insensitive,
* with optional parameters such as `charset=utf-8`), the string is sent as is if it parses as JSON. Otherwise, it is
* JSON-encoded as a string, including quotes and escaping. Strings with other content types are sent as is.
*
* Pass a [Buffer], such as `Buffer.from(body, 'utf8')`, to send exact bytes without JSON encoding, for example to
* send deliberately malformed JSON or a body used to compute a signature. For strings and buffers, the `content-type`
* header defaults to `application/octet-stream` if not explicitly set.
*/
data?: string|Buffer|Serializable;

Expand Down Expand Up @@ -20344,9 +20372,16 @@ export interface APIRequestContext {
*/
patch<T = any>(url: string, options?: {
/**
* Allows to set post data of the request. If the data parameter is an object, it will be serialized to json string
* and `content-type` header will be set to `application/json` if not explicitly set. Otherwise the `content-type`
* header will be set to `application/octet-stream` if not explicitly set.
* Allows to set post data of the request. If the data parameter is an object other than a [Buffer], it will be
* serialized to JSON and the `content-type` header will be set to `application/json` if not explicitly set.
*
* If the data parameter is a string and the explicitly set `content-type` is `application/json` (case-insensitive,
* with optional parameters such as `charset=utf-8`), the string is sent as is if it parses as JSON. Otherwise, it is
* JSON-encoded as a string, including quotes and escaping. Strings with other content types are sent as is.
*
* Pass a [Buffer], such as `Buffer.from(body, 'utf8')`, to send exact bytes without JSON encoding, for example to
* send deliberately malformed JSON or a body used to compute a signature. For strings and buffers, the `content-type`
* header defaults to `application/octet-stream` if not explicitly set.
*/
data?: string|Buffer|Serializable;

Expand Down Expand Up @@ -20483,9 +20518,16 @@ export interface APIRequestContext {
*/
post<T = any>(url: string, options?: {
/**
* Allows to set post data of the request. If the data parameter is an object, it will be serialized to json string
* and `content-type` header will be set to `application/json` if not explicitly set. Otherwise the `content-type`
* header will be set to `application/octet-stream` if not explicitly set.
* Allows to set post data of the request. If the data parameter is an object other than a [Buffer], it will be
* serialized to JSON and the `content-type` header will be set to `application/json` if not explicitly set.
*
* If the data parameter is a string and the explicitly set `content-type` is `application/json` (case-insensitive,
* with optional parameters such as `charset=utf-8`), the string is sent as is if it parses as JSON. Otherwise, it is
* JSON-encoded as a string, including quotes and escaping. Strings with other content types are sent as is.
*
* Pass a [Buffer], such as `Buffer.from(body, 'utf8')`, to send exact bytes without JSON encoding, for example to
* send deliberately malformed JSON or a body used to compute a signature. For strings and buffers, the `content-type`
* header defaults to `application/octet-stream` if not explicitly set.
*/
data?: string|Buffer|Serializable;

Expand Down Expand Up @@ -20580,9 +20622,16 @@ export interface APIRequestContext {
*/
put<T = any>(url: string, options?: {
/**
* Allows to set post data of the request. If the data parameter is an object, it will be serialized to json string
* and `content-type` header will be set to `application/json` if not explicitly set. Otherwise the `content-type`
* header will be set to `application/octet-stream` if not explicitly set.
* Allows to set post data of the request. If the data parameter is an object other than a [Buffer], it will be
* serialized to JSON and the `content-type` header will be set to `application/json` if not explicitly set.
*
* If the data parameter is a string and the explicitly set `content-type` is `application/json` (case-insensitive,
* with optional parameters such as `charset=utf-8`), the string is sent as is if it parses as JSON. Otherwise, it is
* JSON-encoded as a string, including quotes and escaping. Strings with other content types are sent as is.
*
* Pass a [Buffer], such as `Buffer.from(body, 'utf8')`, to send exact bytes without JSON encoding, for example to
* send deliberately malformed JSON or a body used to compute a signature. For strings and buffers, the `content-type`
* header defaults to `application/octet-stream` if not explicitly set.
*/
data?: string|Buffer|Serializable;

Expand Down
Loading
Loading