Skip to content

Commit

Permalink
Merge pull request #77
Browse files Browse the repository at this point in the history
feat/bind-and-listen
  • Loading branch information
0bvim authored Nov 15, 2024
2 parents b94579d + feeb154 commit 2327b4f
Show file tree
Hide file tree
Showing 53 changed files with 965 additions and 2,574 deletions.
18 changes: 0 additions & 18 deletions .gdb_history

This file was deleted.

34 changes: 34 additions & 0 deletions .github/workflows/feature.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: Feature CI

on:
push:
branches: [feature/*]
pull_request:
branches: [main, develop]

jobs:
feature-ci:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Set up C++ environment
uses: aminya/setup-cpp@v1

# start test coverage using this tool or gcov
- name: Install gcovr
run: sudo apt-get install -y gcovr

- name: Compile Webserv
run: make

- name: Run Code
run: |
make run &
SERVER_PID=$!
sleep 3
- name: Stop Webserv
run: kill -SIGINT $SERVER_PID || true
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,6 @@
bin/
build/
webserv
.idea


43 changes: 0 additions & 43 deletions .vscode/launch.json

This file was deleted.

76 changes: 0 additions & 76 deletions .vscode/settings.json

This file was deleted.

30 changes: 0 additions & 30 deletions CMakeLists.txt

This file was deleted.

8 changes: 3 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ SRC_DIR := src
BUILD_DIR := build
TESTS_DIR := tests

SRCS := $(wildcard $(SRC_DIR)/*.cpp)
SRCS := $(shell find $(SRC_DIR) -name "*.cpp")
OBJS := $(patsubst $(SRC_DIR)/%.cpp, $(BUILD_DIR)/%.o, $(SRCS))
NAME := webserv

Expand All @@ -23,6 +23,7 @@ $(NAME): $(OBJS)
$(CXX) $(CXXFLAGS) -o $@ $^

$(BUILD_DIR)/%.o: $(SRC_DIR)/%.cpp | $(BUILD_DIR)
@mkdir -p $(dir $@)
$(CXX) $(CXXFLAGS) -c -o $@ $<

$(BUILD_DIR):
Expand All @@ -38,7 +39,4 @@ re: fclean all
@echo "Rebuilding..."

run: all
@./$(NAME) default.conf

run2: all
@./$(NAME) arquivo.conf
@./$(NAME) config/default.conf
39 changes: 39 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,41 @@
# webserv
This is when you finally understand why a URL starts with HTTP


```mermaid
flowchart TD
A[Introduction to HTTP] --> B[Overview of HTTP server]
B --> C[Primary function of a web server]
C --> D[Request/Response model]
D --> E[Role of client and server]
A1[General rules] --> F[Program Stability]
F --> G[No crashing or unexpected quit]
F --> H[Makefile structure]
F --> I[Use C++ 98 standard]
F --> J[Forbidden libraries]
A2[Mandatory Part] --> K[Program name: webserv]
K --> L[HTTP server in C++ 98]
L --> M[Command to run: ./webserv config_file]
L --> N[Requirements]
N --> O[Non-blocking I/O using poll or equivalent]
N --> P[Configuration file handling]
N --> Q[GET, POST, DELETE methods support]
N --> R[Serve static content]
N --> S[Handle file uploads]
N --> T[Multiple ports support]
A3[For MacOS only] --> U[Use of fcntl]
A4[Configuration File] --> V[Define server host and port]
V --> W[Set up server_names]
W --> X[Configure routes for files]
X --> Y[Enable CGI execution]
X --> Z[Handle uploads and directory listing]
A5[Bonus Part] --> AA[Support cookies and session management]
AA --> AB[Handle multiple CGI scripts]
A6[Submission and Peer Evaluation] --> AC[Submit via Git repository]
```
60 changes: 0 additions & 60 deletions arquivo.conf

This file was deleted.

36 changes: 36 additions & 0 deletions config/default.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
server {
host 127.0.0.1;
port 8080;
server_names example.com www.example.com;
client_max_size 10M;

error_pages {
404 /errors/404.html;
500 /errors/500.html;
}

location / {
methods GET POST DELETE;
root /var/www/html;
directory_list on;
index index.html;
client_max_size 20M;

cgi {
extension .php;
path /usr/bin/php-cgi;
}

upload {
path /var/www/uploads;
max_size 5M;
}
}

location /redirect {
redirect {
code 301;
url /new-location;
}
}
}
File renamed without changes.
Loading

0 comments on commit 2327b4f

Please sign in to comment.