Builder


abstract class Builder
kotlin.Any
   ↳ android.net.http.BidirectionalStream.Builder

Builder for BidirectionalStreams. Allows configuring stream before constructing it via Builder#build.

Summary

Public constructors

Public methods
abstract BidirectionalStream.Builder
addHeader(header: String, value: String)

Adds a request header.

abstract BidirectionalStream

Creates a BidirectionalStream using configuration from this Builder.

abstract BidirectionalStream.Builder
setDelayRequestHeadersUntilFirstFlushEnabled(delayRequestHeadersUntilFirstFlush: Boolean)

Sets whether to delay sending request headers until BidirectionalStream#flush() is called.

abstract BidirectionalStream.Builder

Sets the HTTP method for the request.

abstract BidirectionalStream.Builder
setPriority(priority: Int)

Sets priority of the stream which should be one of the STREAM_PRIORITY_* values.

abstract BidirectionalStream.Builder

Sets android.net.TrafficStats tag to use when accounting socket traffic caused by this request.

abstract BidirectionalStream.Builder

Sets specific UID to use when accounting socket traffic caused by this request.

Public constructors

Builder

Builder()

Public methods

addHeader

abstract fun addHeader(
    header: String,
    value: String
): BidirectionalStream.Builder

Adds a request header. Returns builder to facilitate chaining.

Parameters
header String: the header name This value cannot be null.
value String: the header value This value cannot be null.
Return
BidirectionalStream.Builder the builder to facilitate chaining This value cannot be null.

build

abstract fun build(): BidirectionalStream

Creates a BidirectionalStream using configuration from this Builder. The returned BidirectionalStream can then be started by calling android.net.http.BidirectionalStream#start.

Return
BidirectionalStream constructed BidirectionalStream using configuration from this Builder This value cannot be null.

setDelayRequestHeadersUntilFirstFlushEnabled

abstract fun setDelayRequestHeadersUntilFirstFlushEnabled(delayRequestHeadersUntilFirstFlush: Boolean): BidirectionalStream.Builder

Sets whether to delay sending request headers until BidirectionalStream#flush() is called. This flag is currently only respected when QUIC is negotiated. When true, QUIC will send request header frame along with data frame(s) as a single packet when possible.

Parameters
delayRequestHeadersUntilFirstFlush Boolean: if true, sending request headers will be delayed until flush() is called.
Return
BidirectionalStream.Builder the builder to facilitate chaining. This value cannot be null.

setHttpMethod

abstract fun setHttpMethod(method: String): BidirectionalStream.Builder

Sets the HTTP method for the request. Returns builder to facilitate chaining.

Parameters
method String: the method to use for request. Default is 'POST' This value cannot be null.
Return
BidirectionalStream.Builder the builder to facilitate chaining This value cannot be null.

setPriority

abstract fun setPriority(priority: Int): BidirectionalStream.Builder

Sets priority of the stream which should be one of the STREAM_PRIORITY_* values. The stream is given STREAM_PRIORITY_MEDIUM priority if this method is not called.

Parameters
priority Int: priority of the stream which should be one of the STREAM_PRIORITY_* values. Value is android.net.http.BidirectionalStream#STREAM_PRIORITY_IDLE, android.net.http.BidirectionalStream#STREAM_PRIORITY_LOWEST, android.net.http.BidirectionalStream#STREAM_PRIORITY_LOW, android.net.http.BidirectionalStream#STREAM_PRIORITY_MEDIUM, or android.net.http.BidirectionalStream#STREAM_PRIORITY_HIGHEST
Return
BidirectionalStream.Builder the builder to facilitate chaining. This value cannot be null.

setTrafficStatsTag

abstract fun setTrafficStatsTag(tag: Int): BidirectionalStream.Builder

Sets android.net.TrafficStats tag to use when accounting socket traffic caused by this request. See android.net.TrafficStats for more information. If no tag is set (e.g. this method isn't called), then Android accounts for the socket traffic caused by this request as if the tag value were set to 0.

NOTE:Setting a tag disallows sharing of sockets with requests with other tags, which may adversely effect performance by prohibiting connection sharing. In other words use of multiplexed sockets (e.g. HTTP/2 and QUIC) will only be allowed if all requests have the same socket tag.

Parameters
tag Int: the tag value used to when accounting for socket traffic caused by this request. Tags between 0xFFFFFF00 and 0xFFFFFFFF are reserved and used internally by system services like android.app.DownloadManager when performing traffic on behalf of an application.
Return
BidirectionalStream.Builder the builder to facilitate chaining. This value cannot be null.

setTrafficStatsUid

abstract fun setTrafficStatsUid(uid: Int): BidirectionalStream.Builder

Sets specific UID to use when accounting socket traffic caused by this request. See android.net.TrafficStats for more information. Designed for use when performing an operation on behalf of another application. Caller must hold android.Manifest.permission#MODIFY_NETWORK_ACCOUNTING permission. By default traffic is attributed to UID of caller.

NOTE:Setting a UID disallows sharing of sockets with requests with other UIDs, which may adversely effect performance by prohibiting connection sharing. In other words use of multiplexed sockets (e.g. HTTP/2 and QUIC) will only be allowed if all requests have the same UID set.

Parameters
uid Int: the UID to attribute socket traffic caused by this request.
Return
BidirectionalStream.Builder the builder to facilitate chaining. This value cannot be null.