Skip to content
rcutte edited this page Jun 9, 2024 · 5 revisions

Welcome to the WebServ wiki!

Resources


Web Server

A web server is server software, or hardware dedicated to running said software, that can satisfy client requests on the World Wide Web. A web server can, in general, contain one or more websites. A web server processes incoming network requests over HTTP and several other related protocols.

🎬 Web Server Concepts and Examples

HTTP Protocol

📖 STD 97 - RFC 9110 produced by Internet Engineering Task Force (IETF)

📚 HTTP Guides - MDN

Hypertext Transfer Protocol (HTTP) is an application-layer protocol for transmitting hypermedia documents, such as HTML. It was designed for communication between web browsers and web servers, but it can also be used for other purposes. HTTP follows a classical client-server model, with a client opening a connection to make a request, then waiting until it receives a response. HTTP is a stateless protocol, meaning that the server does not keep any data (state) between two requests.

HTTP Request/Response

HTTP Request

A request message from a client to a server includes, within the first line of that message, the method to be applied to the resource, the identifier of the resource, and the protocol version in use.

<HTTP Method> <URL Target> <HTTP Version>
<Header 1>: <Value>
<Header 2>: <Value>
...
<Header N>: <Value>

<Body>
POST /name HTTP/1.1
Host: 127.0.0.1:8000
User-Agent: browser
Content-Length: 9
Content-Type: application/x-www-form-urlencoded

name=John

HTTP Response

A response message from a server to a client includes, within the first line of that message, the protocol version being used, a status code, and a textual phrase conveying the status or error of the request.

<HTTP Version> <Status Code> <Status Phrase>
<Header 1>: <Value>
<Header 2>: <Value>
...
<Header N>: <Value>

<Body>
HTTP/1.1 200 OK
Content-Length: 113
Content-Type: text/html
Connection: Closed

<!DOCTYPE html>
<html>
<head>
    <title>WebServ</title>
</head>
<body>
    <h1>Hello, John!</h1>
</body>
</html>

HTTP Status Codes

Status codes are issued by a server in response to a client's request made to the server. They are part of the HTTP/1.1 standard defined by the Internet Engineering Task Force (IETF).

Category Description
1xx Informational: The request was received, continuing process
2xx Successful: The request was successfully received, understood, and accepted
3xx Redirection: Further action needs to be taken in order to complete the request
4xx Client Error: The request contains bad syntax or cannot be fulfilled
5xx Server Error: The server failed to fulfill an apparently valid request

Usefull Status Codes

Status Code Name Description
200 OK The request has succeeded.
201 Created The request has been fulfilled and has resulted in one or more new resources being created.
204 No Content The server has successfully fulfilled the request and there is no additional content to send in the response payload body.
301 Moved Permanently The target resource has been assigned a new permanent URI and any future references to this resource ought to use one of the enclosed URIs.
307 Temporary Redirect The target resource resides temporarily under a different URI.
400 Bad Request The server could not understand the request due to invalid syntax.
401 Unauthorized The request has not been applied because it lacks valid authentication credentials for the target resource.
403 Forbidden The server understood the request but refuses to authorize it.
404 Not Found The origin server did not find a current representation for the target resource or is not willing to disclose that one exists.
413 Payload Too Large The server is refusing to process a request because the request payload is larger than the server is willing or able to process.
500 Internal Server Error The server encountered an unexpected condition that prevented it from fulfilling the request.

Network Programming

📖 Guide to Network Programming Using Internet Sockets

Structuration

event loop, data structures for "requests" and "responses" and "configuration", and code to parse/generate those data structures...

Clone this wiki locally