From 6cb2f05a6c1abfd6afc91b49acbe8423203f4f57 Mon Sep 17 00:00:00 2001 From: Chocobo1 Date: Thu, 13 Apr 2017 14:46:40 +0800 Subject: [PATCH] Demote to helper function Rename function --- src/base/http/connection.cpp | 2 +- src/base/http/responsegenerator.cpp | 6 ++---- src/base/http/responsegenerator.h | 7 ++----- 3 files changed, 5 insertions(+), 10 deletions(-) diff --git a/src/base/http/connection.cpp b/src/base/http/connection.cpp index ce81c6807..9e26874a6 100644 --- a/src/base/http/connection.cpp +++ b/src/base/http/connection.cpp @@ -87,7 +87,7 @@ void Connection::read() void Connection::sendResponse(const Response &response) { - m_socket->write(ResponseGenerator::generate(response)); + m_socket->write(toByteArray(response)); } bool Connection::hasExpired(const qint64 timeout) const diff --git a/src/base/http/responsegenerator.cpp b/src/base/http/responsegenerator.cpp index 378396722..6b08b5803 100644 --- a/src/base/http/responsegenerator.cpp +++ b/src/base/http/responsegenerator.cpp @@ -35,9 +35,7 @@ #include "base/utils/gzip.h" -using namespace Http; - -QByteArray ResponseGenerator::generate(Response response) +QByteArray Http::toByteArray(Response response) { if (response.headers[HEADER_CONTENT_ENCODING] == "gzip") { // A gzip seems to have 23 bytes overhead. @@ -69,7 +67,7 @@ QByteArray ResponseGenerator::generate(Response response) return ret.toUtf8() + response.content; } -QString ResponseGenerator::httpDate() +QString Http::httpDate() { // [RFC 7231] 7.1.1.1. Date/Time Formats // example: "Sun, 06 Nov 1994 08:49:37 GMT" diff --git a/src/base/http/responsegenerator.h b/src/base/http/responsegenerator.h index 3d41f7444..a2fbb2ce2 100644 --- a/src/base/http/responsegenerator.h +++ b/src/base/http/responsegenerator.h @@ -37,11 +37,8 @@ namespace Http { - namespace ResponseGenerator - { - QByteArray generate(Response response); - QString httpDate(); - }; + QByteArray toByteArray(Response response); + QString httpDate(); } #endif // HTTP_RESPONSEGENERATOR_H