mirror of https://github.com/aria2/aria2
2007-11-27 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
Set Content-Type to SingleFileDownloadContext when http response is received. * src/HttpResponseCommand.cc * src/HttpResponse.{h, cc} * test/HttpResponseTest.ccpull/1/head
parent
506bc3db13
commit
fac8e1d273
|
@ -1,3 +1,11 @@
|
|||
2007-11-27 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
|
||||
|
||||
Set Content-Type to SingleFileDownloadContext when http response is
|
||||
received.
|
||||
* src/HttpResponseCommand.cc
|
||||
* src/HttpResponse.{h, cc}
|
||||
* test/HttpResponseTest.cc
|
||||
|
||||
2007-11-27 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
|
||||
|
||||
Rewritten to add content-type support.
|
||||
|
|
|
@ -146,3 +146,12 @@ int64_t HttpResponse::getEntityLength() const
|
|||
return httpHeader->getRange()->getEntityLength();
|
||||
}
|
||||
}
|
||||
|
||||
string HttpResponse::getContentType() const
|
||||
{
|
||||
if(httpHeader.isNull()) {
|
||||
return "";
|
||||
} else {
|
||||
return httpHeader->getFirst("Content-Type");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -89,6 +89,8 @@ public:
|
|||
|
||||
int64_t getEntityLength() const;
|
||||
|
||||
string getContentType() const;
|
||||
|
||||
void setHttpHeader(const HttpHeaderHandle& httpHeader)
|
||||
{
|
||||
this->httpHeader = httpHeader;
|
||||
|
|
|
@ -91,6 +91,7 @@ bool HttpResponseCommand::executeInternal()
|
|||
SingleFileDownloadContextHandle dctx = _requestGroup->getDownloadContext();
|
||||
dctx->setTotalLength(totalLength);
|
||||
dctx->setFilename(httpResponse->determinFilename());
|
||||
dctx->setContentType(httpResponse->getContentType());
|
||||
_requestGroup->preDownloadProcessing();
|
||||
if(e->_requestGroupMan->isSameFileBeingDownloaded(_requestGroup)) {
|
||||
throw new DownloadFailureException(EX_DUPLICATE_FILE_DOWNLOAD,
|
||||
|
|
|
@ -13,6 +13,7 @@ class HttpResponseTest : public CppUnit::TestFixture {
|
|||
CPPUNIT_TEST(testGetContentLength_contentLength);
|
||||
//CPPUNIT_TEST(testGetContentLength_range);
|
||||
CPPUNIT_TEST(testGetEntityLength);
|
||||
CPPUNIT_TEST(testGetContentType);
|
||||
CPPUNIT_TEST(testDeterminFilename_without_ContentDisposition);
|
||||
CPPUNIT_TEST(testDeterminFilename_with_ContentDisposition_zero_length);
|
||||
CPPUNIT_TEST(testDeterminFilename_with_ContentDisposition);
|
||||
|
@ -36,6 +37,7 @@ public:
|
|||
void testGetContentLength_null();
|
||||
void testGetContentLength_contentLength();
|
||||
void testGetEntityLength();
|
||||
void testGetContentType();
|
||||
void testDeterminFilename_without_ContentDisposition();
|
||||
void testDeterminFilename_with_ContentDisposition_zero_length();
|
||||
void testDeterminFilename_with_ContentDisposition();
|
||||
|
@ -90,6 +92,16 @@ void HttpResponseTest::testGetEntityLength()
|
|||
|
||||
}
|
||||
|
||||
void HttpResponseTest::testGetContentType()
|
||||
{
|
||||
HttpResponse httpResponse;
|
||||
HttpHeaderHandle httpHeader = new HttpHeader();
|
||||
httpHeader->put("content-type", "application/octet-stream");
|
||||
httpResponse.setHttpHeader(httpHeader);
|
||||
CPPUNIT_ASSERT_EQUAL(string("application/octet-stream"),
|
||||
httpResponse.getContentType());
|
||||
}
|
||||
|
||||
void HttpResponseTest::testDeterminFilename_without_ContentDisposition()
|
||||
{
|
||||
HttpResponse httpResponse;
|
||||
|
|
Loading…
Reference in New Issue