Skip to content

Commit c6a5ffa

Browse files
committed
Revert "refine http data source"
This reverts commit 029f8df.
1 parent 029f8df commit c6a5ffa

2 files changed

Lines changed: 5 additions & 11 deletions

File tree

‎data_source/http_source.h‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,7 @@ class HTTPConnection;
2323
}
2424

2525
class HTTPSource : public DataSource, public HTTPBase {
26-
public:
2726
HTTPSource(std::shared_ptr<net::HTTPConnection> connection);
28-
~HTTPSource() override;
2927

3028
virtual status_t ReconnectAtOffset(off64_t offset);
3129

@@ -42,6 +40,9 @@ class HTTPSource : public DataSource, public HTTPBase {
4240
int32_t Flags() override;
4341
void Close() override;
4442

43+
protected:
44+
~HTTPSource() override;
45+
4546
// DataSource interfaces
4647
std::string GetUri() override;
4748
virtual std::string GetMIMEType();

‎net/http/curl_http_connection.cc‎

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -75,15 +75,9 @@ void CurlHttpConnection::Disconnect() {
7575
}
7676

7777
ssize_t CurlHttpConnection::ReadAt(off64_t offset, void* data, size_t size) {
78-
if (!connected_) {
78+
if (!connected_ || offset >= content_length_) {
7979
return -1;
8080
}
81-
const off64_t readable_size = content_length_ >= 0
82-
? content_length_
83-
: static_cast<off64_t>(buffer_.size());
84-
if (offset < 0 || offset >= readable_size) {
85-
return 0;
86-
}
8781

8882
size_t available =
8983
std::min(size, buffer_.size() - static_cast<size_t>(offset));
@@ -94,8 +88,7 @@ ssize_t CurlHttpConnection::ReadAt(off64_t offset, void* data, size_t size) {
9488
}
9589

9690
off64_t CurlHttpConnection::GetSize() {
97-
return content_length_ >= 0 ? content_length_
98-
: static_cast<off64_t>(buffer_.size());
91+
return content_length_;
9992
}
10093

10194
status_t CurlHttpConnection::GetMIMEType(std::string& mime_type) {

0 commit comments

Comments
 (0)