43 lines
1.0 KiB
C++
43 lines
1.0 KiB
C++
#ifndef WEBCC_VIEW_H_
|
|
#define WEBCC_VIEW_H_
|
|
|
|
#include <memory>
|
|
|
|
#include "webcc/request.h"
|
|
#include "webcc/response.h"
|
|
|
|
namespace webcc {
|
|
|
|
class View {
|
|
public:
|
|
View() = default;
|
|
|
|
virtual ~View() = default;
|
|
|
|
View(const View&) = delete;
|
|
View& operator=(const View&) = delete;
|
|
|
|
virtual ResponsePtr Handle(RequestPtr request) = 0;
|
|
|
|
// Return true if you want the request data of the given method to be streamed
|
|
// to a temp file. Data streaming is useful for receiving large data, e.g.,
|
|
// a JPEG image, posted from the client.
|
|
virtual bool Stream(const std::string& /*method*/) {
|
|
return false; // No streaming by default
|
|
}
|
|
|
|
// 【核心新增】:请求头预校验虚函数
|
|
// 当 Header 刚解析完毕、尚未接收 Body 时触发。
|
|
// 返回 true 继续接收数据;返回 false 强行 RST 切断连接。
|
|
virtual bool ValidateHeader(RequestPtr /*request*/)
|
|
{
|
|
return true; // 默认不校验,全放行
|
|
}
|
|
};
|
|
|
|
using ViewPtr = std::shared_ptr<View>;
|
|
|
|
} // namespace webcc
|
|
|
|
#endif // WEBCC_VIEW_H_
|