This commit is contained in:
whaffman 2025-09-24 12:03:40 +02:00
parent 7270ee1812
commit 901f766599
28 changed files with 136 additions and 115 deletions

0
fix_iwyu.sh Executable file → Normal file
View File

0
safe_iwyu_fix.sh Executable file → Normal file
View File

View File

@ -1,7 +1,13 @@
#include "webserv/socket/Socket.hpp"
#include <webserv/client/Client.hpp>
#include <webserv/log/Log.hpp>
#include <webserv/log/Log.hpp> // for Log
#include <stdint.h> // for uint8_t
#include <sys/types.h> // for ssize_t
#include <webserv/http/HttpHeaders.hpp> // for HttpHeaders
#include <webserv/server/Server.hpp> // for Server
#include <webserv/socket/Socket.hpp> // for Socket
#include <functional> // for reference_wrapper, cref, ref
#include <map> // for map
#include <utility> // for pair, move
Client::Client(std::unique_ptr<Socket> socket, Server &server, const ServerConfig &server_config)
: client_socket_(std::move(socket)), server_(std::ref(server)), server_config_(std::cref(server_config)),

View File

@ -1,14 +1,17 @@
#pragma once
#include "webserv/socket/Socket.hpp"
#include <webserv/config/ServerConfig.hpp>
#include <webserv/http/HttpRequest.hpp>
#include <webserv/config/ServerConfig.hpp> // for ServerConfig
#include <webserv/http/HttpRequest.hpp> // for HttpRequest
#include <webserv/server/Server.hpp>
#include <webserv/socket/Socket.hpp>
#include <memory>
#include <memory> // for unique_ptr
#include <string> // for string
#include <stddef.h> // for size_t
class Server;
class Socket;
class Client
{

View File

@ -1,12 +1,11 @@
#include <webserv/config/ConfigManager.hpp>
#include <webserv/config/ServerConfig.hpp>
#include <webserv/config/utils.hpp>
#include <webserv/log/Log.hpp>
#include <fstream>
#include <iostream>
#include <sstream>
#include <stdexcept>
#include <webserv/config/ServerConfig.hpp> // for ServerConfig
#include <webserv/config/utils.hpp> // for trim, findCorrespondingClosingBrace, trimSemi
#include <webserv/log/Log.hpp> // for Log
#include <stddef.h> // for size_t
#include <fstream> // for basic_ifstream, basic_istream, basic_filebuf, basic_ostream::operator<<, ifstream, istringstream, stringstream
#include <sstream> // for basic_stringstream, basic_istringstream
#include <stdexcept> // for runtime_error
ConfigManager::ConfigManager() : initialized_(false) {}

View File

@ -1,7 +1,6 @@
#pragma once
#include <webserv/config/ServerConfig.hpp>
#include <string>
#include <vector>

View File

@ -1,7 +1,6 @@
#include <webserv/config/LocationConfig.hpp>
#include <webserv/config/utils.hpp>
#include <webserv/log/Log.hpp>
#include <sstream>
#include <string>

View File

@ -1,10 +1,12 @@
#include <webserv/config/LocationConfig.hpp>
#include <webserv/config/LocationConfig.hpp> // for LocationConfig
#include <webserv/config/ServerConfig.hpp>
#include <webserv/config/utils.hpp>
#include <webserv/log/Log.hpp>
#include <sstream>
#include <string>
#include <webserv/config/utils.hpp> // for findCorrespondingClosingBrace, trim
#include <webserv/log/Log.hpp> // for Log, LOCATION
#include <stddef.h> // for size_t
#include <sstream> // for basic_istringstream, basic_istream, istringstream
#include <string> // for basic_string, char_traits, operator+, allocator, string, operator==, operator>>, operator<=>, to_string, stoi, getline
#include <stdexcept> // for runtime_error
#include <utility> // for pair
ServerConfig::ServerConfig(std::string const &serverBlock) : port_(80)
{

View File

@ -1,7 +1,6 @@
#pragma once
#include <webserv/config/LocationConfig.hpp>
#include <map>
#include <string>
#include <vector>

View File

@ -1,5 +1,4 @@
#include <webserv/config/utils.hpp>
#include <string>
std::string trim(const std::string &str)

View File

@ -1,6 +1,7 @@
#pragma once
#include <string>
#include <stddef.h> // for size_t
#include <string> // for string
std::string trimSemi(const std::string &str);
std::string trim(const std::string &str);

View File

@ -1,9 +1,11 @@
#include "webserv/http/HttpHeaders.hpp"
#include <webserv/config/utils.hpp> // for trim
#include <webserv/http/HttpConstants.hpp> // for CRLF
#include <webserv/http/HttpHeaders.hpp> // for HttpHeaders
#include "webserv/config/utils.hpp"
#include "webserv/http/HttpConstants.hpp"
#include <algorithm> // for __transform_fn, transform
#include <utility> // for pair
#include <algorithm>
#include <ctype.h> // for tolower
std::optional<size_t> HttpHeaders::getContentLength() const
{

View File

@ -1,8 +1,9 @@
#pragma once
#include <optional>
#include <string>
#include <unordered_map>
#include <stddef.h> // for size_t
#include <optional> // for optional
#include <string> // for basic_string, string, hash
#include <unordered_map> // for unordered_map
/**
* @file HttpHeaders.hpp

View File

@ -1,11 +1,12 @@
#include <webserv/client/Client.hpp>
#include <webserv/config/ServerConfig.hpp>
#include <webserv/http/HttpConstants.hpp>
#include <webserv/http/HttpConstants.hpp> // for CRLF, DOUBLE_CRLF
#include <webserv/http/HttpRequest.hpp>
#include <webserv/log/Log.hpp>
#include <webserv/log/Log.hpp> // for Log, LOCATION
#include <sstream> // for basic_stringstream, basic_istream, stringstream
#include <vector> // for vector
#include <exception> // for exception
#include <optional> // for optional, operator>
#include <sstream>
#include <vector>
class ServerConfig;
HttpRequest::HttpRequest(const ServerConfig *serverConfig, const Client *client)
: serverConfig_(serverConfig), client_(client)

View File

@ -1,14 +1,14 @@
#pragma once
#include "webserv/http/HttpHeaders.hpp"
#include <webserv/config/ServerConfig.hpp>
#include <webserv/http/HttpHeaders.hpp> // for HttpHeaders
#include <cstddef>
#include <cstdint>
#include <string>
#include <cstddef> // for size_t
#include <cstdint> // for uint8_t
#include <string> // for string, basic_string
class Client;
class ServerConfig;
class HttpRequest
{
@ -36,7 +36,9 @@ class HttpRequest
[[nodiscard]] const std::string &getBody() const;
[[nodiscard]] const std::string &getMethod() const { return method_; }
[[nodiscard]] const std::string &getTarget() const { return target_; }
[[nodiscard]] const std::string &getHttpVersion() const { return httpVersion_; }
void receiveData(const char *data, size_t length);

View File

@ -1,7 +1,7 @@
#include <webserv/log/Channel.hpp>
#include <iomanip>
#include <sstream>
#include <iomanip> // for operator<<, setfill, setw
#include <sstream> // for basic_ostream, operator<<, basic_stringstream, basic_istream, basic_istringstream, right, istringstream, stringstream
#include <utility> // for get
Log::Level Channel::getLogLevel() const
{

View File

@ -1,7 +1,6 @@
#pragma once
#include <webserv/log/Log.hpp>
#include <map>
#include <string>

View File

@ -1,10 +1,11 @@
#include <webserv/log/FileChannel.hpp>
#include <webserv/log/Log.hpp>
#include <webserv/log/Log.hpp> // for Log
#include <chrono> // for system_clock
#include <iostream> // for cerr
#include <iomanip> // for operator<<, put_time
#include <ctime> // for localtime, tm
#include <chrono>
#include <ios>
#include <iostream>
#include <iomanip>
struct tm;
FileChannel::FileChannel(const std::string &filename, std::ios_base::openmode mode, Log::Level logLevel)
: filename_(filename), fileStream_(filename, mode)

View File

@ -1,10 +1,11 @@
#pragma once
#include <webserv/log/Channel.hpp>
#include <webserv/log/Channel.hpp> // for Channel
#include <webserv/log/Log.hpp> // for Log
#include <fstream>
#include <map>
#include <string>
#include <fstream> // for basic_ofstream, ios_base, ofstream
#include <map> // for map
#include <string> // for string, basic_string
class FileChannel : public Channel
{

View File

@ -1,11 +1,13 @@
#include <webserv/log/FileChannel.hpp>
#include <webserv/log/Channel.hpp> // for Channel
#include <webserv/log/FileChannel.hpp> // for FileChannel
#include <webserv/log/Log.hpp>
#include <webserv/log/StdoutChannel.hpp>
#include <webserv/log/StdoutChannel.hpp> // for StdoutChannel
#include <chrono>
#include <filesystem>
#include <iostream>
#include <memory>
#include <chrono> // for duration_cast, operator-, steady_clock, duration, seconds
#include <exception> // for exception
#include <iostream> // for basic_ostream, operator<<, cerr
#include <memory> // for allocator, unique_ptr, make_unique
#include <utility> // for pair
Log::Log()
{

View File

@ -1,13 +1,14 @@
#pragma once
#include <array>
#include <chrono>
#include <cstring>
#include <map>
#include <memory>
#include <string>
#include <string_view>
#include <unordered_map>
#include <stdint.h> // for uint8_t
#include <array> // for array
#include <chrono> // for steady_clock
#include <map> // for map
#include <memory> // for unique_ptr
#include <string> // for string, basic_string, hash
#include <string_view> // for string_view
#include <unordered_map> // for unordered_map
#include <ios> // for ios_base
class Channel; // Forward declaration

View File

@ -1,11 +1,7 @@
#include <webserv/log/Channel.hpp>
#include <webserv/log/Log.hpp>
#include <webserv/log/Log.hpp> // for Log
#include <webserv/log/StdoutChannel.hpp>
#include <iomanip>
#include <iostream>
#include <map>
#include <ostream>
#include <iomanip> // for operator<<, setfill, setw
#include <iostream> // for basic_ostream, operator<<, basic_ostream::operator<<, cerr, cout, flush, ostream
StdoutChannel::StdoutChannel(Log::Level logLevel)
{

View File

@ -1,6 +1,10 @@
#pragma once
#include <webserv/log/Channel.hpp>
#include <webserv/log/Channel.hpp> // for Channel
#include <webserv/log/Log.hpp> // for Log
#include <map> // for map
#include <string> // for string, basic_string
class StdoutChannel : public Channel
{

View File

@ -1,11 +1,10 @@
#include <webserv/config/ConfigManager.hpp>
#include <webserv/config/LocationConfig.hpp>
#include <webserv/config/ServerConfig.hpp>
#include <webserv/log/Log.hpp>
#include <webserv/server/Server.hpp>
#include <iostream>
#include <string>
#include <webserv/config/ConfigManager.hpp> // for ConfigManager
#include <webserv/log/Log.hpp> // for Log, LOCATION
#include <webserv/server/Server.hpp> // for Server
#include <iostream> // for basic_ostream, operator<<, cerr, ios_base
#include <string> // for basic_string, char_traits, allocator, operator+, operator<=>
#include <map> // for map
#include <utility> // for pair
int main(int argc, char **argv)
{

View File

@ -1,17 +1,20 @@
#include <webserv/log/Log.hpp>
#include <webserv/log/Log.hpp> // for Log
#include <webserv/server/Server.hpp>
#include <webserv/socket/Socket.hpp>
#include <cstring> // For memset
#include <memory>
#include <vector>
#include <arpa/inet.h> // For inet_addr
#include <fcntl.h> // For fcntl()
#include <netinet/in.h> // For sockaddr_in
#include <sys/epoll.h>
#include <sys/socket.h> // For socket functions
#include <unistd.h> // For close()
#include <webserv/socket/Socket.hpp> // for Socket
#include <sys/epoll.h> // for epoll_event, epoll_ctl, EPOLLIN, EPOLLOUT, epoll_create1, epoll_wait, EPOLLERR, EPOLLHUP, EPOLL_CTL_ADD, EPOLL_CTL_DEL, EPOLL_CTL_MOD
#include <sys/socket.h> // for send, SOMAXCONN
#include <unistd.h> // for close
#include <errno.h> // for errno
#include <sys/types.h> // for ssize_t
#include <webserv/client/Client.hpp> // for Client
#include <webserv/config/ConfigManager.hpp> // for ConfigManager
#include <cstring> // for strerror, strlen
#include <memory> // for unique_ptr, allocator, make_unique
#include <vector> // for vector
#include <exception> // for exception
#include <stdexcept> // for runtime_error
#include <string> // for operator+, to_string, basic_string, char_traits, string
#include <utility> // for move, pair
Server::Server(const ConfigManager &configManager) : epoll_fd_(epoll_create1(0)), configManager_(configManager)
{

View File

@ -2,14 +2,18 @@
#include <webserv/client/Client.hpp>
#include <webserv/config/ConfigManager.hpp>
#include <webserv/config/ServerConfig.hpp>
#include <webserv/socket/Socket.hpp>
#include <webserv/config/ServerConfig.hpp> // for ServerConfig
#include <webserv/socket/Socket.hpp> // for Socket
#include <functional>
#include <memory>
#include <unordered_map>
#include <functional> // for reference_wrapper
#include <memory> // for unique_ptr
#include <unordered_map> // for unordered_map
#include <vector> // for vector
#include <stdint.h> // for uint32_t
class Client;
class ConfigManager;
class Server
{

View File

@ -1,14 +1,12 @@
#include <webserv/log/Log.hpp>
#include <webserv/socket/Socket.hpp>
#include <memory>
#include <stdexcept>
#include <arpa/inet.h> // For inet_addr
#include <fcntl.h> // For fcntl()"
#include <netinet/in.h> // For sockaddr_in
#include <sys/socket.h>
#include <unistd.h> // For close()
#include <memory>
#include <stdexcept>
Socket::Socket() : fd_(socket(AF_INET, SOCK_STREAM, 0))
{

View File

@ -1,9 +1,9 @@
#pragma once
#include <memory>
#include <string>
#include <sys/types.h>
#include <sys/types.h> // for ssize_t
#include <stddef.h> // for size_t
#include <memory> // for unique_ptr
#include <string> // for string
class Socket
{