diff --git a/test/UnitHTTP.cpp b/test/UnitHTTP.cpp index 368924e0b..16e45b00c 100644 --- a/test/UnitHTTP.cpp +++ b/test/UnitHTTP.cpp @@ -22,6 +22,7 @@ #include #include #include +#include class UnitHTTP : public UnitWSD { @@ -176,18 +177,19 @@ public: LOG_TST("Receiving..."); char buffer[4096] = { 0, }; int got = socket->receiveBytes(buffer, 4096); - static const std::string start = - "HTTP/1.0 200 OK\r\n" - "Content-Disposition: attachment; filename=\"test.txt\"\r\n"; - if (strncmp(buffer, start.c_str(), start.size())) - { - LOG_TST("missing pre-amble " << got << " [" << buffer << "] vs. expected [" << start - << ']'); - LOK_ASSERT(Util::startsWith(std::string(buffer), start)); - exitTest(TestResult::Failed); - return; - } + http::Response httpResponse; + LOK_ASSERT_MESSAGE("Expected to receive valid data", + httpResponse.readData(buffer, got) > 0); + LOK_ASSERT(!httpResponse.statusLine().httpVersion().empty()); + LOK_ASSERT(!httpResponse.statusLine().reasonPhrase().empty()); + LOK_ASSERT_EQUAL(http::StatusCode::OK, httpResponse.statusLine().statusCode()); + LOK_ASSERT(httpResponse.statusLine().statusCategory() == + http::StatusLine::StatusCodeClass::Successful); + LOK_ASSERT_EQUAL(std::string("HTTP/1.0"), httpResponse.statusLine().httpVersion()); + LOK_ASSERT_EQUAL(std::string("OK"), httpResponse.statusLine().reasonPhrase()); + LOK_ASSERT_EQUAL(std::string("attachment; filename=\"test.txt\""), + httpResponse.header().get("Content-Disposition")); // TODO: check content-length etc. diff --git a/wsd/ClientSession.cpp b/wsd/ClientSession.cpp index d2dd9312a..0215342f8 100644 --- a/wsd/ClientSession.cpp +++ b/wsd/ClientSession.cpp @@ -1813,7 +1813,6 @@ bool ClientSession::handleKitToClientMessage(const std::shared_ptr& pay const std::string fileName = Poco::Path(resultURL.getPath()).getFileName(); Poco::Net::HTTPResponse response; - // We have a fragile test that expects Content-Disposition first. if (!fileName.empty()) response.set("Content-Disposition", "attachment; filename=\"" + fileName + '"'); response.setContentType("application/octet-stream");