diff options
author | Daniel Erat <derat@google.com> | 2016-01-06 20:30:14 +0000 |
---|---|---|
committer | android-build-merger <android-build-merger@google.com> | 2016-01-06 20:30:14 +0000 |
commit | c6783c32331b3fe78ffd5077e7f180995d0e268e (patch) | |
tree | 84fa0e646ffc9ec82311f00a8bd8f0831d54dd14 /samples | |
parent | 48e7e363b22de734efa9ca2bdb0d02976a432918 (diff) | |
parent | f47b11cc8e8e27f27d1772c18f09135a948dd59f (diff) | |
download | nanohttpd-nougat-mr2-release.tar.gz |
Integrate upstream changes to 2.2.0.android-wear-p-preview-2android-wear-o-preview-4android-wear-o-preview-3android-wear-9.0.0_r9android-wear-9.0.0_r8android-wear-9.0.0_r7android-wear-9.0.0_r6android-wear-9.0.0_r5android-wear-9.0.0_r4android-wear-9.0.0_r34android-wear-9.0.0_r33android-wear-9.0.0_r32android-wear-9.0.0_r31android-wear-9.0.0_r30android-wear-9.0.0_r3android-wear-9.0.0_r29android-wear-9.0.0_r28android-wear-9.0.0_r27android-wear-9.0.0_r26android-wear-9.0.0_r25android-wear-9.0.0_r24android-wear-9.0.0_r23android-wear-9.0.0_r22android-wear-9.0.0_r21android-wear-9.0.0_r20android-wear-9.0.0_r2android-wear-9.0.0_r19android-wear-9.0.0_r18android-wear-9.0.0_r17android-wear-9.0.0_r16android-wear-9.0.0_r15android-wear-9.0.0_r14android-wear-9.0.0_r13android-wear-9.0.0_r12android-wear-9.0.0_r11android-wear-9.0.0_r10android-wear-9.0.0_r1android-wear-8.1.0_r1android-wear-8.0.0_r2android-wear-8.0.0_r1android-vts-9.0_r9android-vts-9.0_r8android-vts-9.0_r7android-vts-9.0_r6android-vts-9.0_r5android-vts-9.0_r4android-vts-9.0_r19android-vts-9.0_r18android-vts-9.0_r17android-vts-9.0_r16android-vts-9.0_r15android-vts-9.0_r14android-vts-9.0_r13android-vts-9.0_r12android-vts-9.0_r11android-vts-9.0_r10android-vts-8.1_r9android-vts-8.1_r8android-vts-8.1_r7android-vts-8.1_r6android-vts-8.1_r5android-vts-8.1_r4android-vts-8.1_r3android-vts-8.1_r14android-vts-8.1_r13android-vts-8.1_r12android-vts-8.1_r11android-vts-8.1_r10android-vts-8.0_r9android-vts-8.0_r8android-vts-8.0_r7android-vts-8.0_r6android-vts-8.0_r2android-vts-8.0_r13android-vts-8.0_r12android-vts-8.0_r11android-vts-8.0_r10android-vts-8.0_r1android-security-9.0.0_r76android-security-9.0.0_r75android-security-9.0.0_r74android-security-9.0.0_r73android-security-9.0.0_r72android-security-9.0.0_r71android-security-9.0.0_r70android-security-9.0.0_r69android-security-9.0.0_r68android-security-9.0.0_r67android-security-9.0.0_r66android-security-9.0.0_r65android-security-9.0.0_r64android-security-9.0.0_r63android-security-9.0.0_r62android-security-8.1.0_r93android-security-8.1.0_r92android-security-8.1.0_r91android-security-8.1.0_r90android-security-8.1.0_r89android-security-8.1.0_r88android-security-8.1.0_r87android-security-8.1.0_r86android-security-8.1.0_r85android-security-8.1.0_r84android-security-8.1.0_r83android-security-8.1.0_r82android-security-8.0.0_r54android-security-8.0.0_r53android-security-8.0.0_r52android-p-preview-5android-p-preview-4android-p-preview-3android-p-preview-2android-p-preview-1android-o-preview-4android-o-preview-3android-o-preview-2android-o-preview-1android-o-mr1-preview-2android-o-mr1-preview-1android-o-mr1-iot-release-smart-display-r9android-o-mr1-iot-release-smart-display-r8android-o-mr1-iot-release-smart-display-r5android-o-mr1-iot-release-smart-display-r40.1Jandroid-o-mr1-iot-release-smart-display-r4android-o-mr1-iot-release-smart-display-r39android-o-mr1-iot-release-smart-display-r30android-o-mr1-iot-release-smart-display-r3android-o-mr1-iot-release-smart-display-r22android-o-mr1-iot-release-smart-display-r14android-o-mr1-iot-release-smart-clock-r6android-o-mr1-iot-release-smart-clock-r2android-o-mr1-iot-release-smart-clock-fsiandroid-o-mr1-iot-release-smart-clock-fcsandroid-o-mr1-iot-release-cube_r2android-o-mr1-iot-release-cube-fsiandroid-o-mr1-iot-release-cube-fcsandroid-o-mr1-iot-release-1.0.8android-o-mr1-iot-release-1.0.7android-o-mr1-iot-release-1.0.5android-o-mr1-iot-release-1.0.4android-o-mr1-iot-release-1.0.3android-o-mr1-iot-release-1.0.2android-o-mr1-iot-release-1.0.1android-o-mr1-iot-release-1.0.0android-o-mr1-iot-preview-8android-o-mr1-iot-preview-7android-o-mr1-iot-preview-6android-o-iot-preview-5android-n-mr2-preview-2android-n-mr2-preview-1android-n-mr1-preview-2android-n-mr1-preview-1android-n-iot-release-smart-display-r2android-n-iot-release-smart-displayandroid-n-iot-release-polk-at1android-n-iot-release-lg-thinq-wk7android-n-iot-release-ihome-igv1android-n-iot-preview-4android-cts_7.1_r1android-cts-9.0_r9android-cts-9.0_r8android-cts-9.0_r7android-cts-9.0_r6android-cts-9.0_r5android-cts-9.0_r4android-cts-9.0_r3android-cts-9.0_r20android-cts-9.0_r2android-cts-9.0_r19android-cts-9.0_r18android-cts-9.0_r17android-cts-9.0_r16android-cts-9.0_r15android-cts-9.0_r14android-cts-9.0_r13android-cts-9.0_r12android-cts-9.0_r11android-cts-9.0_r10android-cts-9.0_r1android-cts-8.1_r9android-cts-8.1_r8android-cts-8.1_r7android-cts-8.1_r6android-cts-8.1_r5android-cts-8.1_r4android-cts-8.1_r3android-cts-8.1_r25android-cts-8.1_r24android-cts-8.1_r23android-cts-8.1_r22android-cts-8.1_r21android-cts-8.1_r20android-cts-8.1_r2android-cts-8.1_r19android-cts-8.1_r18android-cts-8.1_r17android-cts-8.1_r16android-cts-8.1_r15android-cts-8.1_r14android-cts-8.1_r13android-cts-8.1_r12android-cts-8.1_r11android-cts-8.1_r10android-cts-8.1_r1android-cts-8.0_r9android-cts-8.0_r8android-cts-8.0_r7android-cts-8.0_r6android-cts-8.0_r5android-cts-8.0_r4android-cts-8.0_r3android-cts-8.0_r26android-cts-8.0_r25android-cts-8.0_r24android-cts-8.0_r23android-cts-8.0_r22android-cts-8.0_r21android-cts-8.0_r20android-cts-8.0_r2android-cts-8.0_r19android-cts-8.0_r18android-cts-8.0_r17android-cts-8.0_r16android-cts-8.0_r15android-cts-8.0_r14android-cts-8.0_r13android-cts-8.0_r12android-cts-8.0_r11android-cts-8.0_r10android-cts-8.0_r1android-cts-7.1_r9android-cts-7.1_r8android-cts-7.1_r7android-cts-7.1_r6android-cts-7.1_r5android-cts-7.1_r4android-cts-7.1_r3android-cts-7.1_r29android-cts-7.1_r28android-cts-7.1_r27android-cts-7.1_r26android-cts-7.1_r25android-cts-7.1_r24android-cts-7.1_r23android-cts-7.1_r22android-cts-7.1_r21android-cts-7.1_r20android-cts-7.1_r2android-cts-7.1_r19android-cts-7.1_r18android-cts-7.1_r17android-cts-7.1_r16android-cts-7.1_r15android-cts-7.1_r14android-cts-7.1_r13android-cts-7.1_r12android-cts-7.1_r11android-cts-7.1_r10android-cts-7.1_r1android-cts-7.0_r9android-cts-7.0_r8android-cts-7.0_r7android-cts-7.0_r6android-cts-7.0_r5android-cts-7.0_r4android-cts-7.0_r33android-cts-7.0_r32android-cts-7.0_r31android-cts-7.0_r30android-cts-7.0_r3android-cts-7.0_r29android-cts-7.0_r28android-cts-7.0_r27android-cts-7.0_r26android-cts-7.0_r25android-cts-7.0_r24android-cts-7.0_r23android-cts-7.0_r22android-cts-7.0_r21android-cts-7.0_r20android-cts-7.0_r2android-cts-7.0_r19android-cts-7.0_r18android-cts-7.0_r17android-cts-7.0_r16android-cts-7.0_r15android-cts-7.0_r14android-cts-7.0_r13android-cts-7.0_r12android-cts-7.0_r11android-cts-7.0_r10android-cts-7.0_r1android-9.0.0_r9android-9.0.0_r8android-9.0.0_r7android-9.0.0_r61android-9.0.0_r60android-9.0.0_r6android-9.0.0_r59android-9.0.0_r58android-9.0.0_r57android-9.0.0_r56android-9.0.0_r55android-9.0.0_r54android-9.0.0_r53android-9.0.0_r52android-9.0.0_r51android-9.0.0_r50android-9.0.0_r5android-9.0.0_r49android-9.0.0_r48android-9.0.0_r47android-9.0.0_r46android-9.0.0_r45android-9.0.0_r44android-9.0.0_r43android-9.0.0_r42android-9.0.0_r41android-9.0.0_r40android-9.0.0_r39android-9.0.0_r38android-9.0.0_r37android-9.0.0_r36android-9.0.0_r35android-9.0.0_r34android-9.0.0_r33android-9.0.0_r32android-9.0.0_r31android-9.0.0_r30android-9.0.0_r3android-9.0.0_r22android-9.0.0_r21android-9.0.0_r20android-9.0.0_r2android-9.0.0_r19android-9.0.0_r18android-9.0.0_r17android-9.0.0_r16android-9.0.0_r12android-9.0.0_r11android-9.0.0_r10android-9.0.0_r1android-8.1.0_r9android-8.1.0_r81android-8.1.0_r80android-8.1.0_r8android-8.1.0_r79android-8.1.0_r78android-8.1.0_r77android-8.1.0_r76android-8.1.0_r75android-8.1.0_r74android-8.1.0_r73android-8.1.0_r72android-8.1.0_r71android-8.1.0_r70android-8.1.0_r7android-8.1.0_r69android-8.1.0_r68android-8.1.0_r67android-8.1.0_r66android-8.1.0_r65android-8.1.0_r64android-8.1.0_r63android-8.1.0_r62android-8.1.0_r61android-8.1.0_r60android-8.1.0_r6android-8.1.0_r53android-8.1.0_r52android-8.1.0_r51android-8.1.0_r50android-8.1.0_r5android-8.1.0_r48android-8.1.0_r47android-8.1.0_r46android-8.1.0_r45android-8.1.0_r43android-8.1.0_r42android-8.1.0_r41android-8.1.0_r40android-8.1.0_r4android-8.1.0_r39android-8.1.0_r38android-8.1.0_r37android-8.1.0_r36android-8.1.0_r35android-8.1.0_r33android-8.1.0_r32android-8.1.0_r31android-8.1.0_r30android-8.1.0_r3android-8.1.0_r29android-8.1.0_r28android-8.1.0_r27android-8.1.0_r26android-8.1.0_r25android-8.1.0_r23android-8.1.0_r22android-8.1.0_r21android-8.1.0_r20android-8.1.0_r2android-8.1.0_r19android-8.1.0_r18android-8.1.0_r17android-8.1.0_r16android-8.1.0_r15android-8.1.0_r14android-8.1.0_r13android-8.1.0_r12android-8.1.0_r11android-8.1.0_r10android-8.1.0_r1android-8.0.0_r9android-8.0.0_r7android-8.0.0_r51android-8.0.0_r50android-8.0.0_r49android-8.0.0_r48android-8.0.0_r47android-8.0.0_r46android-8.0.0_r45android-8.0.0_r44android-8.0.0_r43android-8.0.0_r42android-8.0.0_r41android-8.0.0_r40android-8.0.0_r4android-8.0.0_r39android-8.0.0_r38android-8.0.0_r37android-8.0.0_r36android-8.0.0_r35android-8.0.0_r34android-8.0.0_r33android-8.0.0_r32android-8.0.0_r31android-8.0.0_r30android-8.0.0_r3android-8.0.0_r29android-8.0.0_r28android-8.0.0_r27android-8.0.0_r26android-8.0.0_r25android-8.0.0_r24android-8.0.0_r23android-8.0.0_r22android-8.0.0_r21android-8.0.0_r2android-8.0.0_r17android-8.0.0_r16android-8.0.0_r15android-8.0.0_r13android-8.0.0_r12android-8.0.0_r11android-8.0.0_r10android-8.0.0_r1android-7.1.2_r9android-7.1.2_r8android-7.1.2_r6android-7.1.2_r5android-7.1.2_r4android-7.1.2_r39android-7.1.2_r38android-7.1.2_r37android-7.1.2_r36android-7.1.2_r33android-7.1.2_r32android-7.1.2_r30android-7.1.2_r3android-7.1.2_r29android-7.1.2_r28android-7.1.2_r27android-7.1.2_r25android-7.1.2_r24android-7.1.2_r23android-7.1.2_r2android-7.1.2_r19android-7.1.2_r18android-7.1.2_r17android-7.1.2_r16android-7.1.2_r15android-7.1.2_r14android-7.1.2_r13android-7.1.2_r12android-7.1.2_r11android-7.1.2_r10android-7.1.2_r1android-7.1.1_r9android-7.1.1_r8android-7.1.1_r7android-7.1.1_r61android-7.1.1_r60android-7.1.1_r6android-7.1.1_r59android-7.1.1_r58android-7.1.1_r57android-7.1.1_r56android-7.1.1_r55android-7.1.1_r54android-7.1.1_r53android-7.1.1_r52android-7.1.1_r51android-7.1.1_r50android-7.1.1_r49android-7.1.1_r48android-7.1.1_r47android-7.1.1_r46android-7.1.1_r45android-7.1.1_r44android-7.1.1_r43android-7.1.1_r42android-7.1.1_r41android-7.1.1_r40android-7.1.1_r4android-7.1.1_r39android-7.1.1_r38android-7.1.1_r35android-7.1.1_r33android-7.1.1_r32android-7.1.1_r31android-7.1.1_r3android-7.1.1_r28android-7.1.1_r27android-7.1.1_r26android-7.1.1_r25android-7.1.1_r24android-7.1.1_r23android-7.1.1_r22android-7.1.1_r21android-7.1.1_r20android-7.1.1_r2android-7.1.1_r17android-7.1.1_r16android-7.1.1_r15android-7.1.1_r14android-7.1.1_r13android-7.1.1_r12android-7.1.1_r11android-7.1.1_r10android-7.1.1_r1android-7.1.0_r7android-7.1.0_r6android-7.1.0_r5android-7.1.0_r4android-7.1.0_r3android-7.1.0_r2android-7.1.0_r1android-7.0.0_r9android-7.0.0_r8android-7.0.0_r7android-7.0.0_r6android-7.0.0_r5android-7.0.0_r4android-7.0.0_r36android-7.0.0_r35android-7.0.0_r34android-7.0.0_r33android-7.0.0_r32android-7.0.0_r31android-7.0.0_r30android-7.0.0_r3android-7.0.0_r29android-7.0.0_r28android-7.0.0_r27android-7.0.0_r24android-7.0.0_r21android-7.0.0_r19android-7.0.0_r17android-7.0.0_r15android-7.0.0_r14android-7.0.0_r13android-7.0.0_r12android-7.0.0_r11android-7.0.0_r10android-7.0.0_r1security-pi-releasesecurity-oc-releasesecurity-oc-mr1-releasepie-vts-releasepie-security-releasepie-s2-releasepie-release-2pie-releasepie-r2-s2-releasepie-r2-s1-releasepie-r2-releasepie-qpr3-s1-releasepie-qpr3-releasepie-qpr3-b-releasepie-qpr2-releasepie-qpr1-s3-releasepie-qpr1-s2-releasepie-qpr1-s1-releasepie-qpr1-releasepie-platform-releasepie-gsipie-dr1-releasepie-dr1-devpie-devpie-cuttlefish-testingpie-cts-releasepie-b4s4-releasepie-b4s4-devoreo-vts-releaseoreo-security-releaseoreo-releaseoreo-r6-releaseoreo-r5-releaseoreo-r4-releaseoreo-r3-releaseoreo-r2-releaseoreo-mr1-wear-releaseoreo-mr1-vts-releaseoreo-mr1-security-releaseoreo-mr1-s1-releaseoreo-mr1-releaseoreo-mr1-devoreo-mr1-cuttlefish-testingoreo-mr1-cts-releaseoreo-mr1-1.2-iot-releaseoreo-m8-releaseoreo-m7-releaseoreo-m6-s4-releaseoreo-m6-s3-releaseoreo-m6-s2-releaseoreo-m5-releaseoreo-m4-s9-releaseoreo-m4-s8-releaseoreo-m4-s7-releaseoreo-m4-s6-releaseoreo-m4-s5-releaseoreo-m4-s4-releaseoreo-m4-s3-releaseoreo-m4-s2-releaseoreo-m4-s12-releaseoreo-m4-s11-releaseoreo-m4-s10-releaseoreo-m4-s1-releaseoreo-m3-releaseoreo-m2-s5-releaseoreo-m2-s4-releaseoreo-m2-s3-releaseoreo-m2-s2-releaseoreo-m2-s1-releaseoreo-m2-releaseoreo-dr3-releaseoreo-dr2-releaseoreo-dr1-releaseoreo-dr1-devoreo-devoreo-cts-releaseo-previewo-mr1-iot-preview-8o-mr1-iot-preview-7o-mr1-iot-preview-6o-iot-preview-5nougat-releasenougat-mr2.3-releasenougat-mr2.2-releasenougat-mr2.1-releasenougat-mr2-security-releasenougat-mr2-releasenougat-mr2-pixel-releasenougat-mr2-devnougat-mr1.8-releasenougat-mr1.7-releasenougat-mr1.6-releasenougat-mr1.5-releasenougat-mr1.4-releasenougat-mr1.3-releasenougat-mr1.2-releasenougat-mr1.1-releasenougat-mr1-volantis-releasenougat-mr1-security-releasenougat-mr1-releasenougat-mr1-flounder-releasenougat-mr1-devnougat-mr1-cts-releasenougat-mr0.5-releasenougat-iot-releasenougat-dr1-releasenougat-devnougat-cts-releasenougat-bugfix-releasen-iot-preview-4master-cuttlefish-testing-release
am: f47b11cc8e
* commit 'f47b11cc8e8e27f27d1772c18f09135a948dd59f': (179 commits)
[maven-release-plugin] prepare release nanohttpd-project-2.2.0
added some descriptions to the pom
code formating #253
add a gradle dependecy description #222
Decode headers before write remote-addr
Rename NanoWebSocketServer to NanoWSD.
attempt to fix the test
Detached the WebSocket from the Server: It makes more sense if each socket knows how to handle itself.
Updated WebSocket class to handle itself in an overridable manner.
Added more tests; all coverage checks are met now.
Added SSLServerSocketFactoryTest; Fixed non-static classes and wrong return.
read the encode request header exact fix #240
Added ServerSocketFactory JUnit test
encoded multipart requests #240
little imp correction and more test coverage #243
Fix: strange compilation error
Unit test - NanoHttpd throws an exception if temp directory doesn't exist #243
Fix: Issue #243 : NanoHttpd throws an exception if temp directory doesn't exist #243
Allows WebSocket servers to easily override default HTTP behavior.
Fix content-length not being parsed as long
...
Diffstat (limited to 'samples')
-rw-r--r-- | samples/.gitignore | 2 | ||||
-rw-r--r-- | samples/pom.xml | 100 | ||||
-rw-r--r-- | samples/src/main/java/fi/iki/elonen/HelloServer.java | 68 | ||||
-rw-r--r-- | samples/src/main/java/fi/iki/elonen/TempFilesServer.java | 101 | ||||
-rw-r--r-- | samples/src/main/java/fi/iki/elonen/debug/DebugServer.java | 79 | ||||
-rw-r--r-- | samples/src/site/site.xml | 41 |
6 files changed, 246 insertions, 145 deletions
diff --git a/samples/.gitignore b/samples/.gitignore new file mode 100644 index 0000000..868a6b2 --- /dev/null +++ b/samples/.gitignore @@ -0,0 +1,2 @@ +/.settings/ +/LICENSE.txt diff --git a/samples/pom.xml b/samples/pom.xml index a32b07b..63e8f7b 100644 --- a/samples/pom.xml +++ b/samples/pom.xml @@ -1,75 +1,27 @@ -<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> - <modelVersion>4.0.0</modelVersion> - - <groupId>fi.iki.elonen</groupId> - <artifactId>nanohttpd-samples</artifactId> - <version>2.1.0</version> - <packaging>jar</packaging> - - <name>NanoHttpd-Samples</name> - <url>https://github.com/NanoHttpd/nanohttpd</url> - - <dependencies> - <dependency> - <groupId>fi.iki.elonen</groupId> - <artifactId>nanohttpd</artifactId> - <version>2.1.0</version> - </dependency> - <dependency> - <groupId>fi.iki.elonen</groupId> - <artifactId>nanohttpd-webserver</artifactId> - <version>2.1.0</version> - </dependency> - </dependencies> - - <build> - <extensions> - <extension> - <groupId>org.jvnet.wagon-svn</groupId> - <artifactId>wagon-svn</artifactId> - <version>1.8</version> - </extension> - <extension> - <groupId>org.apache.maven.wagon</groupId> - <artifactId>wagon-ftp</artifactId> - <version>1.0-alpha-6</version> - </extension> - </extensions> - - <plugins> - <plugin> - <groupId>org.apache.maven.plugins</groupId> - <artifactId>maven-source-plugin</artifactId> - <version>2.2.1</version> - <executions> - <execution> - <id>attach-sources</id> - <goals> - <goal>jar</goal> - </goals> - </execution> - </executions> - </plugin> - <plugin> - <groupId>org.apache.maven.plugins</groupId> - <artifactId>maven-release-plugin</artifactId> - <version>2.4</version> - </plugin> - <plugin> - <groupId>org.apache.maven.plugins</groupId> - <artifactId>maven-javadoc-plugin</artifactId> - <version>2.9</version> - </plugin> - <plugin> - <groupId>org.apache.maven.plugins</groupId> - <artifactId>maven-compiler-plugin</artifactId> - <version>2.3.1</version> - <configuration> - <source>1.6</source> - <target>1.6</target> - </configuration> - </plugin> - </plugins> - </build> +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + <modelVersion>4.0.0</modelVersion> + <parent> + <groupId>org.nanohttpd</groupId> + <artifactId>nanohttpd-project</artifactId> + <version>2.2.0</version> + </parent> + <artifactId>nanohttpd-samples</artifactId> + <description>samples for nanohttpd</description> + <packaging>jar</packaging> + <name>NanoHttpd-Samples</name> + <dependencies> + <dependency> + <groupId>${project.groupId}</groupId> + <artifactId>nanohttpd</artifactId> + <version>${project.version}</version> + </dependency> + <dependency> + <groupId>${project.groupId}</groupId> + <artifactId>nanohttpd-webserver</artifactId> + <version>${project.version}</version> + </dependency> + </dependencies> + <properties> + <minimal.coverage>0.0</minimal.coverage> + </properties> </project> diff --git a/samples/src/main/java/fi/iki/elonen/HelloServer.java b/samples/src/main/java/fi/iki/elonen/HelloServer.java index c7c7da4..bc91231 100644 --- a/samples/src/main/java/fi/iki/elonen/HelloServer.java +++ b/samples/src/main/java/fi/iki/elonen/HelloServer.java @@ -1,37 +1,77 @@ package fi.iki.elonen; +/* + * #%L + * NanoHttpd-Samples + * %% + * Copyright (C) 2012 - 2015 nanohttpd + * %% + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * 3. Neither the name of the nanohttpd nor the names of its contributors + * may be used to endorse or promote products derived from this software without + * specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, + * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE + * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + * #L% + */ + import java.util.Map; +import java.util.logging.Logger; + +import fi.iki.elonen.util.ServerRunner; /** * An example of subclassing NanoHTTPD to make a custom HTTP server. */ public class HelloServer extends NanoHTTPD { + + /** + * logger to log to. + */ + private static final Logger LOG = Logger.getLogger(HelloServer.class.getName()); + + public static void main(String[] args) { + ServerRunner.run(HelloServer.class); + } + public HelloServer() { super(8080); } - @Override public Response serve(IHTTPSession session) { + @Override + public Response serve(IHTTPSession session) { Method method = session.getMethod(); String uri = session.getUri(); - System.out.println(method + " '" + uri + "' "); + HelloServer.LOG.info(method + " '" + uri + "' "); String msg = "<html><body><h1>Hello server</h1>\n"; Map<String, String> parms = session.getParms(); - if (parms.get("username") == null) - msg += - "<form action='?' method='get'>\n" + - " <p>Your name: <input type='text' name='username'></p>\n" + - "</form>\n"; - else + if (parms.get("username") == null) { + msg += "<form action='?' method='get'>\n" + " <p>Your name: <input type='text' name='username'></p>\n" + "</form>\n"; + } else { msg += "<p>Hello, " + parms.get("username") + "!</p>"; + } msg += "</body></html>\n"; - return new NanoHTTPD.Response(msg); - } - - - public static void main(String[] args) { - ServerRunner.run(HelloServer.class); + return newFixedLengthResponse(msg); } } diff --git a/samples/src/main/java/fi/iki/elonen/TempFilesServer.java b/samples/src/main/java/fi/iki/elonen/TempFilesServer.java index fb96911..964f2b2 100644 --- a/samples/src/main/java/fi/iki/elonen/TempFilesServer.java +++ b/samples/src/main/java/fi/iki/elonen/TempFilesServer.java @@ -1,57 +1,96 @@ package fi.iki.elonen; -import fi.iki.elonen.debug.DebugServer; +/* + * #%L + * NanoHttpd-Samples + * %% + * Copyright (C) 2012 - 2015 nanohttpd + * %% + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * 3. Neither the name of the nanohttpd nor the names of its contributors + * may be used to endorse or promote products derived from this software without + * specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, + * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE + * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + * #L% + */ +import java.io.File; import java.util.ArrayList; import java.util.List; +import fi.iki.elonen.debug.DebugServer; +import fi.iki.elonen.util.ServerRunner; + /** - * @author Paul S. Hawke (paul.hawke@gmail.com) - * On: 3/9/13 at 12:47 AM + * @author Paul S. Hawke (paul.hawke@gmail.com) On: 3/9/13 at 12:47 AM */ public class TempFilesServer extends DebugServer { - public static void main(String[] args) { - TempFilesServer server = new TempFilesServer(); - server.setTempFileManagerFactory(new ExampleManagerFactory()); - ServerRunner.executeInstance(server); - } - - private static class ExampleManagerFactory implements TempFileManagerFactory { - @Override - public TempFileManager create() { - return new ExampleManager(); - } - } private static class ExampleManager implements TempFileManager { - private final String tmpdir; + + private final File tmpdir; + private final List<TempFile> tempFiles; private ExampleManager() { - tmpdir = System.getProperty("java.io.tmpdir"); - tempFiles = new ArrayList<TempFile>(); - } - - @Override - public TempFile createTempFile() throws Exception { - DefaultTempFile tempFile = new DefaultTempFile(tmpdir); - tempFiles.add(tempFile); - System.out.println("Created tempFile: " + tempFile.getName()); - return tempFile; + this.tmpdir = new File(System.getProperty("java.io.tmpdir")); + this.tempFiles = new ArrayList<TempFile>(); } @Override public void clear() { - if (!tempFiles.isEmpty()) { + if (!this.tempFiles.isEmpty()) { System.out.println("Cleaning up:"); } - for (TempFile file : tempFiles) { + for (TempFile file : this.tempFiles) { try { - System.out.println(" "+file.getName()); + System.out.println(" " + file.getName()); file.delete(); - } catch (Exception ignored) {} + } catch (Exception ignored) { + } } - tempFiles.clear(); + this.tempFiles.clear(); } + + @Override + public TempFile createTempFile(String filename_hint) throws Exception { + DefaultTempFile tempFile = new DefaultTempFile(this.tmpdir); + this.tempFiles.add(tempFile); + System.out.println("Created tempFile: " + tempFile.getName()); + return tempFile; + } + } + + private static class ExampleManagerFactory implements TempFileManagerFactory { + + @Override + public TempFileManager create() { + return new ExampleManager(); + } + } + + public static void main(String[] args) { + TempFilesServer server = new TempFilesServer(); + server.setTempFileManagerFactory(new ExampleManagerFactory()); + ServerRunner.executeInstance(server); } } diff --git a/samples/src/main/java/fi/iki/elonen/debug/DebugServer.java b/samples/src/main/java/fi/iki/elonen/debug/DebugServer.java index 1c83876..0ffc34f 100644 --- a/samples/src/main/java/fi/iki/elonen/debug/DebugServer.java +++ b/samples/src/main/java/fi/iki/elonen/debug/DebugServer.java @@ -1,24 +1,62 @@ package fi.iki.elonen.debug; -import fi.iki.elonen.NanoHTTPD; -import fi.iki.elonen.ServerRunner; +/* + * #%L + * NanoHttpd-Samples + * %% + * Copyright (C) 2012 - 2015 nanohttpd + * %% + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * 3. Neither the name of the nanohttpd nor the names of its contributors + * may be used to endorse or promote products derived from this software without + * specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, + * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE + * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + * #L% + */ import java.util.HashMap; import java.util.List; import java.util.Map; +import fi.iki.elonen.NanoHTTPD; +import fi.iki.elonen.util.ServerRunner; + public class DebugServer extends NanoHTTPD { + + public static void main(String[] args) { + ServerRunner.run(DebugServer.class); + } + public DebugServer() { super(8080); } - public static void main(String[] args) { - ServerRunner.run(DebugServer.class); + private void listItem(StringBuilder sb, Map.Entry<String, ? extends Object> entry) { + sb.append("<li><code><b>").append(entry.getKey()).append("</b> = ").append(entry.getValue()).append("</code></li>"); } - @Override public Response serve(IHTTPSession session) { - Map<String, List<String>> decodedQueryParameters = - decodeParameters(session.getQueryParameterString()); + @Override + public Response serve(IHTTPSession session) { + Map<String, List<String>> decodedQueryParameters = decodeParameters(session.getQueryParameterString()); StringBuilder sb = new StringBuilder(); sb.append("<html>"); @@ -26,33 +64,27 @@ public class DebugServer extends NanoHTTPD { sb.append("<body>"); sb.append("<h1>Debug Server</h1>"); - sb.append("<p><blockquote><b>URI</b> = ").append( - String.valueOf(session.getUri())).append("<br />"); + sb.append("<p><blockquote><b>URI</b> = ").append(String.valueOf(session.getUri())).append("<br />"); - sb.append("<b>Method</b> = ").append( - String.valueOf(session.getMethod())).append("</blockquote></p>"); + sb.append("<b>Method</b> = ").append(String.valueOf(session.getMethod())).append("</blockquote></p>"); - sb.append("<h3>Headers</h3><p><blockquote>"). - append(toString(session.getHeaders())).append("</blockquote></p>"); + sb.append("<h3>Headers</h3><p><blockquote>").append(toString(session.getHeaders())).append("</blockquote></p>"); - sb.append("<h3>Parms</h3><p><blockquote>"). - append(toString(session.getParms())).append("</blockquote></p>"); + sb.append("<h3>Parms</h3><p><blockquote>").append(toString(session.getParms())).append("</blockquote></p>"); - sb.append("<h3>Parms (multi values?)</h3><p><blockquote>"). - append(toString(decodedQueryParameters)).append("</blockquote></p>"); + sb.append("<h3>Parms (multi values?)</h3><p><blockquote>").append(toString(decodedQueryParameters)).append("</blockquote></p>"); try { Map<String, String> files = new HashMap<String, String>(); session.parseBody(files); - sb.append("<h3>Files</h3><p><blockquote>"). - append(toString(files)).append("</blockquote></p>"); + sb.append("<h3>Files</h3><p><blockquote>").append(toString(files)).append("</blockquote></p>"); } catch (Exception e) { e.printStackTrace(); } sb.append("</body>"); sb.append("</html>"); - return new Response(sb.toString()); + return newFixedLengthResponse(sb.toString()); } private String toString(Map<String, ? extends Object> map) { @@ -65,15 +97,10 @@ public class DebugServer extends NanoHTTPD { private String unsortedList(Map<String, ? extends Object> map) { StringBuilder sb = new StringBuilder(); sb.append("<ul>"); - for (Map.Entry entry : map.entrySet()) { + for (Map.Entry<String, ? extends Object> entry : map.entrySet()) { listItem(sb, entry); } sb.append("</ul>"); return sb.toString(); } - - private void listItem(StringBuilder sb, Map.Entry entry) { - sb.append("<li><code><b>").append(entry.getKey()). - append("</b> = ").append(entry.getValue()).append("</code></li>"); - } } diff --git a/samples/src/site/site.xml b/samples/src/site/site.xml new file mode 100644 index 0000000..4270945 --- /dev/null +++ b/samples/src/site/site.xml @@ -0,0 +1,41 @@ +<?xml version="1.0" encoding="ISO-8859-1"?> +<project name="${project.name}"> + <skin> + <groupId>org.apache.maven.skins</groupId> + <artifactId>maven-fluido-skin</artifactId> + <version>1.3.0</version> + </skin> + <bannerLeft> + <src>../images/nanohttpd_logo.png</src> + </bannerLeft> + <bannerRight> + <src>../images/nanohttpd_logo_text.png</src> + </bannerRight> + <publishDate position="left" format="yyyy-MM-dd" /> + <version position="right" /> + <poweredBy> + <logo name="Maven" href="http://maven.apache.org/" + img="http://maven.apache.org/images/logos/maven-feather.png" /> + </poweredBy> + <custom> + <fluidoSkin> + <topBarEnabled>false</topBarEnabled> + <sideBarEnabled>true</sideBarEnabled> + <gitHub> + <projectId>Nanohttpd/nanohttpd</projectId> + <ribbonOrientation>right</ribbonOrientation> + <ribbonColor>black</ribbonColor> + </gitHub> + </fluidoSkin> + </custom> + <body> + <breadcrumbs> + <item name="${project.name}" href="index.html" /> + </breadcrumbs> + <menu name="Documentation"> + <item name="About" href="index.html" /> + </menu> + <menu ref="modules" /> + <menu ref="reports" /> + </body> +</project>
\ No newline at end of file |