From 7ef2c371b8eb9e9266ea2a3efd1c797f14c9f7bd Mon Sep 17 00:00:00 2001 From: ritchie Date: Fri, 18 Dec 2015 08:04:22 +0100 Subject: [PATCH] documentation updated #266 --- README.md | 68 +++++++++++++++++++------------------- src/site/markdown/index.md | 68 +++++++++++++++++++------------------- 2 files changed, 68 insertions(+), 68 deletions(-) diff --git a/README.md b/README.md index 2fc43869..5b264a4c 100644 --- a/README.md +++ b/README.md @@ -34,41 +34,41 @@ Edit `pom.xml`, and add this between \: Edit `src/main/java/com/example/App.java` and replace it with: ```java -package com.example; - -import java.util.Map; -import java.io.IOException; -import fi.iki.elonen.NanoHTTPD; - -public class App extends NanoHTTPD { - - public App() throws IOException { - super(8080); - start(); - System.out.println( "\nRunning! Point your browers to http://localhost:8080/ \n" ); - } - - public static void main(String[] args) { - try { - new App(); - } - catch( IOException ioe ) { - System.err.println( "Couldn't start server:\n" + ioe ); - } - } - - @Override - public Response serve(IHTTPSession session) { - String msg = "

Hello server

\n"; - Map parms = session.getParms(); - if (parms.get("username") == null) { - msg += "
\n

Your name:

\n" + "
\n"; - } else { - msg += "

Hello, " + parms.get("username") + "!

"; + package com.example; + + import java.io.IOException; + import java.util.Map; + + import fi.iki.elonen.NanoHTTPD; + + public class App extends NanoHTTPD { + + public App() throws IOException { + super(8080); + start(NanoHTTPD.SOCKET_READ_TIMEOUT, false); + System.out.println("\nRunning! Point your browers to http://localhost:8080/ \n"); + } + + public static void main(String[] args) { + try { + new App(); + } catch (IOException ioe) { + System.err.println("Couldn't start server:\n" + ioe); + } + } + + @Override + public Response serve(IHTTPSession session) { + String msg = "

Hello server

\n"; + Map parms = session.getParms(); + if (parms.get("username") == null) { + msg += "
\n

Your name:

\n" + "
\n"; + } else { + msg += "

Hello, " + parms.get("username") + "!

"; + } + return newFixedLengthResponse(msg + "\n"); } - return newFixedLengthResponse( msg + "\n" ); } -} ``` Compile and run the server: @@ -243,7 +243,7 @@ Just a hint how to generate a certificate for localhost. This will generate a keystore file named 'keystore.jks' with a self signed certificate for a host named localhost with the ip adress 127.0.0.1 . Now you can use: - server.makeSecure(NanoHTTPD.makeSSLSocketFactory("/keystore.jks", "password".toCharArray())); + server.makeSecure(NanoHTTPD.makeSSLSocketFactory("/keystore.jks", "password".toCharArray()), null); Before you start the server to make Nanohttpd serve https connections, when you make sure 'keystore.jks' is in your classpath . diff --git a/src/site/markdown/index.md b/src/site/markdown/index.md index 1a78b2a0..b435b11c 100644 --- a/src/site/markdown/index.md +++ b/src/site/markdown/index.md @@ -34,41 +34,41 @@ Edit `pom.xml`, and add this between \: Edit `src/main/java/com/example/App.java` and replace it with: ```java -package com.example; - -import java.util.Map; -import java.io.IOException; -import fi.iki.elonen.NanoHTTPD; - -public class App extends NanoHTTPD { - - public App() throws IOException { - super(8080); - start(); - System.out.println( "\nRunning! Point your browers to http://localhost:8080/ \n" ); - } - - public static void main(String[] args) { - try { - new App(); - } - catch( IOException ioe ) { - System.err.println( "Couldn't start server:\n" + ioe ); - } - } - - @Override - public Response serve(IHTTPSession session) { - String msg = "

Hello server

\n"; - Map parms = session.getParms(); - if (parms.get("username") == null) { - msg += "
\n

Your name:

\n" + "
\n"; - } else { - msg += "

Hello, " + parms.get("username") + "!

"; + package com.example; + + import java.io.IOException; + import java.util.Map; + + import fi.iki.elonen.NanoHTTPD; + + public class App extends NanoHTTPD { + + public App() throws IOException { + super(8080); + start(NanoHTTPD.SOCKET_READ_TIMEOUT, false); + System.out.println("\nRunning! Point your browers to http://localhost:8080/ \n"); + } + + public static void main(String[] args) { + try { + new App(); + } catch (IOException ioe) { + System.err.println("Couldn't start server:\n" + ioe); + } + } + + @Override + public Response serve(IHTTPSession session) { + String msg = "

Hello server

\n"; + Map parms = session.getParms(); + if (parms.get("username") == null) { + msg += "
\n

Your name:

\n" + "
\n"; + } else { + msg += "

Hello, " + parms.get("username") + "!

"; + } + return newFixedLengthResponse(msg + "\n"); } - return newFixedLengthResponse( msg + "\n" ); } -} ``` Compile and run the server: @@ -239,7 +239,7 @@ Just a hint how to generate a certificate for localhost. This will generate a keystore file named 'keystore.jks' with a self signed certificate for a host named localhost with the ip adress 127.0.0.1 . Now you can use: - server.makeSecure(NanoHTTPD.makeSSLSocketFactory("/keystore.jks", "password".toCharArray())); + server.makeSecure(NanoHTTPD.makeSSLSocketFactory("/keystore.jks", "password".toCharArray()), null); Before you start the server to make Nanohttpd serve https connections, when you make sure 'keystore.jks' is in your classpath .