DefaultHttpDataSource.Factory


class DefaultHttpDataSource.Factory : HttpDataSource.Factory


DataSource.Factory for DefaultHttpDataSource instances.

Summary

Public constructors

Creates an instance.

Public functions

DefaultHttpDataSource!

Creates a DataSource instance.

DefaultHttpDataSource.Factory!

Sets whether to allow cross protocol redirects.

DefaultHttpDataSource.Factory!

Sets the connect timeout, in milliseconds.

DefaultHttpDataSource.Factory!

Sets a content type Predicate.

DefaultHttpDataSource.Factory!

Sets the default request headers for HttpDataSource instances created by the factory.

DefaultHttpDataSource.Factory!

Sets whether we should keep the POST method and body when we have HTTP 302 redirects for a POST request.

DefaultHttpDataSource.Factory!

Sets the read timeout, in milliseconds.

DefaultHttpDataSource.Factory!

Sets the TransferListener that will be used.

DefaultHttpDataSource.Factory!

Sets the user agent that will be used.

Inherited functions

From androidx.media3.datasource.DataSource.Factory
abstract DataSource!

Creates a DataSource instance.

Public constructors

Factory

Factory()

Creates an instance.

Public functions

createDataSource

@UnstableApi
fun createDataSource(): DefaultHttpDataSource!

Creates a DataSource instance.

setAllowCrossProtocolRedirects

@CanIgnoreReturnValue
@UnstableApi
fun setAllowCrossProtocolRedirects(allowCrossProtocolRedirects: Boolean): DefaultHttpDataSource.Factory!

Sets whether to allow cross protocol redirects.

The default is false.

Parameters
allowCrossProtocolRedirects: Boolean

Whether to allow cross protocol redirects.

Returns
DefaultHttpDataSource.Factory!

This factory.

setConnectTimeoutMs

@CanIgnoreReturnValue
@UnstableApi
fun setConnectTimeoutMs(connectTimeoutMs: Int): DefaultHttpDataSource.Factory!

Sets the connect timeout, in milliseconds.

The default is DEFAULT_CONNECT_TIMEOUT_MILLIS.

Parameters
connectTimeoutMs: Int

The connect timeout, in milliseconds, that will be used.

Returns
DefaultHttpDataSource.Factory!

This factory.

setContentTypePredicate

@CanIgnoreReturnValue
@UnstableApi
fun setContentTypePredicate(contentTypePredicate: Predicate<String!>?): DefaultHttpDataSource.Factory!

Sets a content type Predicate. If a content type is rejected by the predicate then a HttpDataSource.InvalidContentTypeException is thrown from open.

The default is null.

Parameters
contentTypePredicate: Predicate<String!>?

The content type Predicate, or null to clear a predicate that was previously set.

Returns
DefaultHttpDataSource.Factory!

This factory.

setDefaultRequestProperties

@CanIgnoreReturnValue
@UnstableApi
fun setDefaultRequestProperties(
    defaultRequestProperties: (Mutable)Map<String!, String!>!
): DefaultHttpDataSource.Factory!

Sets the default request headers for HttpDataSource instances created by the factory.

The new request properties will be used for future requests made by HttpDataSources created by the factory, including instances that have already been created. Modifying the defaultRequestProperties map after a call to this method will have no effect, and so it's necessary to call this method again each time the request properties need to be updated.

Parameters
defaultRequestProperties: (Mutable)Map<String!, String!>!

The default request properties.

Returns
DefaultHttpDataSource.Factory!

This factory.

setKeepPostFor302Redirects

@CanIgnoreReturnValue
@UnstableApi
fun setKeepPostFor302Redirects(keepPostFor302Redirects: Boolean): DefaultHttpDataSource.Factory!

Sets whether we should keep the POST method and body when we have HTTP 302 redirects for a POST request.

setReadTimeoutMs

@CanIgnoreReturnValue
@UnstableApi
fun setReadTimeoutMs(readTimeoutMs: Int): DefaultHttpDataSource.Factory!

Sets the read timeout, in milliseconds.

The default is DEFAULT_READ_TIMEOUT_MILLIS.

Parameters
readTimeoutMs: Int

The connect timeout, in milliseconds, that will be used.

Returns
DefaultHttpDataSource.Factory!

This factory.

setTransferListener

@CanIgnoreReturnValue
@UnstableApi
fun setTransferListener(transferListener: TransferListener?): DefaultHttpDataSource.Factory!

Sets the TransferListener that will be used.

The default is null.

See addTransferListener.

Parameters
transferListener: TransferListener?

The listener that will be used.

Returns
DefaultHttpDataSource.Factory!

This factory.

setUserAgent

@CanIgnoreReturnValue
@UnstableApi
fun setUserAgent(userAgent: String?): DefaultHttpDataSource.Factory!

Sets the user agent that will be used.

The default is null, which causes the default user agent of the underlying platform to be used.

Parameters
userAgent: String?

The user agent that will be used, or null to use the default user agent of the underlying platform.

Returns
DefaultHttpDataSource.Factory!

This factory.