0% found this document useful (0 votes)
6 views1 page

Webserv Request Flow

The document outlines the request flow for a web server, detailing various conditions and responses based on the Transfer-Encoding header, request URI, and HTTP methods. It specifies error codes such as 400 Bad Request, 404 Not Found, and 500 Internal Server Error, along with actions like redirection and CGI execution. The flow also includes checks for allowed characters in the request URI and directory indexing behavior.

Uploaded by

dynamicamine
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views1 page

Webserv Request Flow

The document outlines the request flow for a web server, detailing various conditions and responses based on the Transfer-Encoding header, request URI, and HTTP methods. It specifies error codes such as 400 Bad Request, 404 Not Found, and 500 Internal Server Error, along with actions like redirection and CGI execution. The flow also includes checks for allowed characters in the request URI and directory indexing behavior.

Uploaded by

dynamicamine
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

WEBSERV REQUEST FLOW

if =>

Transfer-Encoding header

exist and is different to “chunked”


Request 404 Not Found

501 Not Implemented RETURN

RETURN

Error

if =>

Transfer-Encoding not exist

Content-Length not exist


FALSE is_req_well_formed()
The method is Post if =>

you request uri doesn’t


if =>

Error
have “/” at the end this directory has

TRUE
an index file and cgi
400 Bad Request RETURN Not Found is_uri_has_/_in_end() Returtn Code Depend on cgi
FALSE RETURN
409 Conflict
RETURN
Error

if =>

Found
if =>
TRUE

Request uri contain


you request

a character not allowded get_resource_type()


a directory
RETURN
403 Forbidden
get_requested_resource()
Directory

400 Bad Request RETURN


run cgi on requested file

DELETE if_location_has_cgi() FALSE with DELTE REQUEST_METHOD

Error

if =>
FALSE TRUE TRUE RETURN
Request uri contain

more that 2048 chars


is_dir_has_index_files()

414 Request-URI Too Long RETURN

if=>

if =>
Delete Succes
Request body larger
File
RETURN
204 No Content
than client max body size

Error
RETURN
SUCESS

in config file delete_all_folder_content() Delete the file


if =>

RETURN
403 Forbidden requested location

doesn’t have cgi


413 Request Entity Too Large RETURN

has_write_acces_on_folder()

FALSE
FAILED

get_matched_location_for_request_uri()
if =>
TRUE FALSE

you request a file


RETURN
500 Internal Server Error

if =>
if =>

no location match
No Lcoation Found
TRUE requested location

the request uri has cgi


301 Moved Permanently
if_location_has_cgi()
404 Not Found RETURN
Location Found RETURN

is_location_have_redirection()
make a 301 redirection

to request uri with “/”

addeed at the end


if =>

if =>
you request uri doesn’t

location have redirection like:


have “/” at the end
return 301 /home/index.html TRUE

FALSE

301 Moved Permanently RETURN

201 Created FALSE


if =>

is_dir_has_index_files()
this directory does’t

RETURN
have an index file
uplaod the Post

Request Body TRUE FALSE RETURN


403 Forbidden
if =>

location support
is_uri_has_/_in_end()
if =>
is_method_allowded_in_location()
upload
method not allowded TRUE

405 Method Not Allowed RETURN

TRUE

FALSE
if =>
if =>

you request
this directory has

a directory
FALSE

an index file
TRUE
if =>
Returtn Code Depend on cgi
check_which_requested_method()
if_location_support_upload()
get_requested_resource() location has cgi run cgi on requested file

with POST REQUEST_METHOD

Directory TRUE

GET POST Found

if =>

requested resource
get_requested_resource()
not found in root Not Found

if_location_has_cgi()
FALSE RETURN
403 Forbidden
get_resource_type()

404 Not Found RETURN Not Found

if =>

Found
get_resource_type() location doesn’t have cgi
File

RETURN

Directory File

if =>
404 Not Found
is_uri_has_/_in_end()
you request a file if =>

you request a file


if =>

you request

a directory
make a 301 redirection
if =>
if =>

to request uri with “/”


you request uri doesn’t
if_location_has_cgi() location Doesn’t

addeed at the end have “/” at the end have cgi

301 Moved Permanently


TRUE
RETURN FALSE FALSE
is_dir_has_index_files()

TRUE
if =>

this directory has

RETURN
TRUE

an index file return requested file


FALSE Request The Start
get_auto_index()

if =>
200 OK
location have cgi
Allowded Chars in request uri
if =>
OFF

autoindex off
ON

run cgi on requested file

with GET REQUEST_METHOD


403 Forbidden RETURN
if =>
ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-._~:/?#[]@!$&'()*+,;=%
autoindex on RETURN

RETURN return autoindex

of the directory
Returtn Code Depend on cgi
200 OK

Made by: kirwa-KO https://github.com/kirwa-KO

You might also like