docs(api): redo request API for java (#10449)
This commit is contained in:
parent
103b6121b8
commit
9fed8a9344
|
|
@ -14,15 +14,15 @@ The method will populate request cookies from the context and update
|
|||
context cookies from the response. The method will automatically follow redirects.
|
||||
|
||||
### param: APIRequestContext.delete.url = %%-fetch-param-url-%%
|
||||
### option: APIRequestContext.delete.params = %%-fetch-option-params-%%
|
||||
### option: APIRequestContext.delete.headers = %%-fetch-option-headers-%%
|
||||
### option: APIRequestContext.delete.data = %%-fetch-option-data-%%
|
||||
### option: APIRequestContext.delete.form = %%-fetch-option-form-%%
|
||||
### param: APIRequestContext.delete.params = %%-java-fetch-params-%%
|
||||
### option: APIRequestContext.delete.params = %%-js-python-fetch-option-params-%%
|
||||
### option: APIRequestContext.delete.headers = %%-js-python-fetch-option-headers-%%
|
||||
### option: APIRequestContext.delete.data = %%-js-python-fetch-option-data-%%
|
||||
### option: APIRequestContext.delete.form = %%-js-python-fetch-option-form-%%
|
||||
### option: APIRequestContext.delete.multipart = %%-js-pyhton-fetch-option-multipart-%%
|
||||
### option: APIRequestContext.delete.multipart = %%-java-fetch-option-multipart-%%
|
||||
### option: APIRequestContext.delete.timeout = %%-fetch-option-timeout-%%
|
||||
### option: APIRequestContext.delete.failOnStatusCode = %%-fetch-option-failonstatuscode-%%
|
||||
### option: APIRequestContext.delete.ignoreHTTPSErrors = %%-context-option-ignorehttpserrors-%%
|
||||
### option: APIRequestContext.delete.timeout = %%-js-python-fetch-option-timeout-%%
|
||||
### option: APIRequestContext.delete.failOnStatusCode = %%-js-python-fetch-option-failonstatuscode-%%
|
||||
### option: APIRequestContext.delete.ignoreHTTPSErrors = %%-js-python-fetch-option-ignorehttpserrors-%%
|
||||
|
||||
## async method: APIRequestContext.dispose
|
||||
|
||||
|
|
@ -40,22 +40,23 @@ context cookies from the response. The method will automatically follow redirect
|
|||
|
||||
Target URL or Request to get all parameters from.
|
||||
|
||||
### option: APIRequestContext.fetch.params = %%-fetch-option-params-%%
|
||||
### param: APIRequestContext.fetch.params = %%-java-fetch-params-%%
|
||||
### option: APIRequestContext.fetch.params = %%-js-python-fetch-option-params-%%
|
||||
|
||||
### option: APIRequestContext.fetch.method
|
||||
* langs: js, python
|
||||
- `method` <[string]>
|
||||
|
||||
If set changes the fetch method (e.g. [PUT](https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods/PUT) or
|
||||
[POST](https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods/POST)). If not specified, GET method is used.
|
||||
|
||||
### option: APIRequestContext.fetch.headers = %%-fetch-option-headers-%%
|
||||
### option: APIRequestContext.fetch.data = %%-fetch-option-data-%%
|
||||
### option: APIRequestContext.fetch.form = %%-fetch-option-form-%%
|
||||
### option: APIRequestContext.fetch.headers = %%-js-python-fetch-option-headers-%%
|
||||
### option: APIRequestContext.fetch.data = %%-js-python-fetch-option-data-%%
|
||||
### option: APIRequestContext.fetch.form = %%-js-python-fetch-option-form-%%
|
||||
### option: APIRequestContext.fetch.multipart = %%-js-pyhton-fetch-option-multipart-%%
|
||||
### option: APIRequestContext.fetch.multipart = %%-java-fetch-option-multipart-%%
|
||||
### option: APIRequestContext.fetch.timeout = %%-fetch-option-timeout-%%
|
||||
### option: APIRequestContext.fetch.failOnStatusCode = %%-fetch-option-failonstatuscode-%%
|
||||
### option: APIRequestContext.fetch.ignoreHTTPSErrors = %%-context-option-ignorehttpserrors-%%
|
||||
### option: APIRequestContext.fetch.timeout = %%-js-python-fetch-option-timeout-%%
|
||||
### option: APIRequestContext.fetch.failOnStatusCode = %%-js-python-fetch-option-failonstatuscode-%%
|
||||
### option: APIRequestContext.fetch.ignoreHTTPSErrors = %%-js-python-fetch-option-ignorehttpserrors-%%
|
||||
|
||||
## async method: APIRequestContext.get
|
||||
- returns: <[APIResponse]>
|
||||
|
|
@ -65,11 +66,12 @@ The method will populate request cookies from the context and update
|
|||
context cookies from the response. The method will automatically follow redirects.
|
||||
|
||||
### param: APIRequestContext.get.url = %%-fetch-param-url-%%
|
||||
### option: APIRequestContext.get.params = %%-fetch-option-params-%%
|
||||
### option: APIRequestContext.get.headers = %%-fetch-option-headers-%%
|
||||
### option: APIRequestContext.get.timeout = %%-fetch-option-timeout-%%
|
||||
### option: APIRequestContext.get.failOnStatusCode = %%-fetch-option-failonstatuscode-%%
|
||||
### option: APIRequestContext.get.ignoreHTTPSErrors = %%-context-option-ignorehttpserrors-%%
|
||||
### param: APIRequestContext.get.params = %%-java-fetch-params-%%
|
||||
### option: APIRequestContext.get.params = %%-js-python-fetch-option-params-%%
|
||||
### option: APIRequestContext.get.headers = %%-js-python-fetch-option-headers-%%
|
||||
### option: APIRequestContext.get.timeout = %%-js-python-fetch-option-timeout-%%
|
||||
### option: APIRequestContext.get.failOnStatusCode = %%-js-python-fetch-option-failonstatuscode-%%
|
||||
### option: APIRequestContext.get.ignoreHTTPSErrors = %%-js-python-fetch-option-ignorehttpserrors-%%
|
||||
|
||||
## async method: APIRequestContext.head
|
||||
- returns: <[APIResponse]>
|
||||
|
|
@ -79,11 +81,12 @@ The method will populate request cookies from the context and update
|
|||
context cookies from the response. The method will automatically follow redirects.
|
||||
|
||||
### param: APIRequestContext.head.url = %%-fetch-param-url-%%
|
||||
### option: APIRequestContext.head.params = %%-fetch-option-params-%%
|
||||
### option: APIRequestContext.head.headers = %%-fetch-option-headers-%%
|
||||
### option: APIRequestContext.head.timeout = %%-fetch-option-timeout-%%
|
||||
### option: APIRequestContext.head.failOnStatusCode = %%-fetch-option-failonstatuscode-%%
|
||||
### option: APIRequestContext.head.ignoreHTTPSErrors = %%-context-option-ignorehttpserrors-%%
|
||||
### param: APIRequestContext.head.params = %%-java-fetch-params-%%
|
||||
### option: APIRequestContext.head.params = %%-js-python-fetch-option-params-%%
|
||||
### option: APIRequestContext.head.headers = %%-js-python-fetch-option-headers-%%
|
||||
### option: APIRequestContext.head.timeout = %%-js-python-fetch-option-timeout-%%
|
||||
### option: APIRequestContext.head.failOnStatusCode = %%-js-python-fetch-option-failonstatuscode-%%
|
||||
### option: APIRequestContext.head.ignoreHTTPSErrors = %%-js-python-fetch-option-ignorehttpserrors-%%
|
||||
|
||||
## async method: APIRequestContext.patch
|
||||
- returns: <[APIResponse]>
|
||||
|
|
@ -93,15 +96,15 @@ The method will populate request cookies from the context and update
|
|||
context cookies from the response. The method will automatically follow redirects.
|
||||
|
||||
### param: APIRequestContext.patch.url = %%-fetch-param-url-%%
|
||||
### option: APIRequestContext.patch.params = %%-fetch-option-params-%%
|
||||
### option: APIRequestContext.patch.headers = %%-fetch-option-headers-%%
|
||||
### option: APIRequestContext.patch.data = %%-fetch-option-data-%%
|
||||
### option: APIRequestContext.patch.form = %%-fetch-option-form-%%
|
||||
### param: APIRequestContext.patch.params = %%-java-fetch-params-%%
|
||||
### option: APIRequestContext.patch.params = %%-js-python-fetch-option-params-%%
|
||||
### option: APIRequestContext.patch.headers = %%-js-python-fetch-option-headers-%%
|
||||
### option: APIRequestContext.patch.data = %%-js-python-fetch-option-data-%%
|
||||
### option: APIRequestContext.patch.form = %%-js-python-fetch-option-form-%%
|
||||
### option: APIRequestContext.patch.multipart = %%-js-pyhton-fetch-option-multipart-%%
|
||||
### option: APIRequestContext.patch.multipart = %%-java-fetch-option-multipart-%%
|
||||
### option: APIRequestContext.patch.timeout = %%-fetch-option-timeout-%%
|
||||
### option: APIRequestContext.patch.failOnStatusCode = %%-fetch-option-failonstatuscode-%%
|
||||
### option: APIRequestContext.patch.ignoreHTTPSErrors = %%-context-option-ignorehttpserrors-%%
|
||||
### option: APIRequestContext.patch.timeout = %%-js-python-fetch-option-timeout-%%
|
||||
### option: APIRequestContext.patch.failOnStatusCode = %%-js-python-fetch-option-failonstatuscode-%%
|
||||
### option: APIRequestContext.patch.ignoreHTTPSErrors = %%-js-python-fetch-option-ignorehttpserrors-%%
|
||||
|
||||
## async method: APIRequestContext.post
|
||||
- returns: <[APIResponse]>
|
||||
|
|
@ -111,15 +114,15 @@ The method will populate request cookies from the context and update
|
|||
context cookies from the response. The method will automatically follow redirects.
|
||||
|
||||
### param: APIRequestContext.post.url = %%-fetch-param-url-%%
|
||||
### option: APIRequestContext.post.params = %%-fetch-option-params-%%
|
||||
### option: APIRequestContext.post.headers = %%-fetch-option-headers-%%
|
||||
### option: APIRequestContext.post.data = %%-fetch-option-data-%%
|
||||
### option: APIRequestContext.post.form = %%-fetch-option-form-%%
|
||||
### param: APIRequestContext.post.params = %%-java-fetch-params-%%
|
||||
### option: APIRequestContext.post.params = %%-js-python-fetch-option-params-%%
|
||||
### option: APIRequestContext.post.headers = %%-js-python-fetch-option-headers-%%
|
||||
### option: APIRequestContext.post.data = %%-js-python-fetch-option-data-%%
|
||||
### option: APIRequestContext.post.form = %%-js-python-fetch-option-form-%%
|
||||
### option: APIRequestContext.post.multipart = %%-js-pyhton-fetch-option-multipart-%%
|
||||
### option: APIRequestContext.post.multipart = %%-java-fetch-option-multipart-%%
|
||||
### option: APIRequestContext.post.timeout = %%-fetch-option-timeout-%%
|
||||
### option: APIRequestContext.post.failOnStatusCode = %%-fetch-option-failonstatuscode-%%
|
||||
### option: APIRequestContext.post.ignoreHTTPSErrors = %%-context-option-ignorehttpserrors-%%
|
||||
### option: APIRequestContext.post.timeout = %%-js-python-fetch-option-timeout-%%
|
||||
### option: APIRequestContext.post.failOnStatusCode = %%-js-python-fetch-option-failonstatuscode-%%
|
||||
### option: APIRequestContext.post.ignoreHTTPSErrors = %%-js-python-fetch-option-ignorehttpserrors-%%
|
||||
|
||||
## async method: APIRequestContext.put
|
||||
- returns: <[APIResponse]>
|
||||
|
|
@ -129,15 +132,15 @@ The method will populate request cookies from the context and update
|
|||
context cookies from the response. The method will automatically follow redirects.
|
||||
|
||||
### param: APIRequestContext.put.url = %%-fetch-param-url-%%
|
||||
### option: APIRequestContext.put.params = %%-fetch-option-params-%%
|
||||
### option: APIRequestContext.put.headers = %%-fetch-option-headers-%%
|
||||
### option: APIRequestContext.put.data = %%-fetch-option-data-%%
|
||||
### option: APIRequestContext.put.form = %%-fetch-option-form-%%
|
||||
### param: APIRequestContext.put.params = %%-java-fetch-params-%%
|
||||
### option: APIRequestContext.put.params = %%-js-python-fetch-option-params-%%
|
||||
### option: APIRequestContext.put.headers = %%-js-python-fetch-option-headers-%%
|
||||
### option: APIRequestContext.put.data = %%-js-python-fetch-option-data-%%
|
||||
### option: APIRequestContext.put.form = %%-js-python-fetch-option-form-%%
|
||||
### option: APIRequestContext.put.multipart = %%-js-pyhton-fetch-option-multipart-%%
|
||||
### option: APIRequestContext.put.multipart = %%-java-fetch-option-multipart-%%
|
||||
### option: APIRequestContext.put.timeout = %%-fetch-option-timeout-%%
|
||||
### option: APIRequestContext.put.failOnStatusCode = %%-fetch-option-failonstatuscode-%%
|
||||
### option: APIRequestContext.put.ignoreHTTPSErrors = %%-context-option-ignorehttpserrors-%%
|
||||
### option: APIRequestContext.put.timeout = %%-js-python-fetch-option-timeout-%%
|
||||
### option: APIRequestContext.put.failOnStatusCode = %%-js-python-fetch-option-failonstatuscode-%%
|
||||
### option: APIRequestContext.put.ignoreHTTPSErrors = %%-js-python-fetch-option-ignorehttpserrors-%%
|
||||
|
||||
## async method: APIRequestContext.storageState
|
||||
- returns: <[Object]>
|
||||
|
|
|
|||
37
docs/src/api/class-formdata.md
Normal file
37
docs/src/api/class-formdata.md
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
# class: FormData
|
||||
* langs: java
|
||||
|
||||
The [FormData] is used create form data that is sent via [APIRequestContext].
|
||||
|
||||
```java
|
||||
import com.microsoft.playwright.options.FormData;
|
||||
...
|
||||
FormData form = FormData.create()
|
||||
.set("firstName", "John")
|
||||
.set("lastName", "Doe")
|
||||
.set("age", 30);
|
||||
page.request().post("http://localhost/submit", RequestOptions.create().setForm(form));
|
||||
```
|
||||
|
||||
## method: FormData.create
|
||||
- returns: <[FormData]>
|
||||
|
||||
Creates new instance of [FormData].
|
||||
|
||||
## method: FormData.set
|
||||
- returns: <[FormData]>
|
||||
|
||||
Sets a field on the form. File values can be passed either as `Path` or as `FilePayload`.
|
||||
|
||||
### param: FormData.set.name
|
||||
- `name` <[string]>
|
||||
|
||||
Field name.
|
||||
|
||||
### param: FormData.set.value
|
||||
- `name` <[string]|[boolean]|[int]|[Path]|[Object]>
|
||||
- `name` <[string]> File name
|
||||
- `mimeType` <[string]> File type
|
||||
- `buffer` <[Buffer]> File content
|
||||
|
||||
Field value.
|
||||
123
docs/src/api/class-requestoptions.md
Normal file
123
docs/src/api/class-requestoptions.md
Normal file
|
|
@ -0,0 +1,123 @@
|
|||
# class: RequestOptions
|
||||
* langs: java
|
||||
|
||||
The [RequestOptions] allows to create form data to be sent via [APIRequestContext].
|
||||
|
||||
```java
|
||||
context.request().post(
|
||||
"https://example.com/submit",
|
||||
RequestOptions.create()
|
||||
.setQueryParam("page", 1)
|
||||
.setData("My data"));
|
||||
```
|
||||
|
||||
## method: RequestOptions.create
|
||||
- returns: <[RequestOptions]>
|
||||
|
||||
Creates new instance of [RequestOptions].
|
||||
|
||||
## method: RequestOptions.setData
|
||||
- returns: <[RequestOptions]>
|
||||
|
||||
Sets the request's post data.
|
||||
|
||||
### param: RequestOptions.setData.data
|
||||
- `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
|
||||
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.
|
||||
|
||||
## method: RequestOptions.setFailOnStatusCode
|
||||
- returns: <[RequestOptions]>
|
||||
|
||||
### param: RequestOptions.setFailOnStatusCode.failOnStatusCode
|
||||
- `failOnStatusCode` <[boolean]>
|
||||
|
||||
Whether to throw on response codes other than 2xx and 3xx. By default response object is returned
|
||||
for all status codes.
|
||||
|
||||
## method: RequestOptions.setForm
|
||||
- returns: <[RequestOptions]>
|
||||
|
||||
Provides [FormData] object that will be serialized as html form using `application/x-www-form-urlencoded` encoding and sent as
|
||||
this request body. If this parameter is specified `content-type` header will be set to `application/x-www-form-urlencoded`
|
||||
unless explicitly provided.
|
||||
|
||||
### param: RequestOptions.setForm.form
|
||||
- `form` <[FormData]>
|
||||
|
||||
Form data to be serialized as html form using `application/x-www-form-urlencoded` encoding and sent as
|
||||
this request body.
|
||||
|
||||
## method: RequestOptions.setHeader
|
||||
- returns: <[RequestOptions]>
|
||||
|
||||
Sets an HTTP header to the request.
|
||||
|
||||
### param: RequestOptions.setHeader.name
|
||||
- `name` <[string]>
|
||||
|
||||
Header name.
|
||||
|
||||
### param: RequestOptions.setHeader.value
|
||||
- `value` <[string]>
|
||||
|
||||
Header value.
|
||||
|
||||
## method: RequestOptions.setIgnoreHTTPSErrors
|
||||
- returns: <[RequestOptions]>
|
||||
|
||||
### param: RequestOptions.setIgnoreHTTPSErrors.ignoreHTTPSErrors
|
||||
- `ignoreHTTPSErrors` <[boolean]>
|
||||
|
||||
Whether to ignore HTTPS errors when sending network requests.
|
||||
|
||||
## method: RequestOptions.setMethod
|
||||
- returns: <[RequestOptions]>
|
||||
|
||||
Changes the request method (e.g. [PUT](https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods/PUT) or
|
||||
[POST](https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods/POST)).
|
||||
|
||||
### param: RequestOptions.setMethod.method
|
||||
- `method` <[string]>
|
||||
|
||||
Request method, e.g. [POST](https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods/POST).
|
||||
|
||||
## method: RequestOptions.setMultipart
|
||||
- returns: <[RequestOptions]>
|
||||
|
||||
Provides [FormData] object that will be serialized as html form using `multipart/form-data` encoding and sent as
|
||||
this request body. If this parameter is specified `content-type` header will be set to `multipart/form-data`
|
||||
unless explicitly provided.
|
||||
|
||||
### param: RequestOptions.setMultipart.form
|
||||
- `form` <[FormData]>
|
||||
|
||||
Form data to be serialized as html form using `multipart/form-data` encoding and sent as
|
||||
this request body.
|
||||
|
||||
## method: RequestOptions.setQueryParam
|
||||
- returns: <[RequestOptions]>
|
||||
|
||||
Adds a query parameter to the request URL.
|
||||
|
||||
### param: RequestOptions.setQueryParam.name
|
||||
- `name` <[string]>
|
||||
|
||||
Parameter name.
|
||||
|
||||
### param: RequestOptions.setQueryParam.value
|
||||
- `value` <[string]|[boolean]|[int]>
|
||||
|
||||
Parameter value.
|
||||
|
||||
## method: RequestOptions.setTimeout
|
||||
- returns: <[RequestOptions]>
|
||||
|
||||
Sets request timeout in milliseconds. Defaults to `30000` (30 seconds). Pass `0` to disable timeout.
|
||||
|
||||
### param: RequestOptions.setTimeout.timeout
|
||||
- `timeout` <[float]>
|
||||
|
||||
Request timeout in milliseconds.
|
||||
|
|
@ -303,28 +303,39 @@ Emulates consistent window screen size available inside web page via `window.scr
|
|||
|
||||
Target URL.
|
||||
|
||||
## fetch-option-params
|
||||
## js-python-fetch-option-params
|
||||
* langs: js, python
|
||||
- `params` <[Object]<[string], [string]|[float]|[boolean]>>
|
||||
|
||||
Query parameters to be sent with the URL.
|
||||
|
||||
## fetch-option-headers
|
||||
## java-fetch-params
|
||||
* langs: java
|
||||
- `options` <[RequestOptions]>
|
||||
|
||||
Optional request parameters.
|
||||
|
||||
## js-python-fetch-option-headers
|
||||
* langs: js, python
|
||||
- `headers` <[Object]<[string], [string]>>
|
||||
|
||||
Allows to set HTTP headers.
|
||||
|
||||
## fetch-option-timeout
|
||||
## js-python-fetch-option-timeout
|
||||
* langs: js, python
|
||||
- `timeout` <[float]>
|
||||
|
||||
Request timeout in milliseconds. Defaults to `30000` (30 seconds). Pass `0` to disable timeout.
|
||||
|
||||
## fetch-option-failonstatuscode
|
||||
## js-python-fetch-option-failonstatuscode
|
||||
* langs: js, python
|
||||
- `failOnStatusCode` <[boolean]>
|
||||
|
||||
Whether to throw on response codes other than 2xx and 3xx. By default response object is returned
|
||||
for all status codes.
|
||||
|
||||
## fetch-option-form
|
||||
## js-python-fetch-option-form
|
||||
* langs: js, python
|
||||
- `form` <[Object]<[string], [string]|[float]|[boolean]>>
|
||||
|
||||
Provides an object that will be serialized as html form using `application/x-www-form-urlencoded` encoding and sent as
|
||||
|
|
@ -343,22 +354,19 @@ this request body. If this parameter is specified `content-type` header will be
|
|||
unless explicitly provided. File values can be passed either as [`fs.ReadStream`](https://nodejs.org/api/fs.html#fs_class_fs_readstream)
|
||||
or as file-like object containing file name, mime-type and its content.
|
||||
|
||||
## java-fetch-option-multipart
|
||||
* langs: java
|
||||
- `multipart` <[Object]<[string], [any]>>
|
||||
|
||||
Provides an object that will be serialized as html form using `multipart/form-data` encoding and sent as
|
||||
this request body. If this parameter is specified `content-type` header will be set to `multipart/form-data`
|
||||
unless explicitly provided. File values can be passed either as [File] or as file-like object [FilePayload]
|
||||
containing file name, mime-type and its content.
|
||||
|
||||
## fetch-option-data
|
||||
## js-python-fetch-option-data
|
||||
* langs: js, python
|
||||
- `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
|
||||
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.
|
||||
|
||||
## js-python-fetch-option-ignorehttpserrors
|
||||
* langs: js, python
|
||||
- `ignoreHTTPSErrors` <[boolean]>
|
||||
|
||||
Whether to ignore HTTPS errors when sending network requests. Defaults to `false`.
|
||||
|
||||
## evaluate-expression
|
||||
- `expression` <[string]>
|
||||
|
|
|
|||
Loading…
Reference in a new issue