add class Header

This commit is contained in:
Talyx
2022-01-07 21:07:37 +03:00
parent 61ed01b849
commit 08c490813a
6 changed files with 170 additions and 65 deletions

42
includes/Header.hpp Normal file
View File

@@ -0,0 +1,42 @@
#ifndef HEADER
# define HEADER
#include "webserv.hpp"
class Header
{
private:
int _type;
int _row;
char *_buff;
// std::string _respons;
std::string _fileName;
std::vector<std::string> _request;
public:
enum REQ
{
GET,
POST,
DELETE
};
public:
std::vector<std::string> getRequest(void);
// std::string getRespons(void);
int getType(void);
std::string getFileName(void);
void setFile(std::string);
void setRequest(char *);
// void generateRespons(void);
void parseBuff(void);
void identifyType(std::string);
void printHeaderInfo(void);
Header();
Header(char *);
~Header();
};
#endif

View File

@@ -5,6 +5,8 @@
#define BUFFSIZE 1024
class Header;
class Server
{
private:
@@ -18,13 +20,8 @@ private:
private:
void checkError(int fd, std::string str);
void sendFile(std::string str);
void sendHeader(void);
void printRed(std::string str);
void printYellow(std::string str);
void printBlue(std::string str);
void printPink(std::string str);
void printGreen(std::string str);
void printTurguoise(std::string str);
void sendHeader(Header head);
void sendRespons(Header head);
public:
Server();

View File

@@ -1,6 +1,16 @@
#ifndef WEBSERV_HPP
#define WEBSERV_HPP
#define RED "\033[31m"
#define GREEN "\033[32m"
#define YELLOW "\033[33m"
#define BLUE "\033[34m"
#define PINK "\033[35m"
#define TURGUOISE "\033[36m"
#define ZERO_C "\033[0m"
#define HOME "www"
#include <iostream>
#include <string>
#include <arpa/inet.h>
@@ -12,8 +22,11 @@
#include <netinet/in.h>
#include <fcntl.h>
#include <unistd.h>
#include "Server.hpp"
#include <stdlib.h>
#include <fstream>
#include <vector>
#include <sstream>
#include "Server.hpp"
#include "Header.hpp"
#endif