Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
Web server
(section)
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
=== Manage request message === Once a request has been read, interpreted, and verified, it has to be managed depending on its method, its URL, and its parameters, which may include values of HTTP headers. In practice, the web server has to handle the request by using one of these response paths:<ref name="ws-static-rqs-root-dir" /> * if something in request was not acceptable (in status line or message headers), web server already sent an error response; * if request has a method (e.g. <code>OPTIONS</code>) that can be satisfied by general code of web server then a successful response is sent; * if URL requires authorization then an [[#URL authorization|authorization error message]] is sent; * if URL maps to a redirection then a [[#URL redirection|redirect message]] is sent; * if URL maps to a [[#Serve dynamic content|dynamic resource]] (a virtual path or a directory listing) then its handler (an internal module or an external program) is called and request parameters (query string and path info) are passed to it in order to allow it to reply to that request; * if URL maps to a [[#Serve static content|static resource]] (usually a file on file system) then the internal static handler is called to send that file; * if request method is not known or if there is some other unacceptable condition (e.g. resource not found, internal server error, etc.) then an [[#Error message|error response]] is sent. ==== Serve static content ==== [[File:Web server serving static content.png|thumb|221x144px|right|PC clients communicating via network with a web server serving static content only]] If a web server program is capable of '''serving static content''' and it has been configured to do so, then it is able to send file content whenever a request message has a valid URL path matching (after URL mapping, URL translation and URL redirection) that of an existing file under the root directory of a website and file has attributes which match those required by internal rules of web server program.<ref name="ws-static-rqs-root-dir" /> That kind of content is called ''static'' because usually it is not changed by the web server when it is sent to clients and because it remains the same until it is modified (file modification) by some program. NOTE: when serving '''static content only''', a web server program usually '''does not change file contents''' of served websites (as they are only read and never written) and so it suffices to support only these [[HTTP method]]s: * <code>OPTIONS</code> * <code>HEAD</code> * <code>GET</code> Response of static file content can be sped up by a '''[[#File cache|file cache]]'''. ===== Directory index files ===== {{Main|Web server directory index}} If a web server program receives a client request message with an URL whose path matches one of an existing ''directory'' and that directory is accessible and serving directory index file(s) is enabled then a web server program may try to serve the first of known (or configured) static index file names (a [[#Regular files|regular file]]) found in that directory; if no index file is found or other conditions are not met then an error message is returned. Most used names for static index files are: <code>index.html</code>, <code>index.htm</code> and <code>Default.htm</code>. ===== Regular files ===== If a web server program receives a client request message with an URL whose path matches the file name of an existing ''file'' and that file is accessible by web server program and its attributes match internal rules of web server program, then web server program can send that file to client. Usually, for security reasons, most web server programs are pre-configured to serve only [[regular file]]s or to avoid to use ''special file types'' like [[device file]]s, along with [[symbolic link]]s or [[hard link]]s to them. The aim is to avoid undesirable side effects when serving static web resources.<ref name="web-server-http">{{Cite book|url=https://books.google.com/books?id=oxg8_i9dVakC&pg=PA38|title=HTTP developer's handbook|author=Chris Shiflett|year=2003|access-date=2021-12-09|language=en|publisher=Sams's publishing|isbn=0-672-32454-7|archive-date=20 January 2023|archive-url=https://web.archive.org/web/20230120185219/https://www.google.it/books/edition/HTTP_Developer_s_Handbook/oxg8_i9dVakC?hl=en&gbpv=1&pg=PA38&printsec=frontcover|url-status=live}}</ref> ==== Serve dynamic content ==== [[File:Web server serving static and dynamic content.png|thumb|221x144px|right|PC clients communicating via network with a web server serving static and dynamic content]] If a web server program is capable of '''serving dynamic content''' and it has been configured to do so, then it is able to communicate with the proper internal module or external program (associated with the requested URL path) in order to pass to it the parameters of the client request. After that, the web server program reads from it its data response (that it has generated, often on the fly) and then it resends it to the client program who made the request.{{citation needed|date=November 2021}} NOTE: when serving '''static and dynamic content''', a web server program usually has to support also the following HTTP method in order to be able to safely '''receive data''' from client(s) and so to be able to host also websites with interactive form(s) that may send large data sets (e.g. lots of [[data entry]] or [[file upload]]s) to web server / external programs / modules: * <code>POST</code> In order to be able to communicate with its internal modules and/or external programs, a web server program must have implemented one or more of the many available '''gateway interface(s)''' (see also [[#StandardCGIs|Web Server Gateway Interfaces used for dynamic content]]). The three '''standard''' and historical '''gateway interfaces''' are the following ones. ; [[Common Gateway Interface|CGI]] : An external CGI program is run by web server program for each dynamic request, then web server program reads from it the generated data response and then resends it to client. ; [[Simple Common Gateway Interface|SCGI]] : An external SCGI program (it usually is a process) is started once by web server program or by some other program / process and then it waits for network connections; every time there is a new request for it, web server program makes a new network connection to it in order to send request parameters and to read its data response, then network connection is closed. ; [[FastCGI]] : An external FastCGI program (it usually is a process) is started once by web server program or by some other program / process and then it waits for a network connection which is established permanently by web server; through that connection are sent the request parameters and read data responses. ===== Directory listings ===== [[File:Web server directory list.png|thumb|271x161px|right|Directory listing dynamically generated by a web server]] {{Main|Web server directory index}} A web server program may be capable to manage the dynamic generation (on the fly) of a '''[[Web server directory index|directory index list]]''' of files and sub-directories.<ref name="ws-directory-listings">{{Cite web|url=https://cwiki.apache.org/confluence/display/HTTPD/DirectoryListings|title=Directory listings|author=ASF Infrabot|publisher=Apache foundation: HTTPd server project|date=2019-05-22|access-date=2021-11-16|language=en|archive-date=7 June 2019|archive-url=https://web.archive.org/web/20190607234544/https://cwiki.apache.org/confluence/display/HTTPD/DirectoryListings|url-status=live}}</ref> If a web server program is configured to do so and a requested URL path matches an existing directory and its access is allowed and no static index file is found under that directory then a web page (usually in HTML format), containing the list of files and/or subdirectories of above mentioned directory, is ''dynamically generated'' (on the fly). If it cannot be generated an error is returned. Some web server programs allow the customization of directory listings by allowing the usage of a web page template (an HTML document containing placeholders, e.g. <code>$(FILE_NAME), $(FILE_SIZE)</code>, etc., that are replaced with the field values of each file entry found in directory by web server), e.g. <code>index.tpl</code> or the usage of HTML and embedded source code that is interpreted and executed on the fly, e.g. <code>index.asp</code>, and / or by supporting the usage of dynamic index programs such as CGIs, SCGIs, FCGIs, e.g. <code>index.cgi</code>, <code>index.php</code>, <code>index.fcgi</code>. Usage of dynamically generated ''directory listings'' is usually avoided or limited to a few selected directories of a website because that generation takes much more OS resources than sending a static index page. The main usage of ''directory listings'' is to allow the download of files (usually when their names, sizes, modification date-times or [[file attribute]]s may change randomly / frequently) ''as they are, without requiring to provide further information to requesting user''.<ref name="ws-apache-dir">{{Cite web|url=https://archive.apache.org/dist/httpd/|title=Apache: directory listing to download files|author=|publisher=Apache: HTTPd server|access-date=2021-12-16|archive-date=2 December 2021|archive-url=https://web.archive.org/web/20211202004258/http://archive.apache.org/dist/httpd/|url-status=live}}</ref> ===== Program or module processing ===== An external program or an internal module (''processing unit'') can execute some sort of application function that may be used to get data from or to store data to one or more [[Content repository|data repositories]], e.g.:{{citation needed|date=November 2021}} * files (file system); * [[database]]s (DBs); * other sources located in local computer or in other computers. A ''processing unit'' can return any kind of web content, also by using data retrieved from a data repository, e.g.:{{citation needed|date=November 2021}} * a document (e.g. [[HTML]], [[XML]], etc.); * an image; * a video; * structured data, e.g. that may be used to update one or more values displayed by a dynamic page ([[DHTML]]) of a [[web interface]] and that maybe was requested by an [[XMLHttpRequest]] [[API]] (see also: [[Dynamic web page|dynamic page]]). In practice whenever there is content that may vary, depending on one or more parameters contained in client request or in configuration settings, then, usually, it is generated dynamically.
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)