The Apache HTTP Server Project is an effort to develop and maintain anopen-source HTTP server for modern operating systems including UNIX andWindows. The goal of this project is to provide a secure, efficient andextensible server that provides HTTP services in sync with the current HTTPstandards.
http-server is a simple, zero-configuration command-line static HTTP server. It is powerful enough for production usage, but it's simple and hackable enough to be used for testing, local development and learning.
download hfs http file server
Download Zip
https://t.co/8BDjVdXZ6E
This class is used to handle the HTTP requests that arrive at the server. Byitself, it cannot respond to any actual HTTP requests; it must be subclassedto handle each request method (e.g. GET or POST).BaseHTTPRequestHandler provides a number of class and instancevariables, and methods for use by subclasses.
Holds an instance of the class specified by the MessageClass classvariable. This instance parses and manages the headers in the HTTPrequest. The parse_headers() function fromhttp.client is used to parse the headers and it requires that theHTTP request provide a valid RFC 2822 style header.
When an HTTP/1.1 conformant server receives an Expect: 100-continuerequest header it responds back with a 100 Continue followed by 200OK headers.This method can be overridden to raise an error if the server does notwant the client to continue. For e.g. server can choose to send 417Expectation Failed as a response header and return False.
Adds a response header to the headers buffer and logs the acceptedrequest. The HTTP response line is written to the internal buffer,followed by Server and Date headers. The values for these two headersare picked up from the version_string() anddate_time_string() methods, respectively. If the server does notintend to send any other headers using the send_header() method,then send_response() should be followed by an end_headers()call.
Sends the response header only, used for the purposes when 100Continue response is sent by the server to the client. The headers notbuffered and sent directly the output stream.If the message is notspecified, the HTTP message corresponding the response code is sent.
By default, the server binds itself to all interfaces. The option -b/--bindspecifies a specific address to which it should bind. Both IPv4 and IPv6addresses are supported. For example, the following command causes the serverto bind to localhost only:
By default, the server is conformant to HTTP/1.0. The option -p/--protocolspecifies the HTTP version to which the server is conformant. For example, thefollowing command runs an HTTP/1.1 conformant server:
Earlier versions of Python did not scrub control characters from thelog messages emitted to stderr from python -m http.server or thedefault BaseHTTPRequestHandler .log_messageimplementation. This could allow remote clients connecting to yourserver to send nefarious control codes to your terminal.
Pooled connections have TCP Keep-Alive enabled for them, but servers maystill close idle connections, in which case they will be removed from thepool and a new connection will be made when a new HTTP request is made forthat host and port. Servers may also refuse to allow multiple requestsover the same connection, in which case the connection will have to beremade for every request and cannot be pooled. The Agent will still makethe requests to that server, but each one will occur over a new connection.
When a connection is closed by the client or the server, it is removedfrom the pool. Any unused sockets in the pool will be unrefed so as notto keep the Node.js process running when there are no outstanding requests.(see socket.unref()).
An agent may also be used for an individual request. By providingagent: false as an option to the http.get() or http.request()functions, a one-time use Agent with default options will be usedfor the client connection.
It is usually not necessary to do this. However, if using anagent with keepAlive enabled, then it is best to explicitly shut downthe agent when it is no longer needed. Otherwise,sockets might stay open for quite a long time before the serverterminates them.
This object is created internally and returned from http.request(). Itrepresents an in-progress request whose header has already been queued. Theheader is still mutable using the setHeader(name, value),getHeader(name), removeHeader(name) API. The actual header willbe sent along with the first data chunk or when calling request.end().
To get the response, add a listener for 'response' to the request object.'response' will be emitted from the request object when the responseheaders have been received. The 'response' event is executed with oneargument which is an instance of http.IncomingMessage.
Emitted when the request has been sent. More specifically, this event is emittedwhen the last segment of the response headers and body have been handed off tothe operating system for transmission over the network. It does not imply thatthe server has received anything yet.
Emitted when the server sends a 1xx intermediate response (excluding 101Upgrade). The listeners of this event will receive an object containing theHTTP version, status code, status message, key-value headers object,and array with the raw header names followed by their respective values.
Emitted each time a server responds to a request with an upgrade. If thisevent is not being listened for and the response status code is 101 SwitchingProtocols, clients receiving an upgrade header will have their connectionsclosed.
Returns a shallow copy of the current outgoing headers. Since a shallow copyis used, array values may be mutated without additional calls to variousheader-related http module methods. The keys of the returned object are theheader names and the values are the respective header values. All header namesare lowercase.
Sends a chunk of the body. This method can be called multiple times. If noContent-Length is set, data will automatically be encoded in HTTP Chunkedtransfer encoding, so that server knows when the data ends. TheTransfer-Encoding: chunked header is added. Calling request.end()is necessary to finish sending the request.
Emitted each time a request with an HTTP Expect header is received, where thevalue is not 100-continue. If this event is not listened for, the server willautomatically respond with a 417 Expectation Failed as appropriate.
Default behavior is to try close the socket with a HTTP '400 Bad Request',or a HTTP '431 Request Header Fields Too Large' in the case of aHPE_HEADER_OVERFLOW error. If the socket is not writable or headersof the current attached http.ServerResponse has been sent, it isimmediately destroyed.
The number of milliseconds of inactivity a server needs to wait for additionalincoming data, after it has finished writing the last response, before a socketwill be destroyed. If the server receives new data before the keep-alivetimeout has fired, it will reset the regular inactivity timeout, i.e.,server.timeout.
A value of 0 will disable the keep-alive timeout behavior on incomingconnections.A value of 0 makes the http server behave similarly to Node.js versions priorto 8.0.0, which did not have a keep-alive timeout.
This method signals to the server that all of the response headers and bodyhave been sent; that server should consider this message complete.The method, response.end(), MUST be called on each response.
If no 'timeout' listener is added to the request, the response, orthe server, then sockets are destroyed when they time out. If a handler isassigned to the request, the response, or the server's 'timeout' events,timed out sockets must be handled explicitly.
An IncomingMessage object is created by http.Server orhttp.ClientRequest and passed as the first argument to the 'request'and 'response' event respectively. It may be used to access responsestatus, headers, and data.
The joinDuplicateHeaders option in the http.request() and http.createServer() functions ensures that duplicate headers are not discarded, but rather combined using a comma separator, in accordance with RFC 9110 Section 5.3.
Depending of the value of options.uniqueHeaders when the client request or theserver were created, this will end up in the header being sent multiple times ora single time with values joined using ; .
Since most requests are GET requests without bodies, Node.js provides thisconvenience method. The only difference between this method andhttp.request() is that it sets the method to GET by default and calls req.end()automatically. The callback must take care to consume the responsedata for reasons stated in http.ClientRequest section.
http.request() returns an instance of the http.ClientRequestclass. The ClientRequest instance is a writable stream. If one needs toupload a file with a POST request, then write to the ClientRequest object.
A web server is computer software and underlying hardware that accepts requests via HTTP (the network protocol created to distribute web content) or its secure variant HTTPS. A user agent, commonly a web browser or web crawler, initiates communication by making a request for a web page or other resource using HTTP, and the server responds with the content of that resource or an error message. A web server can also accept and store resources sent from the user agent if configured to do so.[1][2]
The hardware used to run a web server can vary according to the volume of requests that it needs to handle. At the low end of the range are embedded systems, such as a router that runs a small web server as its configuration interface. A high-traffic Internet website might handle requests with hundreds of servers that run on racks of high-speed computers.
35fe9a5643