diff --git a/README.md b/README.md index 074ff2c..db65285 100644 --- a/README.md +++ b/README.md @@ -1,19 +1,4 @@ ---- -## questions -- mettre les fonctions specifiques a la requete, dans la class client ? -- où est-ce que j'inclus le cgi ? -- est-ce que le cgi est appellé par `/cgi-bin` ? - - non -- g rajouté `char ** env` dans client.cpp - - non -- ajouter un champ "message body" dans client ? - - non -- comment organiser la creation du message reponse (cgi ou pas) et des headers ? -- comment je gere le path `/cgi-bin/` avec la suite ? -- qu'est-ce que le cgi renvoit comme headers ? comment c'est géré ? - - https://www.rfc-editor.org/rfc/rfc3875 - --- ## man @@ -88,30 +73,83 @@ - [ ] Your server must be able to listen to multiple ports (see Configuration file) - [ ] Your server should never die. - --- ## cgi rfc [rfc 3875](https://www.rfc-editor.org/rfc/rfc3875) -[server responsabilities](https://www.rfc-editor.org/rfc/rfc3875#section-3.1) +[3.1: server responsabilities](https://www.rfc-editor.org/rfc/rfc3875#section-3.1) - The server [...] receives the request from the client - selects a CGI script to handle the request - converts the client request to a CGI request - executes the script and converts the CGI response into a response for the client -[script uri](https://www.rfc-editor.org/rfc/rfc3875#section-3.3) +[3.3: script uri](https://www.rfc-editor.org/rfc/rfc3875#section-3.3) - the 'Script-URI' [...] MUST have the property that if the client had accessed this URI instead, then the script would have been executed +[4: how the server prepare the cgi requests](https://www.rfc-editor.org/rfc/rfc3875#section-4) +- the cgi receives 2 differents set of informations : + - the request meta-variables, + - and the message-body + +[4.1: request meta-variables](https://www.rfc-editor.org/rfc/rfc3875#section-4.1) +- a header field that spans multiple lines MUST be merged onto a single line + +[4.2: request message-body](https://www.rfc-editor.org/rfc/rfc3875#section-4.2) +- unless defined otherwise, the script access request data by reading stdin + +[6: how the response from the script is returned to the server](https://www.rfc-editor.org/rfc/rfc3875#section-6) +- The response comprises 2 parts, separated by a blank line : + - a message-header + - and a message-body +- The message-header contains one or more header fields +- The body may be NULL + +[6.2: responses types](https://www.rfc-editor.org/rfc/rfc3875#section-6.2) +- four types of responses : + - document response + - local redirect response + - client redirect response + - client redirect response with document +- document response : + - it must return a Content-Type header field + - a Status-Header field is optional (200 is assumed if omited) + - the server must check the cgi-script output, and modifie it to comply with the protocol version +- local redirect response : + - it must return only a Location field + - it contains a local path URI and query string ('local-pathquery') + - the server must generate the response for this local-pathquery +- client redirect response : + - it must return only a Location field + - it contains an absolute URI path, to indicate the client that it should reprocess the request with this URI + - the http server must generate a 302 'Found' message +- client redirect response with document + - it must return a Location field with an absolute URI path + - it must return the Status header field, with a value of 302 'Found' + - the server must check the cgi-script output, and modifie it to comply with the protocol version + +[6.3: cgi header fields](https://www.rfc-editor.org/rfc/rfc3875#section-6.3) +- whitespace is permitted between the ":" and the field-value +- but not between the field-name and the ":" +- the CGI script can set three differents fields : + - Content-Type + - Location + - Status +- Content-Type : + - if there is a body in the response, a Content-Type field must be present + - if there is no Content-Type, the server must not attempt to determine one +- Location : + +- Status : --- ## cgi env variables -[cgi env variables](http://www.faqs.org/rfcs/rfc3875.html) +[cgi env variables](https://www.rfc-editor.org/rfc/rfc3875#section-4.1) [wikipedia variables environnements cgi](https://fr.wikipedia.org/wiki/Variables_d%27environnement_CGI) [cgi server variables on adobe](https://helpx.adobe.com/coldfusion/cfml-reference/reserved-words-and-variables/cgi-environment-cgi-scope-variables/cgi-server-variables.html) ``` AUTH_TYPE : if the srcipt is protected, the authentification method used to validate the user -CONTENT_LENGTH : length of the request content -CONTENT_TYPE : if there is attached information, as with method POST or PUT, this is the content type of the data (e.g. "text/plain", it is set by the attribute "enctype" in html