4 Star 3 Fork 4

Gitee 极速下载/Tiny-httpd

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
此仓库是为了提升国内下载速度的镜像仓库,每日同步一次。 原始仓库: https://github.com/Huangtuzhi/Tinyhttpd
克隆/下载
response.cpp 1.58 KB
一键复制 编辑 原始数据 按行查看 历史
Huangtuzhi 提交于 10年前 . a
#include "response.h"
#include "httpstatus.h"
#include "log.h"
#include <QDateTime>
Response::Response(QTcpSocket* socket, int http_status_code, QMap<QString, QString>& header):
m_socket(socket),
m_http_status_code(http_status_code),
m_header(header)
{
m_header["Server"] = APPLICATION_IDENTIFIER;
m_header["Date"] = Common::getTimeStampString();
}
void Response::responseHeader()
{
m_socket->write("HTTP/1.0 ");
switch (m_http_status_code)
{
case 200:
m_socket->write(HTTP_STATUS_200);
Log::instance() << HTTP_STATUS_200 << Log::NEWLINE << Log::FLUSH;
break;
case 301:
m_socket->write(HTTP_STATUS_301);
Log::instance() << HTTP_STATUS_301 << Log::NEWLINE << Log::FLUSH;
break;
case 304:
m_socket->write(HTTP_STATUS_304);
Log::instance() << HTTP_STATUS_304 << Log::NEWLINE << Log::FLUSH;
break;
case 403:
m_socket->write(HTTP_STATUS_403);
Log::instance() << HTTP_STATUS_403 << Log::NEWLINE << Log::FLUSH;
break;
case 404:
m_socket->write(HTTP_STATUS_404);
Log::instance() << HTTP_STATUS_404 << Log::NEWLINE << Log::FLUSH;
break;
default:
m_socket->write(QString("%1").arg(m_http_status_code).toLatin1());
}
m_socket->write("\r\n");
QMap<QString, QString>::iterator i;
for(i = m_header.begin(); i != m_header.end(); ++i)
{
m_socket->write(i.key().toLatin1());
m_socket->write(": ");
m_socket->write(i.value().toLatin1());
m_socket->write("\r\n");
}
m_socket->write("\r\n");
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
C/C++
1
https://gitee.com/mirrors/Tiny-httpd.git
git@gitee.com:mirrors/Tiny-httpd.git
mirrors
Tiny-httpd
Tiny-httpd
master

搜索帮助