summaryrefslogtreecommitdiff
path: root/src/HttpResponse.cc
diff options
context:
space:
mode:
authorTatsuhiro Tsujikawa <tatsuhiro.t@gmail.com>2010-09-06 14:29:36 +0000
committerTatsuhiro Tsujikawa <tatsuhiro.t@gmail.com>2010-09-06 14:29:36 +0000
commitefbfe4c006cfb6e0bf3ee4ed57d0657c0cd85c19 (patch)
treea72723a125c34220772259f051673ff88598bded /src/HttpResponse.cc
parent552c753dbba55005964ad60698d803a44dac6391 (diff)
2010-09-06 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
Data from remote server in HTTP/FTP download are now written to the disk(or memory) through StreamFilter. Decoding chunked and gziped streams are done cascading StreamFilter. Removed inefficient 1byte read code. * src/ChunkedDecodingStreamFilter.cc * src/ChunkedDecodingStreamFilter.h * src/DownloadCommand.cc * src/DownloadCommand.h * src/GZipDecodingStreamFilter.cc * src/GZipDecodingStreamFilter.h * src/HttpConnection.cc * src/HttpDownloadCommand.cc * src/HttpResponse.cc * src/HttpResponse.h * src/HttpResponseCommand.cc * src/HttpResponseCommand.h * src/HttpSkipResponseCommand.cc * src/HttpSkipResponseCommand.h * src/Makefile.am * src/NullSinkStreamFilter.cc * src/NullSinkStreamFilter.h * src/RequestGroup.cc * src/SinkStreamFilter.cc * src/SinkStreamFilter.h * src/StreamFilter.cc * src/StreamFilter.h * test/ChunkedDecodingStreamFilterTest.cc * test/GZipDecodingStreamFilterTest.cc * test/HttpResponseTest.cc * test/Makefile.am * test/MockSegment.h
Diffstat (limited to 'src/HttpResponse.cc')
-rw-r--r--src/HttpResponse.cc25
1 files changed, 13 insertions, 12 deletions
diff --git a/src/HttpResponse.cc b/src/HttpResponse.cc
index e2b08fb1..fd406b4a 100644
--- a/src/HttpResponse.cc
+++ b/src/HttpResponse.cc
@@ -46,14 +46,13 @@
#include "DlRetryEx.h"
#include "StringFormat.h"
#include "A2STR.h"
-#include "Decoder.h"
-#include "ChunkedDecoder.h"
-#ifdef HAVE_LIBZ
-# include "GZipDecoder.h"
-#endif // HAVE_LIBZ
#include "CookieStorage.h"
#include "AuthConfigFactory.h"
#include "AuthConfig.h"
+#include "ChunkedDecodingStreamFilter.h"
+#ifdef HAVE_LIBZ
+# include "GZipDecodingStreamFilter.h"
+#endif // HAVE_LIBZ
namespace aria2 {
@@ -177,20 +176,21 @@ bool HttpResponse::isTransferEncodingSpecified() const
std::string HttpResponse::getTransferEncoding() const
{
- // TODO See TODO in getTransferEncodingDecoder()
+ // TODO See TODO in getTransferEncodingStreamFilter()
return httpHeader_->getFirst(HttpHeader::TRANSFER_ENCODING);
}
-SharedHandle<Decoder> HttpResponse::getTransferEncodingDecoder() const
+SharedHandle<StreamFilter> HttpResponse::getTransferEncodingStreamFilter() const
{
+ SharedHandle<StreamFilter> filter;
// TODO Transfer-Encoding header field can contains multiple tokens. We should
// parse the field and retrieve each token.
if(isTransferEncodingSpecified()) {
if(getTransferEncoding() == HttpHeader::CHUNKED) {
- return SharedHandle<Decoder>(new ChunkedDecoder());
+ filter.reset(new ChunkedDecodingStreamFilter());
}
}
- return SharedHandle<Decoder>();
+ return filter;
}
bool HttpResponse::isContentEncodingSpecified() const
@@ -203,15 +203,16 @@ const std::string& HttpResponse::getContentEncoding() const
return httpHeader_->getFirst(HttpHeader::CONTENT_ENCODING);
}
-SharedHandle<Decoder> HttpResponse::getContentEncodingDecoder() const
+SharedHandle<StreamFilter> HttpResponse::getContentEncodingStreamFilter() const
{
+ SharedHandle<StreamFilter> filter;
#ifdef HAVE_LIBZ
if(getContentEncoding() == HttpHeader::GZIP ||
getContentEncoding() == HttpHeader::DEFLATE) {
- return SharedHandle<Decoder>(new GZipDecoder());
+ filter.reset(new GZipDecodingStreamFilter());
}
#endif // HAVE_LIBZ
- return SharedHandle<Decoder>();
+ return filter;
}
uint64_t HttpResponse::getContentLength() const