public final class

HttpEngineDataSource.Factory

extends java.lang.Object

implements HttpDataSource.Factory

 java.lang.Object

↳androidx.media3.datasource.HttpEngineDataSource.Factory

Overview

DataSource.Factory for HttpEngineDataSource instances.

Summary

Constructors
publicFactory(HttpEngine httpEngine, java.util.concurrent.Executor executor)

Creates an instance.

Methods
public HttpDataSourcecreateDataSource()

public HttpEngineDataSource.FactorysetConnectionTimeoutMs(int connectTimeoutMs)

Sets the connect timeout, in milliseconds.

public HttpEngineDataSource.FactorysetContentTypePredicate(<any> contentTypePredicate)

Sets a content type .

public final HttpEngineDataSource.FactorysetDefaultRequestProperties(java.util.Map<java.lang.String, java.lang.String> defaultRequestProperties)

public HttpEngineDataSource.FactorysetHandleSetCookieRequests(boolean handleSetCookieRequests)

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

public HttpEngineDataSource.FactorysetKeepPostFor302Redirects(boolean keepPostFor302Redirects)

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

public HttpEngineDataSource.FactorysetReadTimeoutMs(int readTimeoutMs)

Sets the read timeout, in milliseconds.

public HttpEngineDataSource.FactorysetRequestPriority(int requestPriority)

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

public HttpEngineDataSource.FactorysetResetTimeoutOnRedirects(boolean resetTimeoutOnRedirects)

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

public HttpEngineDataSource.FactorysetTransferListener(TransferListener transferListener)

Sets the TransferListener that will be used.

public HttpEngineDataSource.FactorysetUserAgent(java.lang.String userAgent)

Sets the user agent that will be used.

from java.lang.Objectclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Constructors

public Factory(HttpEngine httpEngine, java.util.concurrent.Executor executor)

Creates an instance.

Parameters:

httpEngine: An to make the requests.
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.

Methods

public final HttpEngineDataSource.Factory setDefaultRequestProperties(java.util.Map<java.lang.String, java.lang.String> defaultRequestProperties)

public HttpEngineDataSource.Factory setUserAgent(java.lang.String userAgent)

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: The user agent that will be used, or null to use the default user agent of the underlying .

Returns:

This factory.

public HttpEngineDataSource.Factory setRequestPriority(int requestPriority)

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

The default is UrlRequest.

Parameters:

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

Returns:

This factory.

public HttpEngineDataSource.Factory setConnectionTimeoutMs(int connectTimeoutMs)

Sets the connect timeout, in milliseconds.

The default is HttpEngineDataSource.DEFAULT_CONNECT_TIMEOUT_MILLIS.

Parameters:

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

Returns:

This factory.

public HttpEngineDataSource.Factory setResetTimeoutOnRedirects(boolean resetTimeoutOnRedirects)

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

The default is false.

Parameters:

resetTimeoutOnRedirects: Whether the connect timeout is reset when a redirect occurs.

Returns:

This factory.

public HttpEngineDataSource.Factory setHandleSetCookieRequests(boolean handleSetCookieRequests)

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

The default is false.

Parameters:

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

Returns:

This factory.

public HttpEngineDataSource.Factory setReadTimeoutMs(int readTimeoutMs)

Sets the read timeout, in milliseconds.

The default is HttpEngineDataSource.DEFAULT_READ_TIMEOUT_MILLIS.

Parameters:

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

Returns:

This factory.

public HttpEngineDataSource.Factory setContentTypePredicate(<any> contentTypePredicate)

Sets a content type . If a content type is rejected by the predicate then a HttpDataSource.InvalidContentTypeException is thrown from DataSource.open(DataSpec).

The default is null.

Parameters:

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

Returns:

This factory.

public HttpEngineDataSource.Factory setKeepPostFor302Redirects(boolean keepPostFor302Redirects)

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

public HttpEngineDataSource.Factory setTransferListener(TransferListener transferListener)

Sets the TransferListener that will be used.

The default is null.

See DataSource.addTransferListener(TransferListener).

Parameters:

transferListener: The listener that will be used.

Returns:

This factory.

public HttpDataSource createDataSource()