Interface HttpDataSource
-
- All Superinterfaces:
DataReader,DataSource
- All Known Implementing Classes:
CronetDataSource,DefaultHttpDataSource,OkHttpDataSource
@Deprecated public interface HttpDataSource extends DataSource
Deprecated.com.google.android.exoplayer2 is deprecated. Please migrate to androidx.media3 (which contains the same ExoPlayer code). See the migration guide for more details, including a script to help with the migration.An HTTPDataSource.
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static classHttpDataSource.BaseFactoryDeprecated.Base implementation ofHttpDataSource.Factorythat sets default request properties.static classHttpDataSource.CleartextNotPermittedExceptionDeprecated.Thrown when cleartext HTTP traffic is not permitted.static interfaceHttpDataSource.FactoryDeprecated.A factory forHttpDataSourceinstances.static classHttpDataSource.HttpDataSourceExceptionDeprecated.Thrown when an error is encountered when trying to read from aHttpDataSource.static classHttpDataSource.InvalidContentTypeExceptionDeprecated.Thrown when the content type is invalid.static classHttpDataSource.InvalidResponseCodeExceptionDeprecated.Thrown when an attempt to open a connection results in a response code not in the 2xx range.static classHttpDataSource.RequestPropertiesDeprecated.Stores HTTP request properties (aka HTTP headers) and provides methods to modify the headers in a thread safe way to avoid the potential of creating snapshots of an inconsistent or unintended state.
-
Field Summary
Fields Modifier and Type Field Description static Predicate<String>REJECT_PAYWALL_TYPESDeprecated.APredicatethat rejects content types often used for pay-walls.
-
Method Summary
All Methods Instance Methods Abstract Methods Deprecated Methods Modifier and Type Method Description voidclearAllRequestProperties()Deprecated.Clears all request headers that were set bysetRequestProperty(String, String).voidclearRequestProperty(String name)Deprecated.Clears the value of a request header.voidclose()Deprecated.Closes the source.intgetResponseCode()Deprecated.When the source is open, returns the HTTP response status code associated with the lastopen(com.google.android.exoplayer2.upstream.DataSpec)call.Map<String,List<String>>getResponseHeaders()Deprecated.When the source is open, returns the response headers associated with the lastDataSource.open(com.google.android.exoplayer2.upstream.DataSpec)call.longopen(DataSpec dataSpec)Deprecated.Opens the source to read the specified data.intread(byte[] buffer, int offset, int length)Deprecated.Reads up tolengthbytes of data from the input.voidsetRequestProperty(String name, String value)Deprecated.Sets the value of a request header.-
Methods inherited from interface com.google.android.exoplayer2.upstream.DataSource
addTransferListener, getUri
-
-
-
-
Method Detail
-
open
long open(DataSpec dataSpec) throws HttpDataSource.HttpDataSourceException
Deprecated.Opens the source to read the specified data.Note:
HttpDataSourceimplementations are advised to set request headers passed via (in order of decreasing priority) thedataSpec,setRequestProperty(java.lang.String, java.lang.String)and the default parameters set in theHttpDataSource.Factory.- Specified by:
openin interfaceDataSource- Parameters:
dataSpec- Defines the data to be read.- Returns:
- The number of bytes that can be read from the opened source. For unbounded requests
(i.e., requests where
DataSpec.lengthequalsC.LENGTH_UNSET) this value is the resolved length of the request, orC.LENGTH_UNSETif the length is still unresolved. For all other requests, the value returned will be equal to the request'sDataSpec.length. - Throws:
HttpDataSource.HttpDataSourceException
-
close
void close() throws HttpDataSource.HttpDataSourceExceptionDeprecated.Description copied from interface:DataSourceCloses the source. This method must be called even if the corresponding call toDataSource.open(DataSpec)threw anIOException.- Specified by:
closein interfaceDataSource- Throws:
HttpDataSource.HttpDataSourceException
-
read
int read(byte[] buffer, int offset, int length) throws HttpDataSource.HttpDataSourceExceptionDeprecated.Description copied from interface:DataReaderReads up tolengthbytes of data from the input.If
readLengthis zero then 0 is returned. Otherwise, if no data is available because the end of the opened range has been reached, thenC.RESULT_END_OF_INPUTis returned. Otherwise, the call will block until at least one byte of data has been read and the number of bytes read is returned.- Specified by:
readin interfaceDataReader- Parameters:
buffer- A target array into which data should be written.offset- The offset into the target array at which to write.length- The maximum number of bytes to read from the input.- Returns:
- The number of bytes read, or
C.RESULT_END_OF_INPUTif the input has ended. This may be less thanlengthbecause the end of the input (or available data) was reached, the method was interrupted, or the operation was aborted early for another reason. - Throws:
HttpDataSource.HttpDataSourceException
-
setRequestProperty
void setRequestProperty(String name, String value)
Deprecated.Sets the value of a request header. The value will be used for subsequent connections established by the source.Note: If the same header is set as a default parameter in the
HttpDataSource.Factory, then the header value set with this method should be preferred when connecting with the data source. Seeopen(com.google.android.exoplayer2.upstream.DataSpec).- Parameters:
name- The name of the header field.value- The value of the field.
-
clearRequestProperty
void clearRequestProperty(String name)
Deprecated.Clears the value of a request header. The change will apply to subsequent connections established by the source.- Parameters:
name- The name of the header field.
-
clearAllRequestProperties
void clearAllRequestProperties()
Deprecated.Clears all request headers that were set bysetRequestProperty(String, String).
-
getResponseCode
int getResponseCode()
Deprecated.When the source is open, returns the HTTP response status code associated with the lastopen(com.google.android.exoplayer2.upstream.DataSpec)call. Otherwise, returns a negative value.
-
getResponseHeaders
Map<String,List<String>> getResponseHeaders()
Deprecated.Description copied from interface:DataSourceWhen the source is open, returns the response headers associated with the lastDataSource.open(com.google.android.exoplayer2.upstream.DataSpec)call. Otherwise, returns an empty map.Key look-up in the returned map is case-insensitive.
- Specified by:
getResponseHeadersin interfaceDataSource
-
-