From 82b80c33d8bb5c12ed571971666b396b3433cb4d Mon Sep 17 00:00:00 2001 From: Tatsuhiro Tsujikawa Date: Mon, 10 Nov 2008 16:08:22 +0000 Subject: [PATCH] 2008-11-11 Tatsuhiro Tsujikawa 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 --- ChangeLog | 8 ++++++++ src/HttpResponse.cc | 3 ++- src/HttpResponse.h | 1 + test/HttpResponseTest.cc | 5 +++-- 4 files changed, 14 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index 0e9b1374..36a19961 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2008-11-11 Tatsuhiro Tsujikawa + + 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 Removed unused code. diff --git a/src/HttpResponse.cc b/src/HttpResponse.cc index 715effce..71ed71eb 100644 --- a/src/HttpResponse.cc +++ b/src/HttpResponse.cc @@ -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; } } diff --git a/src/HttpResponse.h b/src/HttpResponse.h index b12a6f44..78272bbb 100644 --- a/src/HttpResponse.h +++ b/src/HttpResponse.h @@ -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); diff --git a/test/HttpResponseTest.cc b/test/HttpResponseTest.cc index 81176154..2ec223b6 100644 --- a/test/HttpResponseTest.cc +++ b/test/HttpResponseTest.cc @@ -122,9 +122,10 @@ void HttpResponseTest::testGetContentType() { HttpResponse httpResponse; SharedHandle 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()); }