目录

Request.Builder

Class Info

public abstract static class Request.Builder

Builder for the Request object. Use the newRequest method of HttpClient to create a Request.Builder object.

Public Constructor Summary

Constructor Name

public Request.Builder()

Default constructor.

Public Method Summary

Qualifier and Type

Method Name and Description

public abstract Request.Builder

addHeader(String name, String value)

Adds a message header.

public abstract Request

build()

Builds a Request object.

public abstract Request.Builder

method(String method)

Sets the request method.

public abstract Request.Builder

options(String options)

Sets the Request object built by Request.Builder.

public abstract Request.Builder

removeHeader(String name)

Removes a message header specified by name from the request.

public abstract Request.Builder

requestBody(RequestBody requestBody)

Sets the request body.

public abstract Request.Builder

url(String url)

Sets the request URL.

Public Constructors

[h2]Request.Builder

Constructor

public Request.Builder()

Default constructor for building a Request.Builder object.

Public Methods

[h2]addHeader

Method

public abstract Request.Builder addHeader(String name, String value)

Adds a message header.

Parameters

Name

Description

name

Message header name.

value

Message header value.

Returns

Type

Description

Request.Builder

Builder for the Request object.

[h2]build

Method

public abstract Request build()

Builds a Request object.

Returns

Type

Description

Request

Request object.

[h2]method

Method

public abstract Request.Builder method(String method)

Sets the request method. Several request methods specified for HTTP are supported, such as GET, POST, PUT, and DELETE.

Parameters

Name

Description

method

Request method.

Returns

Type

Description

Request.Builder

Builder for the Request object.

[h2]options

Method

public abstract Request.Builder options(String options)

Sets the Request object built by Request.Builder.

Parameters

Name

Description

options

Parameters in JSON format, for example, {"call_timeout":10000,"connect_empty_body":true}. For details about supported parameters, please refer to options.

options

Description

call_timeout

Request timeout interval, in milliseconds. The value is of the int type. The default value is 0, indicating that the request never times out. The value must be greater than or equal to 20.

concurrent_connect_delay

Timeout interval of concurrent connection setup, in milliseconds. The value is of the int type. The default value is 500.
  • If the value of connect_timeout is less than or equal to 2000, the value of concurrent_connect_delay must range from 100 to the value of connect_timeout.
  • If the value of connect_timeout is greater than 2000, the value of concurrent_connect_delay must range from 100 to 2000.

connect_empty_body

Indicates whether to set up a connection and transmit data. The value is of the boolean type. The default value is false.
  • true: Only set up a connection, without transmitting data.
  • false: Set up a connection and transmit data.

connect_timeout

Connection timeout interval, in milliseconds. The value is of the int type. The default value is 10000.
  • If the value of concurrent_connect_delay is less than or equal to 1000, the value of connect_timeout must be greater than or equal to 1000.
  • If the value of concurrent_connect_delay is greater than 1000, the value of connect_timeout must be greater than that of concurrent_connect_delay.

enable_concurrent_connect

Indicates whether to enable concurrent connection setup. The value is of the boolean type. The default value is true.
  • true: yes
  • false: no

ping_interval

Interval at which ping frame detection is performed, in milliseconds. The value is of the int type. The default value is 0, indicating that ping frame detection does not take effect. The value must be greater than 0.

read_timeout

Read timeout interval, in milliseconds. The value is of the int type. The default value is 10000. The value must be greater than 0.

retry_time

Number of request retries. A retry will be triggered upon an I/O exception. The value is of the int type. The default value is 1, indicating that one retry is supported upon a failure. The value must be greater than or equal to 0.

write_timeout

Write timeout interval, in milliseconds. The value is of the int type. The default value is 10000. The value must be greater than 0.

Returns

Type

Description

Request.Builder

Builder for the Request object.

[h2]removeHeader

Method

public abstract Request.Builder removeHeader(String name)

Removes a message header specified by name from the request.

Parameters

Name

Description

name

Message header name.

Returns

Type

Description

Request.Builder

Builder for the Request object.

[h2]requestBody

Method

public abstract Request.Builder requestBody(RequestBody requestBody)

Sets the request body.

Parameters

Name

Description

requestBody

Request body.

Returns

Type

Description

Request.Builder

Builder for the Request object.

[h2]url

Method

public abstract Request.Builder url(String url)

Sets the request URL.

Parameters

Name

Description

url

Request URL.

Returns

Type

Description

Request.Builder

Builder for the Request object.