# DataSpec

Artifact: [androidx.media3:media3-datasource](https://developer.android.com/jetpack/androidx/releases/media3) [View Source](https://cs.android.com/search?q=file:androidx/media3/datasource/DataSpec.java+class:androidx.media3.datasource.DataSpec)

*** ** * ** ***


```
@UnstableApi
class DataSpec
```

<br />

*** ** * ** ***

Defines a region of data in a resource.

## Summary

| ### Nested types |
|---|
| `class https://developer.android.com/reference/kotlin/androidx/media3/datasource/DataSpec.Builder` Builds `https://developer.android.com/reference/kotlin/androidx/media3/datasource/DataSpec` instances. |
| `@https://developer.android.com/reference/java/lang/annotation/Documented.html @https://developer.android.com/reference/java/lang/annotation/Retention.html(value = https://developer.android.com/reference/java/lang/annotation/RetentionPolicy.html#SOURCE) @https://developer.android.com/reference/java/lang/annotation/Target.html(value = https://developer.android.com/reference/java/lang/annotation/ElementType.html#TYPE_USE) @https://developer.android.com/reference/kotlin/androidx/annotation/IntDef(flag = true, value = ) annotation https://developer.android.com/reference/kotlin/androidx/media3/datasource/DataSpec.Flags` The flags that apply to any request for data. |
| `@https://developer.android.com/reference/java/lang/annotation/Documented.html @https://developer.android.com/reference/java/lang/annotation/Retention.html(value = https://developer.android.com/reference/java/lang/annotation/RetentionPolicy.html#SOURCE) @https://developer.android.com/reference/java/lang/annotation/Target.html(value = https://developer.android.com/reference/java/lang/annotation/ElementType.html#TYPE_USE) @https://developer.android.com/reference/kotlin/androidx/annotation/IntDef(value = ) annotation https://developer.android.com/reference/kotlin/androidx/media3/datasource/DataSpec.HttpMethod` HTTP methods supported by ExoPlayer `https://developer.android.com/reference/kotlin/androidx/media3/datasource/HttpDataSource`s. |

| ### Constants |
|---|---|
| `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/datasource/DataSpec#FLAG_ALLOW_CACHE_FRAGMENTATION() = 4` Allows fragmentation of this request into multiple cache files, meaning a cache eviction policy will be able to evict individual fragments of the data. |
| `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/datasource/DataSpec#FLAG_ALLOW_GZIP() = 1` Allows an underlying network stack to request that the server use gzip compression. |
| `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/datasource/DataSpec#FLAG_DONT_CACHE_IF_LENGTH_UNKNOWN() = 2` Prevents caching if the length cannot be resolved when the `https://developer.android.com/reference/kotlin/androidx/media3/datasource/DataSource` is opened. |
| `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/datasource/DataSpec#FLAG_MIGHT_NOT_USE_FULL_NETWORK_SPEED() = 8` Indicates there are known external factors that might prevent the data from being loaded at full network speed (e.g. server throttling or unfinished live media chunks). |
| `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/datasource/DataSpec#HTTP_METHOD_GET() = 1` HTTP GET method. |
| `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/datasource/DataSpec#HTTP_METHOD_HEAD() = 3` HTTP HEAD method. |
| `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/datasource/DataSpec#HTTP_METHOD_POST() = 2` HTTP POST method. |

| ### Public constructors |
|---|
| `https://developer.android.com/reference/kotlin/androidx/media3/datasource/DataSpec#DataSpec(android.net.Uri)(uri: https://developer.android.com/reference/android/net/Uri.html!)` Constructs an instance. |
| `https://developer.android.com/reference/kotlin/androidx/media3/datasource/DataSpec#DataSpec(android.net.Uri,long,long)(uri: https://developer.android.com/reference/android/net/Uri.html!, position: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html, length: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html)` Constructs an instance. |
| `[DataSpec](https://developer.android.com/reference/kotlin/androidx/media3/datasource/DataSpec#DataSpec(android.net.Uri,long,long,java.lang.String))(uri: https://developer.android.com/reference/android/net/Uri.html!, position: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html, length: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html, key: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html?)` **This function is deprecated.** Use `https://developer.android.com/reference/kotlin/androidx/media3/datasource/DataSpec.Builder`. <br /> |

| ### Public functions |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/media3/datasource/DataSpec.Builder!` | `https://developer.android.com/reference/kotlin/androidx/media3/datasource/DataSpec#buildUpon()()` Returns a `https://developer.android.com/reference/kotlin/androidx/media3/datasource/DataSpec.Builder` initialized with the values of this instance. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html!` | `https://developer.android.com/reference/kotlin/androidx/media3/datasource/DataSpec#getHttpMethodString()()` Returns the uppercase HTTP method name (e.g., "GET", "POST", "HEAD") corresponding to the `https://developer.android.com/reference/kotlin/androidx/media3/datasource/DataSpec#httpMethod()`. |
| `java-static https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html!` | `https://developer.android.com/reference/kotlin/androidx/media3/datasource/DataSpec#getStringForHttpMethod(int)(@https://developer.android.com/reference/kotlin/androidx/media3/datasource/DataSpec.HttpMethod httpMethod: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)` Returns an uppercase HTTP method name (e.g., "GET", "POST", "HEAD") corresponding to the given `https://developer.android.com/reference/kotlin/androidx/media3/datasource/DataSpec.HttpMethod`. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/datasource/DataSpec#isFlagSet(int)(@https://developer.android.com/reference/kotlin/androidx/media3/datasource/DataSpec.Flags flag: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)` Returns whether the given flag is set. |
| `https://developer.android.com/reference/kotlin/androidx/media3/datasource/DataSpec!` | `https://developer.android.com/reference/kotlin/androidx/media3/datasource/DataSpec#subrange(long)(offset: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html)` Returns a data spec that represents a subrange of the data defined by this DataSpec. |
| `https://developer.android.com/reference/kotlin/androidx/media3/datasource/DataSpec!` | `https://developer.android.com/reference/kotlin/androidx/media3/datasource/DataSpec#subrange(long,long)(offset: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html, length: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html)` Returns a data spec that represents a subrange of the data defined by this DataSpec. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html!` | `https://developer.android.com/reference/kotlin/androidx/media3/datasource/DataSpec#toString()()` |
| `https://developer.android.com/reference/kotlin/androidx/media3/datasource/DataSpec!` | `https://developer.android.com/reference/kotlin/androidx/media3/datasource/DataSpec#withAdditionalHeaders(java.util.Map<java.lang.String,java.lang.String>)( additionalHttpRequestHeaders: (https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-mutable-map/index.html)https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-map/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html!, https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html!>! )` Returns a copy this data spec with additional HTTP request headers. |
| `https://developer.android.com/reference/kotlin/androidx/media3/datasource/DataSpec!` | `https://developer.android.com/reference/kotlin/androidx/media3/datasource/DataSpec#withRequestHeaders(java.util.Map<java.lang.String,java.lang.String>)(httpRequestHeaders: (https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-mutable-map/index.html)https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-map/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html!, https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html!>!)` Returns a copy of this data spec with the specified HTTP request headers. |
| `https://developer.android.com/reference/kotlin/androidx/media3/datasource/DataSpec!` | `https://developer.android.com/reference/kotlin/androidx/media3/datasource/DataSpec#withUri(android.net.Uri)(uri: https://developer.android.com/reference/android/net/Uri.html!)` Returns a copy of this data spec with the specified Uri. |

| ### Public properties |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/datasource/DataSpec#absoluteStreamPosition()` **This property is deprecated.** Use `https://developer.android.com/reference/kotlin/androidx/media3/datasource/DataSpec#position()` except for specific use cases where the absolute position within the resource is required within a `https://developer.android.com/reference/kotlin/androidx/media3/datasource/DataSource` chain. <br /> |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html?` | `https://developer.android.com/reference/kotlin/androidx/media3/datasource/DataSpec#customData()` Application specific data. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `@https://developer.android.com/reference/kotlin/androidx/media3/datasource/DataSpec.Flags https://developer.android.com/reference/kotlin/androidx/media3/datasource/DataSpec#flags()` Request `https://developer.android.com/reference/kotlin/androidx/media3/datasource/DataSpec.Flags`. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-array/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-byte/index.html>?` | `https://developer.android.com/reference/kotlin/androidx/media3/datasource/DataSpec#httpBody()` The HTTP request body, null otherwise. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `@https://developer.android.com/reference/kotlin/androidx/media3/datasource/DataSpec.HttpMethod https://developer.android.com/reference/kotlin/androidx/media3/datasource/DataSpec#httpMethod()` The HTTP method to use when requesting the data. |
| `(https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-mutable-map/index.html)https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-map/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html!, https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html!>!` | `https://developer.android.com/reference/kotlin/androidx/media3/datasource/DataSpec#httpRequestHeaders()` Additional HTTP headers to use when requesting the data. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html?` | `https://developer.android.com/reference/kotlin/androidx/media3/datasource/DataSpec#key()` A key that uniquely identifies the resource. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/datasource/DataSpec#length()` The length of the data, or `https://developer.android.com/reference/kotlin/androidx/media3/common/C#LENGTH_UNSET()`. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html?` | `https://developer.android.com/reference/kotlin/androidx/media3/datasource/DataSpec#location()` A logical identifier of the location (e.g., a service location, pathway, CDN identifier etc.) from which the resource is loaded, or `null` if the location is not known or not applicable. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/datasource/DataSpec#position()` The position of the data when read from `https://developer.android.com/reference/kotlin/androidx/media3/datasource/DataSpec#uri()`. |
| `https://developer.android.com/reference/android/net/Uri.html!` | `https://developer.android.com/reference/kotlin/androidx/media3/datasource/DataSpec#uri()` A `https://developer.android.com/reference/android/net/Uri.html` from which data belonging to the resource can be read. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/datasource/DataSpec#uriPositionOffset()` The offset of the data located at `https://developer.android.com/reference/kotlin/androidx/media3/datasource/DataSpec#uri()` within the resource. |

## Constants

### FLAG_ALLOW_CACHE_FRAGMENTATION

```
const val FLAG_ALLOW_CACHE_FRAGMENTATION = 4: Int
```

Allows fragmentation of this request into multiple cache files, meaning a cache eviction policy will be able to evict individual fragments of the data. Depending on the cache implementation, setting this flag may also enable more concurrent access to the data (e.g. reading one fragment whilst writing another).

### FLAG_ALLOW_GZIP

```
const val FLAG_ALLOW_GZIP = 1: Int
```

Allows an underlying network stack to request that the server use gzip compression.

Should not typically be set if the data being requested is already compressed (e.g. most audio and video requests). May be set when requesting other data.

When a `https://developer.android.com/reference/kotlin/androidx/media3/datasource/DataSource` is used to request data with this flag set, and if the `https://developer.android.com/reference/kotlin/androidx/media3/datasource/DataSource` does make a network request, then the value returned from `https://developer.android.com/reference/kotlin/androidx/media3/datasource/DataSource#open(androidx.media3.datasource.DataSpec)` will typically be `https://developer.android.com/reference/kotlin/androidx/media3/common/C#LENGTH_UNSET()`. The data read from `https://developer.android.com/reference/kotlin/androidx/media3/common/DataReader#read(byte[],int,int)` will be the decompressed data.

### FLAG_DONT_CACHE_IF_LENGTH_UNKNOWN

```
const val FLAG_DONT_CACHE_IF_LENGTH_UNKNOWN = 2: Int
```

Prevents caching if the length cannot be resolved when the `https://developer.android.com/reference/kotlin/androidx/media3/datasource/DataSource` is opened.

### FLAG_MIGHT_NOT_USE_FULL_NETWORK_SPEED

```
const val FLAG_MIGHT_NOT_USE_FULL_NETWORK_SPEED = 8: Int
```

Indicates there are known external factors that might prevent the data from being loaded at full network speed (e.g. server throttling or unfinished live media chunks).

### HTTP_METHOD_GET

```
const val HTTP_METHOD_GET = 1: Int
```

HTTP GET method.

### HTTP_METHOD_HEAD

```
const val HTTP_METHOD_HEAD = 3: Int
```

HTTP HEAD method.

### HTTP_METHOD_POST

```
const val HTTP_METHOD_POST = 2: Int
```

HTTP POST method.

## Public constructors

### DataSpec

```
DataSpec(uri: Uri!)
```

Constructs an instance.

| Parameters |
|---|---|
| `uri: https://developer.android.com/reference/android/net/Uri.html!` | `https://developer.android.com/reference/kotlin/androidx/media3/datasource/DataSpec#uri()`. |

### DataSpec

```
DataSpec(uri: Uri!, position: Long, length: Long)
```

Constructs an instance.

| Parameters |
|---|---|
| `uri: https://developer.android.com/reference/android/net/Uri.html!` | `https://developer.android.com/reference/kotlin/androidx/media3/datasource/DataSpec#uri()`. |
| `position: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/datasource/DataSpec#position()`. |
| `length: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/datasource/DataSpec#length()`. |

### DataSpec

```
[DataSpec](https://developer.android.com/reference/kotlin/androidx/media3/datasource/DataSpec#DataSpec(android.net.Uri,long,long,java.lang.String))(uri: Uri!, position: Long, length: Long, key: String?)
```

> [!CAUTION]
> **This function is deprecated.**   
>
> Use `https://developer.android.com/reference/kotlin/androidx/media3/datasource/DataSpec.Builder`.

Constructs an instance.

| Parameters |
|---|---|
| `uri: https://developer.android.com/reference/android/net/Uri.html!` | `https://developer.android.com/reference/kotlin/androidx/media3/datasource/DataSpec#uri()`. |
| `position: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/datasource/DataSpec#position()`. |
| `length: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/datasource/DataSpec#length()`. |
| `key: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html?` | `https://developer.android.com/reference/kotlin/androidx/media3/datasource/DataSpec#key()`. |

## Public functions

### buildUpon

```
fun buildUpon(): DataSpec.Builder!
```

Returns a `https://developer.android.com/reference/kotlin/androidx/media3/datasource/DataSpec.Builder` initialized with the values of this instance.

### getHttpMethodString

```
fun getHttpMethodString(): String!
```

Returns the uppercase HTTP method name (e.g., "GET", "POST", "HEAD") corresponding to the `https://developer.android.com/reference/kotlin/androidx/media3/datasource/DataSpec#httpMethod()`.

### getStringForHttpMethod

```
java-static fun getStringForHttpMethod(@DataSpec.HttpMethod httpMethod: Int): String!
```

Returns an uppercase HTTP method name (e.g., "GET", "POST", "HEAD") corresponding to the given `https://developer.android.com/reference/kotlin/androidx/media3/datasource/DataSpec.HttpMethod`.

### isFlagSet

```
fun isFlagSet(@DataSpec.Flags flag: Int): Boolean
```

Returns whether the given flag is set.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/kotlin/androidx/media3/datasource/DataSpec.Flags flag: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | Flag to be checked if it is set. |

### subrange

```
fun subrange(offset: Long): DataSpec!
```

Returns a data spec that represents a subrange of the data defined by this DataSpec. The subrange includes data from the offset up to the end of this DataSpec.

| Parameters |
|---|---|
| `offset: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html` | The offset of the subrange. |

| Returns |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/media3/datasource/DataSpec!` | A data spec that represents a subrange of the data defined by this DataSpec. |

### subrange

```
fun subrange(offset: Long, length: Long): DataSpec!
```

Returns a data spec that represents a subrange of the data defined by this DataSpec.

| Parameters |
|---|---|
| `offset: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html` | The offset of the subrange. |
| `length: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html` | The length of the subrange. |

| Returns |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/media3/datasource/DataSpec!` | A data spec that represents a subrange of the data defined by this DataSpec. |

### toString

```
fun toString(): String!
```

### withAdditionalHeaders

```
fun withAdditionalHeaders(
    additionalHttpRequestHeaders: (Mutable)Map<String!, String!>!
): DataSpec!
```

Returns a copy this data spec with additional HTTP request headers. Headers in `
additionalHttpRequestHeaders` will overwrite any headers already in the data spec that have the same keys.

| Parameters |
|---|---|
| `additionalHttpRequestHeaders: (https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-mutable-map/index.html)https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-map/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html!, https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html!>!` | The additional HTTP request headers. |

| Returns |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/media3/datasource/DataSpec!` | The copied data spec with the additional HTTP request headers. |

### withRequestHeaders

```
fun withRequestHeaders(httpRequestHeaders: (Mutable)Map<String!, String!>!): DataSpec!
```

Returns a copy of this data spec with the specified HTTP request headers. Headers already in the data spec are not copied to the new instance.

| Parameters |
|---|---|
| `httpRequestHeaders: (https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-mutable-map/index.html)https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-map/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html!, https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html!>!` | The HTTP request headers. |

| Returns |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/media3/datasource/DataSpec!` | The copied data spec with the specified HTTP request headers. |

### withUri

```
fun withUri(uri: Uri!): DataSpec!
```

Returns a copy of this data spec with the specified Uri.

| Parameters |
|---|---|
| `uri: https://developer.android.com/reference/android/net/Uri.html!` | The new source `https://developer.android.com/reference/android/net/Uri.html`. |

| Returns |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/media3/datasource/DataSpec!` | The copied data spec with the specified Uri. |

## Public properties

### absoluteStreamPosition

```
val absoluteStreamPosition: Long
```

> [!CAUTION]
> **This property is deprecated.**   
>
> Use `https://developer.android.com/reference/kotlin/androidx/media3/datasource/DataSpec#position()` except for specific use cases where the absolute position within the resource is required within a `https://developer.android.com/reference/kotlin/androidx/media3/datasource/DataSource` chain. Where the absolute position is required, use `uriPositionOffset + position`.

The absolute position of the data in the resource.

### customData

```
val customData: Any?
```

Application specific data.

This field is intended for advanced use cases in which applications require the ability to attach custom data to `https://developer.android.com/reference/kotlin/androidx/media3/datasource/DataSpec` instances. The custom data should be immutable.

### flags

```
@DataSpec.Flags
val flags: Int
```

Request `https://developer.android.com/reference/kotlin/androidx/media3/datasource/DataSpec.Flags`.

### httpBody

```
val httpBody: Array<Byte>?
```

The HTTP request body, null otherwise. If the body is non-null, then `httpBody.length` will be non-zero.

### httpMethod

```
@DataSpec.HttpMethod
val httpMethod: Int
```

The HTTP method to use when requesting the data. This value will be ignored by non-HTTP `https://developer.android.com/reference/kotlin/androidx/media3/datasource/DataSource` implementations.

### httpRequestHeaders

```
val httpRequestHeaders: (Mutable)Map<String!, String!>!
```

Additional HTTP headers to use when requesting the data.

Note: This map is for additional headers specific to the data being requested. It does not include headers that are set directly by `https://developer.android.com/reference/kotlin/androidx/media3/datasource/HttpDataSource` implementations. In particular, this means the following headers are not included:

- `Range`: `https://developer.android.com/reference/kotlin/androidx/media3/datasource/HttpDataSource` implementations derive the `Range` header from `https://developer.android.com/reference/kotlin/androidx/media3/datasource/DataSpec#position()` and `https://developer.android.com/reference/kotlin/androidx/media3/datasource/DataSpec#length()`.
- `Accept-Encoding`: `https://developer.android.com/reference/kotlin/androidx/media3/datasource/HttpDataSource` implementations derive the `
  Accept-Encoding` header based on whether `https://developer.android.com/reference/kotlin/androidx/media3/datasource/DataSpec#flags()` includes `https://developer.android.com/reference/kotlin/androidx/media3/datasource/DataSpec#FLAG_ALLOW_GZIP()`.
- `User-Agent`: `https://developer.android.com/reference/kotlin/androidx/media3/datasource/HttpDataSource` implementations set the `User-Agent` header directly.
- Other headers set at the `https://developer.android.com/reference/kotlin/androidx/media3/datasource/HttpDataSource` layer. I.e., headers set using `https://developer.android.com/reference/kotlin/androidx/media3/datasource/HttpDataSource#setRequestProperty(java.lang.String,java.lang.String)`, and using `https://developer.android.com/reference/kotlin/androidx/media3/datasource/HttpDataSource.Factory#setDefaultRequestProperties(java.util.Map<java.lang.String,java.lang.String>)`.

### key

```
val key: String?
```

A key that uniquely identifies the resource. Used for cache indexing. May be null if the data spec is not intended to be used in conjunction with a cache.

### length

```
val length: Long
```

The length of the data, or `https://developer.android.com/reference/kotlin/androidx/media3/common/C#LENGTH_UNSET()`.

### location

```
val location: String?
```

A logical identifier of the location (e.g., a service location, pathway, CDN identifier etc.) from which the resource is loaded, or `null` if the location is not known or not applicable.

### position

```
val position: Long
```

The position of the data when read from `https://developer.android.com/reference/kotlin/androidx/media3/datasource/DataSpec#uri()`.

### uri

```
val uri: Uri!
```

A `https://developer.android.com/reference/android/net/Uri.html` from which data belonging to the resource can be read.

### uriPositionOffset

```
val uriPositionOffset: Long
```

The offset of the data located at `https://developer.android.com/reference/kotlin/androidx/media3/datasource/DataSpec#uri()` within the resource.

Equal to 0 unless `https://developer.android.com/reference/kotlin/androidx/media3/datasource/DataSpec#uri()` provides access to a subset of the resource. As an example, consider a resource that can be requested over the network and is 1000 bytes long. If `https://developer.android.com/reference/kotlin/androidx/media3/datasource/DataSpec#uri()` points to a local file that contains just bytes \[200-300\], then this field will be set to `200`.

This field can be ignored except for in specific circumstances where the absolute position in the resource is required in a `https://developer.android.com/reference/kotlin/androidx/media3/datasource/DataSource` chain. One example is when a `https://developer.android.com/reference/kotlin/androidx/media3/datasource/DataSource` needs to decrypt the content as it's read. In this case the absolute position in the resource is typically needed to correctly initialize the decryption algorithm.