commit | 79f7c96a8ad15f0928be085e54f948303275cffa | [log] [tgz] |
---|---|---|
author | Digital Rounin <[email protected]> | Tue Sep 03 19:13:28 2013 +0700 |
committer | Digital Rounin <[email protected]> | Tue Sep 03 19:13:28 2013 +0700 |
tree | 07615fe69a50aab25cdf71570c63aa084f40b6c6 | |
parent | 868d807d8d6c0dcd63963ad40b9f10971eb459d9 [diff] |
Ignore Vim/Vi backup & swap files Have Git ignore Vim/Vi backup & swap files.
NanoHttpd is a light-weight HTTP server designed for embedding in other applications.
NanoHttpd has been released under a Modified BSD licence.
Please take a look at the new “ssl-support” branch containing submitted code adding SSL support to NanoHttpd. It's a great new feature that needs all eyes to polish in preparation for a release, making sure it works on all platforms.
index.html
and index.htm
./
.The project is managed with a “fork and pull-request” pattern.
If you want to contribute, fork this repo and submit a pull-request of your changes when you're ready.
Anyone can create Issues, and pull requests should be tied back to an issue describing the purpose of the submitted code.
In an ideal world for a bug fix: write a test of your own that fails as a result of the bug being present. Then fix the bug so that your unit-test passes. The test will now be a guard against the bug ever coming back.
Similarly for enhancements, exercise your code with tests.
Whatever else happens, if you make changes to the code, the unit & integration test suite (under core/src/main/test/
) should all continue to function. Pull requests with broken tests will be rejected.
The original (Java 1.1 project) and the Java 6 project merged in early 2013 to pool resources around “NanoHttpd” as a whole, regardless of flavor. Development of the Java 1.1 version continues as a permanent branch (“nanohttpd-for-java1.1”) in the main http://github.com/NanoHttpd/nanohttpd repository.
Firstly take a look at the “samples” sub-module. The sample code illustrates using NanoHttpd in various ways.
Secondly, you can run the standalone NanoHttpd Webserver.
Or, create your own class that extends NanoHTTPD
and overrides one of the two flavors of the serve()
method. For example:
public class DebugServer extends NanoHTTPD { /** * Constructs an HTTP server on given port. */ public DebugServer() { super(8080); } @Override public Response serve(String uri, Method method, Map<String, String> header, Map<String, String> parms, Map<String, String> files) { StringBuilder sb = new StringBuilder(); sb.append("<html>"); sb.append("<head><title>Debug Server</title></head>"); sb.append("<body>"); sb.append("<h1>Response</h1>"); sb.append("<p><blockquote><b>URI -</b> ").append(uri).append("<br />"); sb.append("<b>Method -</b> ").append(method).append("</blockquote></p>"); sb.append("<h3>Headers</h3><p><blockquote>").append(header).append("</blockquote></p>"); sb.append("<h3>Parms</h3><p><blockquote>").append(parms).append("</blockquote></p>"); sb.append("<h3>Files</h3><p><blockquote>").append(files).append("</blockquote></p>"); sb.append("</body>"); sb.append("</html>"); return new Response(sb.toString()); } public static void main(String[] args) { ServerRunner.run(DebugServer.class); } }
The Java 6 version of nanohttpd was born when we realized that embedding Jetty inside our Android application was going to inflate the size without bringing along features that we were going to need. The search for a smaller more streamlined HTTP server lead us to nanohttpd as the project had started with exactly the same goals, but we wanted to clear up the old code - move from Java 1.1, run static code analysis tools and cleanup the findings and pull out sample/test code from the source.
In the words of the original founder of the project
I couldn't find a small enough, embeddable and easily modifiable HTTP server that I could just copy and paste into my other Java projects. Every one of them consisted of dozens of .java files and/or jars, usually with - from my point of view - “overkill features” like servlet support, web administration, configuration files, logging etc.
Since that time we fixed a number of bugs, moved the build to maven and pulled out the samples from the runtime JAR to further slim it down.
The two projects pooled resources in early 2013, merging code-bases, to better support the user base and reduce confusion over why two NanoHttpd projects existed.
http://nanohttpd.com - went live July 1st, 2013.
Thank you to everyone who has reported bugs and suggested fixes.