warsvrprotocolhttpreply.cpp

来自「ftpserver very good sample」· C++ 代码 · 共 99 行

CPP
99
字号
#include "StdAfx.h"#if WAR_RFC2068#include "WarSvrProtocolHttpReply.h"   // class implemented#ifndef WAR_SVR_PROTOCOL_HTTP_H#   include "WarSvrProtocolHttp.h"#endif/////////////////////////////// PUBLIC /////////////////////////////////////////============================= LIFECYCLE ====================================WarSvrProtocolHttpReply::WarSvrProtocolHttpReply(){    Reset();}// WarSvrProtocolHttpReplyWarSvrProtocolHttpReply::~WarSvrProtocolHttpReply(){}// ~WarSvrProtocolHttpReply//============================= OPERATORS ====================================//============================= OPERATIONS ===================================WarCollector<WarSvrProtocolHttpReply::type_t>& WarSvrProtocolHttpReply::AddEnumValue1(int enumValue)        throw(WarException){	if (mHaveReplied)		return *this; // We have already replied. This is probarbly just an				// error-message folklowing a throw up after the reply.    // Prepare reply    WarLog http_log(WARLOG_DEBUG_HTTP, "WarSvrProtocolHttpReply::AddEnumValue1()");        mHeader.SetReplyCode((HttpReplyCodeE)enumValue);    mHeader.SetContentLength(GetValue().size());    if (!mHeader.IsSet("Content-Type"))        mHeader.Set("Content-Type", "text/html");    // Reply    WarCollector<char> header_buffer;    mHeader.GetServerHeaders(header_buffer);    // Send header    GetServer().Send(header_buffer.GetValue());    if (http_log)    {        http_log << "Replying to client: "             << header_buffer.GetValue()             << war_endl;    }    // Send content    GetServer().Send(GetValue());	GetServer().FlushOut();	mHaveReplied = true;    return *this;}WarCollector<WarSvrProtocolHttpReply::type_t>& WarSvrProtocolHttpReply::AddEnumValue2(int enumValue)        throw(WarException){    mHeader.Set("Content-Type", "text/html");	WarCollector<type_t> out;	out << "<html>\r\n<title>Server Message</title>\r\n<body>\r\n"        << "<h2>Server Message</h2><hr>\r\n<strong>"		<<  GetMessages()[enumValue]		<< "</strong>\r\n</body>\r\n</html>\r\n";	Add(out.GetValue());    return *this;}void WarSvrProtocolHttpReply::Reset(){    mHeader.Reset();	collector_type_t::Reset();	mHaveReplied = false;}//============================= CALLBACK   ===================================//============================= ACCESS     ===================================//============================= INQUIRY    ===================================/////////////////////////////// PROTECTED  ////////////////////////////////////////////////////////////////// PRIVATE    ///////////////////////////////////#endif // #if WAR_RFC2068

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?