2008-11-11 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>

Fixed the bug that metalink file is not processed if
	Content-Type field has a paramter.
	* src/HttpResponse.cc
	* src/HttpResponse.h
	* test/HttpResponseTest.cc
pull/1/head
Tatsuhiro Tsujikawa 2008-11-10 16:08:22 +00:00
parent bb8481e752
commit 82b80c33d8
4 changed files with 14 additions and 3 deletions

View File

@ -1,3 +1,11 @@
2008-11-11 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
Fixed the bug that metalink file is not processed if Content-Type
field has a paramter.
* src/HttpResponse.cc
* src/HttpResponse.h
* test/HttpResponseTest.cc
2008-11-10 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
Removed unused code.

View File

@ -212,7 +212,8 @@ std::string HttpResponse::getContentType() const
if(httpHeader.isNull()) {
return A2STR::NIL;
} else {
return httpHeader->getFirst(HttpHeader::CONTENT_TYPE);
return
Util::split(httpHeader->getFirst(HttpHeader::CONTENT_TYPE), ";").first;
}
}

View File

@ -97,6 +97,7 @@ public:
uint64_t getEntityLength() const;
// Returns type "/" subtype. The parameter is removed.
std::string getContentType() const;
void setHttpHeader(const SharedHandle<HttpHeader>& httpHeader);

View File

@ -122,9 +122,10 @@ void HttpResponseTest::testGetContentType()
{
HttpResponse httpResponse;
SharedHandle<HttpHeader> httpHeader(new HttpHeader());
httpHeader->put("content-type", "application/octet-stream");
httpHeader->put("content-type", "application/metalink+xml; charset=UTF-8");
httpResponse.setHttpHeader(httpHeader);
CPPUNIT_ASSERT_EQUAL(std::string("application/octet-stream"),
// See paramter is ignored.
CPPUNIT_ASSERT_EQUAL(std::string("application/metalink+xml"),
httpResponse.getContentType());
}