# BidirectionalStream.Builder


```
abstract class BidirectionalStream.Builder
```

<br />

*** ** * ** ***

Builder for `https://developer.android.com/develop/connectivity/cronet/reference/kotlin/org/chromium/net/BidirectionalStream`s. Allows configuring stream before constructing it via `https://developer.android.com/develop/connectivity/cronet/reference/kotlin/org/chromium/net/BidirectionalStream.Builder#build()`. Created by `https://developer.android.com/develop/connectivity/cronet/reference/kotlin/org/chromium/net/CronetEngine#newBidirectionalStreamBuilder(java.lang.String,org.chromium.net.BidirectionalStream.Callback,java.util.concurrent.Executor)`.

## Summary

| ### Constants |
|---|---|
| `const https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html` | `https://developer.android.com/develop/connectivity/cronet/reference/kotlin/org/chromium/net/BidirectionalStream.Builder#STREAM_PRIORITY_HIGHEST() = 4` Highest stream priority. |
| `const https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html` | `https://developer.android.com/develop/connectivity/cronet/reference/kotlin/org/chromium/net/BidirectionalStream.Builder#STREAM_PRIORITY_IDLE() = 0` Lowest stream priority. |
| `const https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html` | `https://developer.android.com/develop/connectivity/cronet/reference/kotlin/org/chromium/net/BidirectionalStream.Builder#STREAM_PRIORITY_LOW() = 2` Low stream priority. |
| `const https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html` | `https://developer.android.com/develop/connectivity/cronet/reference/kotlin/org/chromium/net/BidirectionalStream.Builder#STREAM_PRIORITY_LOWEST() = 1` Very low stream priority. |
| `const https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html` | `https://developer.android.com/develop/connectivity/cronet/reference/kotlin/org/chromium/net/BidirectionalStream.Builder#STREAM_PRIORITY_MEDIUM() = 3` Medium stream priority. |

| ### Public constructors |
|---|
| `https://developer.android.com/develop/connectivity/cronet/reference/kotlin/org/chromium/net/BidirectionalStream.Builder#Builder()()` |

| ### Public functions |
|---|---|
| `abstract https://developer.android.com/develop/connectivity/cronet/reference/kotlin/org/chromium/net/BidirectionalStream.Builder!` | `https://developer.android.com/develop/connectivity/cronet/reference/kotlin/org/chromium/net/BidirectionalStream.Builder#addHeader(java.lang.String,java.lang.String)(header: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html!, value: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html!)` Adds a request header. |
| `https://developer.android.com/develop/connectivity/cronet/reference/kotlin/org/chromium/net/BidirectionalStream.Builder!` | `https://developer.android.com/develop/connectivity/cronet/reference/kotlin/org/chromium/net/BidirectionalStream.Builder#addRequestAnnotation(java.lang.Object)(annotation: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html!)` Associates the annotation object with this request. |
| `https://developer.android.com/develop/connectivity/cronet/reference/kotlin/org/chromium/net/BidirectionalStream.Builder!` | `https://developer.android.com/develop/connectivity/cronet/reference/kotlin/org/chromium/net/BidirectionalStream.Builder#bindToNetwork(long)(networkHandle: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-long/index.html)` Binds the request to the specified network handle. |
| `abstract https://developer.android.com/develop/connectivity/cronet/reference/kotlin/org/chromium/net/BidirectionalStream!` | `https://developer.android.com/develop/connectivity/cronet/reference/kotlin/org/chromium/net/BidirectionalStream.Builder#build()()` Creates a `https://developer.android.com/develop/connectivity/cronet/reference/kotlin/org/chromium/net/BidirectionalStream` using configuration from this `https://developer.android.com/develop/connectivity/cronet/reference/kotlin/org/chromium/net/BidirectionalStream.Builder`. |
| `abstract https://developer.android.com/develop/connectivity/cronet/reference/kotlin/org/chromium/net/BidirectionalStream.Builder!` | `https://developer.android.com/develop/connectivity/cronet/reference/kotlin/org/chromium/net/BidirectionalStream.Builder#delayRequestHeadersUntilFirstFlush(boolean)( delayRequestHeadersUntilFirstFlush: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html )` Delays sending request headers until `https://developer.android.com/develop/connectivity/cronet/reference/kotlin/org/chromium/net/BidirectionalStream#flush()` is called. |
| `abstract https://developer.android.com/develop/connectivity/cronet/reference/kotlin/org/chromium/net/BidirectionalStream.Builder!` | `https://developer.android.com/develop/connectivity/cronet/reference/kotlin/org/chromium/net/BidirectionalStream.Builder#setHttpMethod(java.lang.String)(method: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html!)` Sets the HTTP method for the request. |
| `abstract https://developer.android.com/develop/connectivity/cronet/reference/kotlin/org/chromium/net/BidirectionalStream.Builder!` | `https://developer.android.com/develop/connectivity/cronet/reference/kotlin/org/chromium/net/BidirectionalStream.Builder#setPriority(int)(priority: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)` Sets priority of the stream which should be one of the `https://developer.android.com/develop/connectivity/cronet/reference/kotlin/org/chromium/net/BidirectionalStream.Builder#STREAM_PRIORITY_IDLE()` values. |
| `https://developer.android.com/develop/connectivity/cronet/reference/kotlin/org/chromium/net/BidirectionalStream.Builder!` | `https://developer.android.com/develop/connectivity/cronet/reference/kotlin/org/chromium/net/BidirectionalStream.Builder#setTrafficStatsTag(int)(tag: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)` Sets `https://developer.android.com/reference/android/net/TrafficStats.html` tag to use when accounting socket traffic caused by this request. |
| `https://developer.android.com/develop/connectivity/cronet/reference/kotlin/org/chromium/net/BidirectionalStream.Builder!` | `https://developer.android.com/develop/connectivity/cronet/reference/kotlin/org/chromium/net/BidirectionalStream.Builder#setTrafficStatsUid(int)(uid: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)` Sets specific UID to use when accounting socket traffic caused by this request. |

## Constants

### STREAM_PRIORITY_HIGHEST

```
const val STREAM_PRIORITY_HIGHEST = 4: Int
```

Highest stream priority. Passed to `https://developer.android.com/develop/connectivity/cronet/reference/kotlin/org/chromium/net/BidirectionalStream.Builder#setPriority(int)`.

### STREAM_PRIORITY_IDLE

```
const val STREAM_PRIORITY_IDLE = 0: Int
```

Lowest stream priority. Passed to `https://developer.android.com/develop/connectivity/cronet/reference/kotlin/org/chromium/net/BidirectionalStream.Builder#setPriority(int)`.

### STREAM_PRIORITY_LOW

```
const val STREAM_PRIORITY_LOW = 2: Int
```

Low stream priority. Passed to `https://developer.android.com/develop/connectivity/cronet/reference/kotlin/org/chromium/net/BidirectionalStream.Builder#setPriority(int)`.

### STREAM_PRIORITY_LOWEST

```
const val STREAM_PRIORITY_LOWEST = 1: Int
```

Very low stream priority. Passed to `https://developer.android.com/develop/connectivity/cronet/reference/kotlin/org/chromium/net/BidirectionalStream.Builder#setPriority(int)`.

### STREAM_PRIORITY_MEDIUM

```
const val STREAM_PRIORITY_MEDIUM = 3: Int
```

Medium stream priority. Passed to `https://developer.android.com/develop/connectivity/cronet/reference/kotlin/org/chromium/net/BidirectionalStream.Builder#setPriority(int)`. This is the default priority given to the stream.

## Public constructors

### Builder

```
Builder()
```

## Public functions

### addHeader

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

Adds a request header. Returns builder to facilitate chaining.

| Parameters |
|---|---|
| `header: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html!` | the header name |
| `value: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html!` | the header value |

| Returns |
|---|---|
| `https://developer.android.com/develop/connectivity/cronet/reference/kotlin/org/chromium/net/BidirectionalStream.Builder!` | the builder to facilitate chaining |

### addRequestAnnotation

```
fun addRequestAnnotation(annotation: Any!): BidirectionalStream.Builder!
```

Associates the annotation object with this request. May add more than one. Passed through to a `https://developer.android.com/develop/connectivity/cronet/reference/kotlin/org/chromium/net/RequestFinishedInfo.Listener`, see `https://developer.android.com/develop/connectivity/cronet/reference/kotlin/org/chromium/net/RequestFinishedInfo#getAnnotations()`.

| Parameters |
|---|---|
| `annotation: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html!` | an object to pass on to the `https://developer.android.com/develop/connectivity/cronet/reference/kotlin/org/chromium/net/RequestFinishedInfo.Listener` with a `https://developer.android.com/develop/connectivity/cronet/reference/kotlin/org/chromium/net/RequestFinishedInfo`. |

| Returns |
|---|---|
| `https://developer.android.com/develop/connectivity/cronet/reference/kotlin/org/chromium/net/BidirectionalStream.Builder!` | the builder to facilitate chaining. |

### bindToNetwork

```
fun bindToNetwork(networkHandle: Long): BidirectionalStream.Builder!
```

Binds the request to the specified network handle. Cronet will send this request only using the network associated to this handle. If this network disconnects the request will fail, the exact error will depend on the stage of request processing when the network disconnects. Network handles can be obtained through `Network#getNetworkHandle`. Only available starting from Android Marshmallow.

| Parameters |
|---|---|
| `networkHandle: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-long/index.html` | the network handle to bind the request to. Specify `https://developer.android.com/develop/connectivity/cronet/reference/kotlin/org/chromium/net/CronetEngine#UNBIND_NETWORK_HANDLE()` to unbind. |

| Returns |
|---|---|
| `https://developer.android.com/develop/connectivity/cronet/reference/kotlin/org/chromium/net/BidirectionalStream.Builder!` | the builder to facilitate chaining. |

### build

```
abstract fun build(): BidirectionalStream!
```

Creates a `https://developer.android.com/develop/connectivity/cronet/reference/kotlin/org/chromium/net/BidirectionalStream` using configuration from this `https://developer.android.com/develop/connectivity/cronet/reference/kotlin/org/chromium/net/BidirectionalStream.Builder`. The returned `BidirectionalStream` can then be started by calling `https://developer.android.com/develop/connectivity/cronet/reference/kotlin/org/chromium/net/BidirectionalStream#start()`.

| Returns |
|---|---|
| `https://developer.android.com/develop/connectivity/cronet/reference/kotlin/org/chromium/net/BidirectionalStream!` | constructed `https://developer.android.com/develop/connectivity/cronet/reference/kotlin/org/chromium/net/BidirectionalStream` using configuration from this `https://developer.android.com/develop/connectivity/cronet/reference/kotlin/org/chromium/net/BidirectionalStream.Builder` |

### delayRequestHeadersUntilFirstFlush

```
abstract fun delayRequestHeadersUntilFirstFlush(
    delayRequestHeadersUntilFirstFlush: Boolean
): BidirectionalStream.Builder!
```

Delays sending request headers until `https://developer.android.com/develop/connectivity/cronet/reference/kotlin/org/chromium/net/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: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html` | if true, sending request headers will be delayed until flush() is called. |

| Returns |
|---|---|
| `https://developer.android.com/develop/connectivity/cronet/reference/kotlin/org/chromium/net/BidirectionalStream.Builder!` | the builder to facilitate chaining. |

### setHttpMethod

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

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

| Parameters |
|---|---|
| `method: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html!` | the method to use for request. Default is 'POST' |

| Returns |
|---|---|
| `https://developer.android.com/develop/connectivity/cronet/reference/kotlin/org/chromium/net/BidirectionalStream.Builder!` | the builder to facilitate chaining |

### setPriority

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

Sets priority of the stream which should be one of the `https://developer.android.com/develop/connectivity/cronet/reference/kotlin/org/chromium/net/BidirectionalStream.Builder#STREAM_PRIORITY_IDLE()` values. The stream is given `https://developer.android.com/develop/connectivity/cronet/reference/kotlin/org/chromium/net/BidirectionalStream.Builder#STREAM_PRIORITY_MEDIUM()` priority if this method is not called.

| Parameters |
|---|---|
| `priority: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html` | priority of the stream which should be one of the `https://developer.android.com/develop/connectivity/cronet/reference/kotlin/org/chromium/net/BidirectionalStream.Builder#STREAM_PRIORITY_IDLE()` values. |

| Returns |
|---|---|
| `https://developer.android.com/develop/connectivity/cronet/reference/kotlin/org/chromium/net/BidirectionalStream.Builder!` | the builder to facilitate chaining. |

### setTrafficStatsTag

```
fun setTrafficStatsTag(tag: Int): BidirectionalStream.Builder!
```

Sets `https://developer.android.com/reference/android/net/TrafficStats.html` tag to use when accounting socket traffic caused by this request. See `https://developer.android.com/reference/android/net/TrafficStats.html` 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: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html` | 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 `https://developer.android.com/reference/android/app/DownloadManager.html` when performing traffic on behalf of an application. |

| Returns |
|---|---|
| `https://developer.android.com/develop/connectivity/cronet/reference/kotlin/org/chromium/net/BidirectionalStream.Builder!` | the builder to facilitate chaining. |

### setTrafficStatsUid

```
fun setTrafficStatsUid(uid: Int): BidirectionalStream.Builder!
```

Sets specific UID to use when accounting socket traffic caused by this request. See `https://developer.android.com/reference/android/net/TrafficStats.html` for more information. Designed for use when performing an operation on behalf of another application. Caller must hold `
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: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html` | the UID to attribute socket traffic caused by this request. |

| Returns |
|---|---|
| `https://developer.android.com/develop/connectivity/cronet/reference/kotlin/org/chromium/net/BidirectionalStream.Builder!` | the builder to facilitate chaining. |