Package com.google.android.exoplayer2.upstream

## Class DefaultHttpDataSource.Factory

- java.lang.Object
- - com.google.android.exoplayer2.upstream.DefaultHttpDataSource.Factory

- All Implemented Interfaces:
    `DataSource.Factory`, `HttpDataSource.Factory`
  Enclosing class:
    DefaultHttpDataSource

      public static final class DefaultHttpDataSource.Factory
      extends Object
      implements HttpDataSource.Factory

  `DataSource.Factory` for `DefaultHttpDataSource` instances.

- - ### Constructor Summary

    Constructors
    Constructor | Description
    --- | ---
    `Factory()` | Creates an instance.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `DefaultHttpDataSource` | `createDataSource()` | Creates a `DataSource` instance.
    `DefaultHttpDataSource.Factory` | `setAllowCrossProtocolRedirects​(boolean allowCrossProtocolRedirects)` | Sets whether to allow cross protocol redirects.
    `DefaultHttpDataSource.Factory` | `setConnectTimeoutMs​(int connectTimeoutMs)` | Sets the connect timeout, in milliseconds.
    `DefaultHttpDataSource.Factory` | `setContentTypePredicate​(Predicate<String> contentTypePredicate)` | Sets a content type `Predicate`.
    `DefaultHttpDataSource.Factory` | `setDefaultRequestProperties​(Map<String,​String> defaultRequestProperties)` | Sets the default request headers for `HttpDataSource` instances created by the factory.
    `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.
    `DefaultHttpDataSource.Factory` | `setReadTimeoutMs​(int readTimeoutMs)` | Sets the read timeout, in milliseconds.
    `DefaultHttpDataSource.Factory` | `setTransferListener​(TransferListener transferListener)` | Sets the `TransferListener` that will be used.
    `DefaultHttpDataSource.Factory` | `setUserAgent​(String userAgent)` | Sets the user agent that will be used.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### Factory

          public Factory()

      Creates an instance.

  - ### Method Detail

    - #### setDefaultRequestProperties

          @CanIgnoreReturnValue
          public final DefaultHttpDataSource.Factory setDefaultRequestProperties​(Map<String,​String> defaultRequestProperties)

      Description copied from interface: `HttpDataSource.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.

      Specified by:
        `setDefaultRequestProperties` in interface `HttpDataSource.Factory`
      Parameters:
        `defaultRequestProperties` - The default request properties.
      Returns:
        This factory.

    - #### setUserAgent

          @CanIgnoreReturnValue
          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:
        `userAgent` - The user agent that will be used, or `null` to use the default user agent of the underlying platform.
      Returns:
        This factory.

    - #### setConnectTimeoutMs

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

      Sets the connect timeout, in milliseconds.

      The default is `DefaultHttpDataSource.DEFAULT_CONNECT_TIMEOUT_MILLIS`.

      Parameters:
        `connectTimeoutMs` - The connect timeout, in milliseconds, that will be used.
      Returns:
        This factory.

    - #### setReadTimeoutMs

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

      Sets the read timeout, in milliseconds.

      The default is `DefaultHttpDataSource.DEFAULT_READ_TIMEOUT_MILLIS`.

      Parameters:
        `readTimeoutMs` - The connect timeout, in milliseconds, that will be used.
      Returns:
        This factory.

    - #### setAllowCrossProtocolRedirects

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

      Sets whether to allow cross protocol redirects.

      The default is `false`.

      Parameters:
        `allowCrossProtocolRedirects` - Whether to allow cross protocol redirects.
      Returns:
        This factory.

    - #### setContentTypePredicate

          @CanIgnoreReturnValue
          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 `DefaultHttpDataSource.open(DataSpec)`.

      The default is `null`.

      Parameters:
        `contentTypePredicate` - The content type `Predicate`, or `null` to clear a predicate that was previously set.
      Returns:
        This factory.

    - #### setTransferListener

          @CanIgnoreReturnValue
          public DefaultHttpDataSource.Factory setTransferListener​(@Nullable
                                                                   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.

    - #### setKeepPostFor302Redirects

          @CanIgnoreReturnValue
          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.

    - #### createDataSource

          public DefaultHttpDataSource createDataSource()

      Description copied from interface: `DataSource.Factory`
      Creates a `DataSource` instance.
      Specified by:
        `createDataSource` in interface `DataSource.Factory`
      Specified by:
        `createDataSource` in interface `HttpDataSource.Factory`