Http-server: Difference between revisions

From NovaOrdis Knowledge Base
Jump to navigation Jump to search
 
(18 intermediate revisions by the same user not shown)
Line 5: Line 5:
=Overview=
=Overview=


A simple, multithreaded experimental web server. Developed to experiment with the behavior of user agents and proxies.
An experimental multithreaded HTTP/1.1 (RFC 2616) web server. Developed to experiment with the behavior of user agents and proxies.


The server registers itself with the JVM as an MBean, so it can be managed via a standard JMX client such as [[VisualVM]] or [[JConsole]].
The server registers itself with the JVM as an MBean, as "novaordis:service=http-server", so it can be managed via a standard JMX client such as [[VisualVM]] or [[Jconsole|JConsole]].


=GitHub=
=GitHub=
Line 20: Line 20:


The document-root is optional, it will sever the current directory if not specified.
The document-root is optional, it will sever the current directory if not specified.
=Features=
* The server assumes HTTP/1.1 ''persistent connections'', as described in [[HTTP Persistent Connections]]. The server can be configured to close the connection after the initial request/response sequence by specifying "persistent-connection=false" on the command line.
* The server registers itself with the JVM's platform MBeanServer as "novaordis:service=http-server".
* The "listConnections()" JMX management operation lists the active connections and the closed connections, giving information such as remote and local address, creation timestamp, time alive, User-Agent, etc.
* The server has an "Echo" handler that parses the request and responds according to the request configuration: by default it responds to any URL with 200 OK.
** If the request contains "<tt>code=<http-response-status-code></tt>" among its query parameters, the handler generates a response with the requested status code.
** If the request contains "<tt>length=<number-of-bytes></tt>" among its query parameters, the handler generates a random text body of the specified length. Otherwise it generates a conventional short body ("SYNTHETIC 200 OK").
** The handler can also introduce delays in processing of a request, if delay=<delay-in-ms> is specified on the server's command line or the request contains "<tt>delay=<delay-in-ms></tt>" query parameter. The command line "delay" configuration is the default value,  and it will be overridden by on a request by request basis, if the request contains the query parameter. Example: <tt><nowiki>http://localhost:10000/?delay=2000</nowiki></tt>. This request handler is useful to simulate long running requests. A "delayed" request can be released at any time by invoking the <tt>releaseDelayedRequest()</tt> JMX method.

Latest revision as of 00:09, 10 January 2017

Internal

Overview

An experimental multithreaded HTTP/1.1 (RFC 2616) web server. Developed to experiment with the behavior of user agents and proxies.

The server registers itself with the JVM as an MBean, as "novaordis:service=http-server", so it can be managed via a standard JMX client such as VisualVM or JConsole.

GitHub

https://github.com/NovaOrdis/playground/tree/master/http/http-server

Run

./bin/http-server <port> [document-root]

The document-root is optional, it will sever the current directory if not specified.

Features

  • The server assumes HTTP/1.1 persistent connections, as described in HTTP Persistent Connections. The server can be configured to close the connection after the initial request/response sequence by specifying "persistent-connection=false" on the command line.
  • The server registers itself with the JVM's platform MBeanServer as "novaordis:service=http-server".
  • The "listConnections()" JMX management operation lists the active connections and the closed connections, giving information such as remote and local address, creation timestamp, time alive, User-Agent, etc.
  • The server has an "Echo" handler that parses the request and responds according to the request configuration: by default it responds to any URL with 200 OK.
    • If the request contains "code=<http-response-status-code>" among its query parameters, the handler generates a response with the requested status code.
    • If the request contains "length=<number-of-bytes>" among its query parameters, the handler generates a random text body of the specified length. Otherwise it generates a conventional short body ("SYNTHETIC 200 OK").
    • The handler can also introduce delays in processing of a request, if delay=<delay-in-ms> is specified on the server's command line or the request contains "delay=<delay-in-ms>" query parameter. The command line "delay" configuration is the default value, and it will be overridden by on a request by request basis, if the request contains the query parameter. Example: http://localhost:10000/?delay=2000. This request handler is useful to simulate long running requests. A "delayed" request can be released at any time by invoking the releaseDelayedRequest() JMX method.