рефактор + чистка кода

This commit is contained in:
2024-10-30 10:40:38 +03:00
parent 2fef65d9d9
commit 5c348ace87
16 changed files with 47 additions and 130 deletions

View File

@@ -1,27 +1,17 @@
//
// request_parser.cpp
// ~~~~~~~~~~~~~~~~~~
//
// Copyright (c) 2003-2024 Christopher M. Kohlhoff (chris at kohlhoff dot com)
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
//
#include "request_parser.hpp"
#include "request.hpp"
namespace http::server {
request_parser::request_parser()
RequestParser::RequestParser()
: state_(method_start) {
}
void request_parser::reset() {
void RequestParser::reset() {
state_ = method_start;
}
request_parser::result_type request_parser::consume(request &req, char input) {
RequestParser::result_type RequestParser::consume(Request &req, char input) {
switch (state_) {
case method_start:
if (!is_char(input) || is_ctl(input) || is_tspecial(input)) {
@@ -200,15 +190,15 @@ namespace http::server {
}
}
bool request_parser::is_char(int c) {
bool RequestParser::is_char(int c) {
return c >= 0 && c <= 127;
}
bool request_parser::is_ctl(int c) {
bool RequestParser::is_ctl(int c) {
return (c >= 0 && c <= 31) || (c == 127);
}
bool request_parser::is_tspecial(int c) {
bool RequestParser::is_tspecial(int c) {
switch (c) {
case '(':
case ')':
@@ -235,7 +225,7 @@ namespace http::server {
}
}
bool request_parser::is_digit(int c) {
bool RequestParser::is_digit(int c) {
return c >= '0' && c <= '9';
}
} // namespace http::server