public static abstract class

UrlRequest.Builder

extends Object
java.lang.Object
   ↳ com.tencent.smtt.export.external.interfaces.UrlRequest.Builder
Known Direct Subclasses

Class Overview

Builder for UrlRequests. Allows configuring requests before constructing them with build().

Summary

Constants
int REQUEST_PRIORITY_HIGHEST Highest request priority.
int REQUEST_PRIORITY_IDLE Lowest request priority.
int REQUEST_PRIORITY_LOW Low request priority.
int REQUEST_PRIORITY_LOWEST Very low request priority.
int REQUEST_PRIORITY_MEDIUM Medium request priority.
Public Constructors
Builder()
Public Methods
abstract UrlRequest.Builder addHeader(String header, String value)
Adds a request header.
abstract UrlRequest build()
Creates a UrlRequest using configuration within this UrlRequest.Builder.
abstract UrlRequest.Builder disableCache()
Disables cache for the request.
abstract UrlRequest.Builder setDns(String host, String address)
set dns
abstract UrlRequest.Builder setHttpMethod(String method)
Sets the HTTP method verb to use for this request.
abstract UrlRequest.Builder setPriority(int priority)
Sets priority of the request which should be one of the REQUEST_PRIORITY_* values.
abstract UrlRequest.Builder setRequestBody(String body)
set requeset body
abstract UrlRequest.Builder setRequestBodyBytes(byte[] body)
set requeset body
[Expand]
Inherited Methods
From class java.lang.Object

Constants

public static final int REQUEST_PRIORITY_HIGHEST

Highest request priority. Passed to setPriority(int).

Constant Value: 4 (0x00000004)

public static final int REQUEST_PRIORITY_IDLE

Lowest request priority. Passed to setPriority(int).

Constant Value: 0 (0x00000000)

public static final int REQUEST_PRIORITY_LOW

Low request priority. Passed to setPriority(int).

Constant Value: 2 (0x00000002)

public static final int REQUEST_PRIORITY_LOWEST

Very low request priority. Passed to setPriority(int).

Constant Value: 1 (0x00000001)

public static final int REQUEST_PRIORITY_MEDIUM

Medium request priority. Passed to setPriority(int). This is the default priority given to the request.

Constant Value: 3 (0x00000003)

Public Constructors

public Builder ()

Public Methods

public abstract UrlRequest.Builder addHeader (String header, String value)

Adds a request header.

Parameters
header header name.
value header value.
Returns
  • the builder to facilitate chaining.

public abstract UrlRequest build ()

Creates a UrlRequest using configuration within this UrlRequest.Builder. The returned UrlRequest can then be started by calling start().

Returns

public abstract UrlRequest.Builder disableCache ()

Disables cache for the request. If context is not set up to use cache, this call has no effect.

Returns
  • the builder to facilitate chaining.

public abstract UrlRequest.Builder setDns (String host, String address)

set dns

Parameters
host host
address address

public abstract UrlRequest.Builder setHttpMethod (String method)

Sets the HTTP method verb to use for this request.

The default when this method is not called is "GET" if the request has no body or "POST" if it does.

Parameters
method "GET", "HEAD", "DELETE", "POST" or "PUT".
Returns
  • the builder to facilitate chaining.

public abstract UrlRequest.Builder setPriority (int priority)

Sets priority of the request which should be one of the REQUEST_PRIORITY_* values. The request is given REQUEST_PRIORITY_MEDIUM priority if this method is not called.

Parameters
priority priority of the request which should be one of the REQUEST_PRIORITY_* values.
Returns
  • the builder to facilitate chaining.

public abstract UrlRequest.Builder setRequestBody (String body)

set requeset body

Parameters
body string

public abstract UrlRequest.Builder setRequestBodyBytes (byte[] body)

set requeset body

Parameters
body byte[]