Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
SDK
/
exoplayer
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
9cdd246a
authored
Jan 07, 2016
by
Yu-Hsuan Lin
Committed by
Oliver Woodman
Jan 07, 2016
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
support okhttp3
parent
cc1f3e5c
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
14 additions
and
20 deletions
extensions/okhttp/build.gradle
extensions/okhttp/src/main/java/com/google/android/exoplayer/ext/okhttp/OkHttpDataSource.java
extensions/okhttp/build.gradle
View file @
9cdd246a
...
...
@@ -36,7 +36,7 @@ android {
dependencies
{
compile
project
(
':library'
)
compile
(
'com.squareup.okhttp
:okhttp:2.5.0
'
)
{
compile
(
'com.squareup.okhttp
3:okhttp:+
'
)
{
exclude
group:
'org.json'
}
}
extensions/okhttp/src/main/java/com/google/android/exoplayer/ext/okhttp/OkHttpDataSource.java
View file @
9cdd246a
...
...
@@ -22,14 +22,6 @@ import com.google.android.exoplayer.upstream.TransferListener;
import
com.google.android.exoplayer.util.Assertions
;
import
com.google.android.exoplayer.util.Predicate
;
import
com.squareup.okhttp.CacheControl
;
import
com.squareup.okhttp.HttpUrl
;
import
com.squareup.okhttp.OkHttpClient
;
import
com.squareup.okhttp.Request
;
import
com.squareup.okhttp.RequestBody
;
import
com.squareup.okhttp.Response
;
import
com.squareup.okhttp.internal.Util
;
import
java.io.EOFException
;
import
java.io.IOException
;
import
java.io.InputStream
;
...
...
@@ -39,6 +31,13 @@ import java.util.List;
import
java.util.Map
;
import
java.util.concurrent.atomic.AtomicReference
;
import
okhttp3.CacheControl
;
import
okhttp3.HttpUrl
;
import
okhttp3.OkHttpClient
;
import
okhttp3.Request
;
import
okhttp3.RequestBody
;
import
okhttp3.Response
;
/**
* An {@link HttpDataSource} that delegates to Square's {@link OkHttpClient}.
*/
...
...
@@ -116,7 +115,7 @@ public class OkHttpDataSource implements HttpDataSource {
@Override
public
String
getUri
()
{
return
response
==
null
?
null
:
response
.
request
().
urlString
();
return
response
==
null
?
null
:
response
.
request
().
url
().
to
String
();
}
@Override
...
...
@@ -184,15 +183,10 @@ public class OkHttpDataSource implements HttpDataSource {
bytesToSkip
=
responseCode
==
200
&&
dataSpec
.
position
!=
0
?
dataSpec
.
position
:
0
;
// Determine the length of the data to be read, after skipping.
try
{
long
contentLength
=
response
.
body
().
contentLength
();
bytesToRead
=
dataSpec
.
length
!=
C
.
LENGTH_UNBOUNDED
?
dataSpec
.
length
:
contentLength
!=
-
1
?
contentLength
-
bytesToSkip
:
C
.
LENGTH_UNBOUNDED
;
}
catch
(
IOException
e
)
{
closeConnectionQuietly
();
throw
new
HttpDataSourceException
(
e
,
dataSpec
);
}
long
contentLength
=
response
.
body
().
contentLength
();
bytesToRead
=
dataSpec
.
length
!=
C
.
LENGTH_UNBOUNDED
?
dataSpec
.
length
:
contentLength
!=
-
1
?
contentLength
-
bytesToSkip
:
C
.
LENGTH_UNBOUNDED
;
opened
=
true
;
if
(
listener
!=
null
)
{
...
...
@@ -370,7 +364,7 @@ public class OkHttpDataSource implements HttpDataSource {
* Closes the current connection quietly, if there is one.
*/
private
void
closeConnectionQuietly
()
{
Util
.
closeQuietly
(
response
.
body
()
);
response
.
body
().
close
(
);
response
=
null
;
responseByteStream
=
null
;
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment