DefaultHttpDataSource.Factory


public final class DefaultHttpDataSource.Factory implements HttpDataSource.Factory


DataSource.Factory for DefaultHttpDataSource instances.

Summary

Public constructors

Creates an instance.

Public methods

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
@CanIgnoreReturnValue
@UnstableApi
setCrossProtocolRedirectsForceOriginal(
    boolean crossProtocolRedirectsForceOriginal
)

Sets whether cross protocol redirects should be forced to follow original protocol.

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.

Public constructors

Factory

public Factory()

Creates an instance.

Public methods

createDataSource

@UnstableApi
public DefaultHttpDataSource createDataSource()

Creates a DataSource instance.

setAllowCrossProtocolRedirects

@CanIgnoreReturnValue
@UnstableApi
public DefaultHttpDataSource.Factory setAllowCrossProtocolRedirects(boolean allowCrossProtocolRedirects)

Sets whether to allow cross protocol redirects.

The default is false.

Parameters
boolean allowCrossProtocolRedirects

Whether to allow cross protocol redirects.

Returns
DefaultHttpDataSource.Factory

This factory.

setConnectTimeoutMs

@CanIgnoreReturnValue
@UnstableApi
public DefaultHttpDataSource.Factory setConnectTimeoutMs(int connectTimeoutMs)

Sets the connect timeout, in milliseconds.

The default is DEFAULT_CONNECT_TIMEOUT_MILLIS.

Parameters
int connectTimeoutMs

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

Returns
DefaultHttpDataSource.Factory

This factory.

setContentTypePredicate

@CanIgnoreReturnValue
@UnstableApi
public DefaultHttpDataSource.Factory setContentTypePredicate(
    @Nullable Predicate<String> contentTypePredicate
)

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
@Nullable Predicate<String> contentTypePredicate

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

Returns
DefaultHttpDataSource.Factory

This factory.

setCrossProtocolRedirectsForceOriginal

@CanIgnoreReturnValue
@UnstableApi
public DefaultHttpDataSource.Factory setCrossProtocolRedirectsForceOriginal(
    boolean crossProtocolRedirectsForceOriginal
)

Sets whether cross protocol redirects should be forced to follow original protocol. This should only be set if allowCrossProtocolRedirects is false.

The default is false.

Parameters
boolean crossProtocolRedirectsForceOriginal

Whether to force original protocol.

Returns
DefaultHttpDataSource.Factory

This factory.

setDefaultRequestProperties

@CanIgnoreReturnValue
@UnstableApi
public DefaultHttpDataSource.Factory setDefaultRequestProperties(
    Map<StringString> defaultRequestProperties
)

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
Map<StringString> defaultRequestProperties

The default request properties.

Returns
DefaultHttpDataSource.Factory

This factory.

setKeepPostFor302Redirects

@CanIgnoreReturnValue
@UnstableApi
public DefaultHttpDataSource.Factory setKeepPostFor302Redirects(boolean keepPostFor302Redirects)

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

setReadTimeoutMs

@CanIgnoreReturnValue
@UnstableApi
public DefaultHttpDataSource.Factory setReadTimeoutMs(int readTimeoutMs)

Sets the read timeout, in milliseconds.

The default is DEFAULT_READ_TIMEOUT_MILLIS.

Parameters
int readTimeoutMs

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

Returns
DefaultHttpDataSource.Factory

This factory.

setTransferListener

@CanIgnoreReturnValue
@UnstableApi
public DefaultHttpDataSource.Factory setTransferListener(@Nullable TransferListener transferListener)

Sets the TransferListener that will be used.

The default is null.

See addTransferListener.

Parameters
@Nullable TransferListener transferListener

The listener that will be used.

Returns
DefaultHttpDataSource.Factory

This factory.

setUserAgent

@CanIgnoreReturnValue
@UnstableApi
public DefaultHttpDataSource.Factory setUserAgent(@Nullable String userAgent)

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
@Nullable String userAgent

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

Returns
DefaultHttpDataSource.Factory

This factory.