Added in [API level 34](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  
Also in [S Extensions 7](https://developer.android.com/sdkExtensions) Summary: [Ctors](https://developer.android.com/reference/android/net/http/BidirectionalStream.Builder#pubctors) \| [Methods](https://developer.android.com/reference/android/net/http/BidirectionalStream.Builder#pubmethods) \| [Inherited Methods](https://developer.android.com/reference/android/net/http/BidirectionalStream.Builder#inhmethods)

# BidirectionalStream.Builder

*** ** * ** ***

` public static abstract class BidirectionalStream.Builder `   
` extends https://developer.android.com/reference/java/lang/Object ` ` `

|---|---|
| [java.lang.Object](https://developer.android.com/reference/java/lang/Object) ||
| ↳ | android.net.http.BidirectionalStream.Builder |

<br />

*** ** * ** ***

Builder for `https://developer.android.com/reference/android/net/http/BidirectionalStream`s. Allows configuring stream before constructing it via `https://developer.android.com/reference/android/net/http/BidirectionalStream.Builder#build()`.

## Summary

| ### Public constructors ||
|---|---|
| ` https://developer.android.com/reference/android/net/http/BidirectionalStream.Builder#Builder()() ` |

| ### Public methods ||
|---|---|
| ` abstract https://developer.android.com/reference/android/net/http/BidirectionalStream.Builder` | ` https://developer.android.com/reference/android/net/http/BidirectionalStream.Builder#addHeader(java.lang.String,%20java.lang.String)(https://developer.android.com/reference/java/lang/String header, https://developer.android.com/reference/java/lang/String value) ` Adds a request header. |
| ` abstract https://developer.android.com/reference/android/net/http/BidirectionalStream` | ` https://developer.android.com/reference/android/net/http/BidirectionalStream.Builder#build()() ` Creates a `https://developer.android.com/reference/android/net/http/BidirectionalStream` using configuration from this `https://developer.android.com/reference/android/net/http/BidirectionalStream.Builder`. |
| ` abstract https://developer.android.com/reference/android/net/http/BidirectionalStream.Builder` | ` https://developer.android.com/reference/android/net/http/BidirectionalStream.Builder#setDelayRequestHeadersUntilFirstFlushEnabled(boolean)(boolean delayRequestHeadersUntilFirstFlush) ` Sets whether to delay sending request headers until `https://developer.android.com/reference/android/net/http/BidirectionalStream#flush()` is called. |
| ` abstract https://developer.android.com/reference/android/net/http/BidirectionalStream.Builder` | ` https://developer.android.com/reference/android/net/http/BidirectionalStream.Builder#setHttpMethod(java.lang.String)(https://developer.android.com/reference/java/lang/String method) ` Sets the HTTP method for the request. |
| ` abstract https://developer.android.com/reference/android/net/http/BidirectionalStream.Builder` | ` https://developer.android.com/reference/android/net/http/BidirectionalStream.Builder#setPriority(int)(int priority) ` Sets priority of the stream which should be one of the `https://developer.android.com/reference/android/net/http/BidirectionalStream#STREAM_PRIORITY_IDLE` values. |
| ` abstract https://developer.android.com/reference/android/net/http/BidirectionalStream.Builder` | ` https://developer.android.com/reference/android/net/http/BidirectionalStream.Builder#setTrafficStatsTag(int)(int tag) ` Sets `https://developer.android.com/reference/android/net/TrafficStats` tag to use when accounting socket traffic caused by this request. |
| ` abstract https://developer.android.com/reference/android/net/http/BidirectionalStream.Builder` | ` https://developer.android.com/reference/android/net/http/BidirectionalStream.Builder#setTrafficStatsUid(int)(int uid) ` Sets specific UID to use when accounting socket traffic caused by this request. |

### Inherited methods

From class ` https://developer.android.com/reference/java/lang/Object ` ` https://developer.android.com/reference/java/lang/Object` ` https://developer.android.com/reference/java/lang/Object#clone()() `

Creates and returns a copy of this object.
` boolean` ` https://developer.android.com/reference/java/lang/Object#equals(java.lang.Object)(https://developer.android.com/reference/java/lang/Object obj) `

Indicates whether some other object is "equal to" this one.
` void` ` https://developer.android.com/reference/java/lang/Object#finalize()() `

Called by the garbage collector on an object when garbage collection determines that there are no more references to the object.
` final https://developer.android.com/reference/java/lang/Class<?>` ` https://developer.android.com/reference/java/lang/Object#getClass()() `

Returns the runtime class of this `Object`.
` int` ` https://developer.android.com/reference/java/lang/Object#hashCode()() `

Returns a hash code value for the object.
` final void` ` https://developer.android.com/reference/java/lang/Object#notify()() `

Wakes up a single thread that is waiting on this object's monitor.
` final void` ` https://developer.android.com/reference/java/lang/Object#notifyAll()() `

Wakes up all threads that are waiting on this object's monitor.
` https://developer.android.com/reference/java/lang/String` ` https://developer.android.com/reference/java/lang/Object#toString()() `

Returns a string representation of the object.
` final void` ` https://developer.android.com/reference/java/lang/Object#wait(long,%20int)(long timeoutMillis, int nanos) `

Causes the current thread to wait until it is awakened, typically by being *notified* or *interrupted*, or until a certain amount of real time has elapsed.
` final void` ` https://developer.android.com/reference/java/lang/Object#wait(long)(long timeoutMillis) `

Causes the current thread to wait until it is awakened, typically by being *notified* or *interrupted*, or until a certain amount of real time has elapsed.
` final void` ` https://developer.android.com/reference/java/lang/Object#wait()() `

Causes the current thread to wait until it is awakened, typically by being *notified* or *interrupted*.

## Public constructors

### Builder

Added in [API level 34](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  
Also in [S Extensions 7](https://developer.android.com/sdkExtensions)

```
public Builder ()
```

<br />

<br />

## Public methods

### addHeader

Added in [API level 34](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  
Also in [S Extensions 7](https://developer.android.com/sdkExtensions)

```
public abstract BidirectionalStream.Builder addHeader (String header, 
                String value)
```

Adds a request header. Returns builder to facilitate chaining.

<br />

| Parameters ||
|---|---|
| `header` | `String`: the header name. This value cannot be `null`. <br /> |
| `value` | `String`: the header value. This value cannot be `null`. <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/net/http/BidirectionalStream.Builder` | the builder to facilitate chaining. This value cannot be `null`. <br /> |

### build

Added in [API level 34](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  
Also in [S Extensions 7](https://developer.android.com/sdkExtensions)

```
public abstract BidirectionalStream build ()
```

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

<br />

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/net/http/BidirectionalStream` | constructed `https://developer.android.com/reference/android/net/http/BidirectionalStream` using configuration from this `https://developer.android.com/reference/android/net/http/BidirectionalStream.Builder` This value cannot be `null`. <br /> |

### setDelayRequestHeadersUntilFirstFlushEnabled

Added in [API level 34](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  
Also in [S Extensions 7](https://developer.android.com/sdkExtensions)

```
public abstract BidirectionalStream.Builder setDelayRequestHeadersUntilFirstFlushEnabled (boolean delayRequestHeadersUntilFirstFlush)
```

Sets whether to delay sending request headers until `https://developer.android.com/reference/android/net/http/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.

<br />

| Parameters ||
|---|---|
| `delayRequestHeadersUntilFirstFlush` | `boolean`: if true, sending request headers will be delayed until flush() is called. <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/net/http/BidirectionalStream.Builder` | the builder to facilitate chaining. This value cannot be `null`. <br /> |

### setHttpMethod

Added in [API level 34](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  
Also in [S Extensions 7](https://developer.android.com/sdkExtensions)

```
public abstract BidirectionalStream.Builder setHttpMethod (String method)
```

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

<br />

| Parameters ||
|---|---|
| `method` | `String`: the method to use for request. Default is 'POST'. This value cannot be `null`. <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/net/http/BidirectionalStream.Builder` | the builder to facilitate chaining. This value cannot be `null`. <br /> |

### setPriority

Added in [API level 34](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  
Also in [S Extensions 7](https://developer.android.com/sdkExtensions)

```
public abstract BidirectionalStream.Builder setPriority (int priority)
```

Sets priority of the stream which should be one of the `https://developer.android.com/reference/android/net/http/BidirectionalStream#STREAM_PRIORITY_IDLE` values. The stream is given `https://developer.android.com/reference/android/net/http/BidirectionalStream#STREAM_PRIORITY_MEDIUM` priority if this method is not called.

<br />

| Parameters ||
|---|---|
| `priority` | `int`: priority of the stream which should be one of the `https://developer.android.com/reference/android/net/http/BidirectionalStream#STREAM_PRIORITY_IDLE` values. Value is one of the following: - `https://developer.android.com/reference/android/net/http/BidirectionalStream#STREAM_PRIORITY_IDLE` - `https://developer.android.com/reference/android/net/http/BidirectionalStream#STREAM_PRIORITY_LOWEST` - `https://developer.android.com/reference/android/net/http/BidirectionalStream#STREAM_PRIORITY_LOW` - `https://developer.android.com/reference/android/net/http/BidirectionalStream#STREAM_PRIORITY_MEDIUM` - `https://developer.android.com/reference/android/net/http/BidirectionalStream#STREAM_PRIORITY_HIGHEST` |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/net/http/BidirectionalStream.Builder` | the builder to facilitate chaining. This value cannot be `null`. <br /> |

### setTrafficStatsTag

Added in [API level 34](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  
Also in [S Extensions 7](https://developer.android.com/sdkExtensions)

```
public abstract BidirectionalStream.Builder setTrafficStatsTag (int tag)
```

Sets `https://developer.android.com/reference/android/net/TrafficStats` tag to use when accounting socket traffic caused by this request. See `https://developer.android.com/reference/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.

<br />

| 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 `https://developer.android.com/reference/android/app/DownloadManager` when performing traffic on behalf of an application. <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/net/http/BidirectionalStream.Builder` | the builder to facilitate chaining. This value cannot be `null`. <br /> |

### setTrafficStatsUid

Added in [API level 34](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  
Also in [S Extensions 7](https://developer.android.com/sdkExtensions)

```
public abstract BidirectionalStream.Builder setTrafficStatsUid (int uid)
```

Sets specific UID to use when accounting socket traffic caused by this request. See `https://developer.android.com/reference/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.

<br />

| Parameters ||
|---|---|
| `uid` | `int`: the UID to attribute socket traffic caused by this request. <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/net/http/BidirectionalStream.Builder` | the builder to facilitate chaining. This value cannot be `null`. <br /> |