HttpEngineDataSource.Factory


class HttpEngineDataSource.Factory : HttpDataSource.Factory


DataSource.Factory for HttpEngineDataSource instances.

Summary

Public constructors

Factory(httpEngine: HttpEngine!, executor: Executor!)

Creates an instance.

Public functions

HttpDataSource!

Creates a DataSource instance.

HttpEngineDataSource.Factory!

Sets the connect timeout, in milliseconds.

HttpEngineDataSource.Factory!

Sets a content type Predicate.

HttpEngineDataSource.Factory!

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

HttpEngineDataSource.Factory!

Sets whether "Set-Cookie" requests on redirect should be forwarded to the redirect url in the "Cookie" header.

HttpEngineDataSource.Factory!

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

HttpEngineDataSource.Factory!

Sets the read timeout, in milliseconds.

HttpEngineDataSource.Factory!

Sets the priority of requests made by HttpEngineDataSource instances created by this factory.

HttpEngineDataSource.Factory!

Sets whether the connect timeout is reset when a redirect occurs.

HttpEngineDataSource.Factory!

Sets the TransferListener that will be used.

HttpEngineDataSource.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(httpEngine: HttpEngine!, executor: Executor!)

Creates an instance.

Parameters
httpEngine: HttpEngine!

An HttpEngine to make the requests.

executor: Executor!

The java.util.concurrent.Executor that will handle responses. This may be a direct executor (i.e. executes tasks on the calling thread) in order to avoid a thread hop from HttpEngine's internal network thread to the response handling thread. However, to avoid slowing down overall network performance, care must be taken to make sure response handling is a fast operation when using a direct executor.

Public functions

createDataSource

@UnstableApi
fun createDataSource(): HttpDataSource!

Creates a DataSource instance.

setConnectionTimeoutMs

@CanIgnoreReturnValue
@UnstableApi
fun setConnectionTimeoutMs(connectTimeoutMs: Int): HttpEngineDataSource.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
HttpEngineDataSource.Factory!

This factory.

setContentTypePredicate

@CanIgnoreReturnValue
@UnstableApi
fun setContentTypePredicate(contentTypePredicate: Predicate<String!>?): HttpEngineDataSource.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
HttpEngineDataSource.Factory!

This factory.

setDefaultRequestProperties

@CanIgnoreReturnValue
@UnstableApi
fun setDefaultRequestProperties(
    defaultRequestProperties: (Mutable)Map<String!, String!>!
): HttpEngineDataSource.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
HttpEngineDataSource.Factory!

This factory.

setHandleSetCookieRequests

@CanIgnoreReturnValue
@UnstableApi
fun setHandleSetCookieRequests(handleSetCookieRequests: Boolean): HttpEngineDataSource.Factory!

Sets whether "Set-Cookie" requests on redirect should be forwarded to the redirect url in the "Cookie" header.

The default is false.

Parameters
handleSetCookieRequests: Boolean

Whether "Set-Cookie" requests on redirect should be forwarded to the redirect url in the "Cookie" header.

Returns
HttpEngineDataSource.Factory!

This factory.

setKeepPostFor302Redirects

@CanIgnoreReturnValue
@UnstableApi
fun setKeepPostFor302Redirects(keepPostFor302Redirects: Boolean): HttpEngineDataSource.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): HttpEngineDataSource.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
HttpEngineDataSource.Factory!

This factory.

setRequestPriority

@CanIgnoreReturnValue
@UnstableApi
fun setRequestPriority(requestPriority: Int): HttpEngineDataSource.Factory!

Sets the priority of requests made by HttpEngineDataSource instances created by this factory.

The default is REQUEST_PRIORITY_MEDIUM.

Parameters
requestPriority: Int

The request priority, which should be one of HttpEngine's UrlRequest#REQUEST_PRIORITY_* constants.

Returns
HttpEngineDataSource.Factory!

This factory.

setResetTimeoutOnRedirects

@CanIgnoreReturnValue
@UnstableApi
fun setResetTimeoutOnRedirects(resetTimeoutOnRedirects: Boolean): HttpEngineDataSource.Factory!

Sets whether the connect timeout is reset when a redirect occurs.

The default is false.

Parameters
resetTimeoutOnRedirects: Boolean

Whether the connect timeout is reset when a redirect occurs.

Returns
HttpEngineDataSource.Factory!

This factory.

setTransferListener

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

Sets the TransferListener that will be used.

The default is null.

See addTransferListener.

Parameters
transferListener: TransferListener?

The listener that will be used.

Returns
HttpEngineDataSource.Factory!

This factory.

setUserAgent

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

Sets the user agent that will be used.

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

Parameters
userAgent: String?

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

Returns
HttpEngineDataSource.Factory!

This factory.