From 44ef0bd5fe47a43e47aec5f7981b6c1d728dd9a8 Mon Sep 17 00:00:00 2001 From: Michele Calgaro Date: Sun, 2 Mar 2025 18:37:22 +0900 Subject: Restructure source files into 'src' subfolder Signed-off-by: Michele Calgaro --- src/plugins/webinterface/httpresponseheader.cpp | 78 +++++++++++++++++++++++++ 1 file changed, 78 insertions(+) create mode 100644 src/plugins/webinterface/httpresponseheader.cpp (limited to 'src/plugins/webinterface/httpresponseheader.cpp') diff --git a/src/plugins/webinterface/httpresponseheader.cpp b/src/plugins/webinterface/httpresponseheader.cpp new file mode 100644 index 0000000..3056f79 --- /dev/null +++ b/src/plugins/webinterface/httpresponseheader.cpp @@ -0,0 +1,78 @@ +/*************************************************************************** + * Copyright (C) 2005 by Joris Guisson * + * joris.guisson@gmail.com * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * + ***************************************************************************/ +#include "httpresponseheader.h" + +namespace kt +{ + static TQString ResponseCodeToString(int r) + { + switch (r) + { + case 200: return "OK"; + case 301: return "Moved Permanently"; + case 304: return "Not Modified"; + case 404: return "Not Found"; + } + return TQString(); + } + + HttpResponseHeader::HttpResponseHeader(int response_code) + : response_code(response_code) + { + } + + HttpResponseHeader::HttpResponseHeader(const HttpResponseHeader & hdr) + { + response_code = hdr.response_code; + fields = hdr.fields; + } + + HttpResponseHeader::~HttpResponseHeader() + { + } + + void HttpResponseHeader::setResponseCode(int rc) + { + response_code = rc; + } + + void HttpResponseHeader::setValue(const TQString & key,const TQString & value) + { + fields[key] = value; + } + + TQString HttpResponseHeader::toString() const + { + TQString str; + str += TQString("HTTP/1.1 %1 %2\r\n").arg(response_code).arg(ResponseCodeToString(response_code)); + + TQMap::const_iterator itr = fields.begin(); + while (itr != fields.end()) + { + str += TQString("%1: %2\r\n").arg(itr.key()).arg(itr.data()); + itr++; + } + str += "\r\n"; + return str; + } + + + +} -- cgit v1.2.3