JSONString interface allows a toJSONString()
5 | * method so that a class can change the behavior of
6 | * JSONObject.toString(), JSONArray.toString(),
7 | * and JSONWriter.value(Object). The
8 | * toJSONString method will be used instead of the default behavior
9 | * of using the Object's toString() method and quoting the result.
10 | */
11 | public interface JSONString {
12 | /**
13 | * The toJSONString method allows a class to produce its own JSON
14 | * serialization.
15 | *
16 | * @return A strictly syntactically correct JSON text.
17 | */
18 | public String toJSONString();
19 | }
20 |
--------------------------------------------------------------------------------
/nodel-framework/src/main/java/org/nodel/json/JSONException.java:
--------------------------------------------------------------------------------
1 | package org.nodel.json;
2 |
3 | /**
4 | * The JSONException is thrown by the JSON.org classes when things are amiss.
5 | * @author JSON.org
6 | * @version 2010-12-24
7 | */
8 | public class JSONException extends Exception {
9 | private static final long serialVersionUID = 0;
10 | private Throwable cause;
11 |
12 | /**
13 | * Constructs a JSONException with an explanatory message.
14 | * @param message Detail about the reason for the exception.
15 | */
16 | public JSONException(String message) {
17 | super(message);
18 | }
19 |
20 | public JSONException(Throwable cause) {
21 | super(cause.getMessage());
22 | this.cause = cause;
23 | }
24 |
25 | public Throwable getCause() {
26 | return this.cause;
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/nodel-webui-js/src/diagnostics.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | (To use this example, place it in a 'content' folder) 11 | 12 |
(click here for pre- and post-Python rendered pages) 13 | 14 |
Raw node name is <%= _node.getName() %>. 15 | 16 |
HTML friendly node description which may have HTML tags is <%! _node.getDesc() %>. 17 | 18 |
ipAddress parameter is <%! param_ipAddress %>. 19 | 20 |
URI is <%! req.uri %>. 23 | 24 |
local host is <%! req.localHost %>, local port is <%! req.localPort %>. 25 | 26 |
local host is <%! req.remoteHost %>, remote port is <%! req.remotePort %>. 27 | 28 |
req attributesresp attributeslocals() itemsglobals() items_node attributes40 | * Temp file managers are created 1-to-1 with incoming requests, to create and 41 | * cleanup temporary files created as a result of handling the request. 42 | *
43 | */ 44 | public interface ITempFileManager { 45 | 46 | void clear(); 47 | 48 | public ITempFile createTempFile(String filename_hint) throws Exception; 49 | } 50 | -------------------------------------------------------------------------------- /nodel-framework/src/main/java/org/nodel/core/NodelPoint.java: -------------------------------------------------------------------------------- 1 | package org.nodel.core; 2 | 3 | /* 4 | * This Source Code Form is subject to the terms of the Mozilla Public 5 | * License, v. 2.0. If a copy of the MPL was not distributed with this 6 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | */ 8 | 9 | import org.nodel.SimpleName; 10 | 11 | /** 12 | * Stores a "node name" , "event" / "action" key. 13 | * For use in maps or lists; performs Nodel name reduction. 14 | */ 15 | public class NodelPoint { 16 | 17 | /** 18 | * (see 'getNode') 19 | */ 20 | private SimpleName _node; 21 | 22 | /** 23 | * (see 'getConnection') 24 | */ 25 | private SimpleName _point; 26 | 27 | /** 28 | * (private constructor) 29 | */ 30 | private NodelPoint(SimpleName node, SimpleName point) { 31 | _node = node; 32 | _point = point; 33 | } 34 | 35 | /** 36 | * Creates a new key. 37 | */ 38 | public static NodelPoint create(String nodeName, String pointName) { 39 | return new NodelPoint(new SimpleName(nodeName), new SimpleName(pointName)); 40 | } 41 | 42 | /** 43 | * Creates a new key. 44 | */ 45 | public static NodelPoint create(SimpleName node, SimpleName point) { 46 | return new NodelPoint(node, point); 47 | } 48 | 49 | /** 50 | * Gets the node. 51 | */ 52 | public SimpleName getNode() { 53 | return _node; 54 | } 55 | 56 | /** 57 | * Gets the connection. 58 | */ 59 | public SimpleName getPoint() { 60 | return _point; 61 | } 62 | 63 | @Override 64 | public boolean equals(Object obj) { 65 | if (obj == null || !(obj instanceof NodelPoint)) 66 | return false; 67 | 68 | NodelPoint other = (NodelPoint) obj; 69 | 70 | return _node.equals(other._node) && _point.equals(other._point); 71 | } // (method) 72 | 73 | @Override 74 | public int hashCode() { 75 | return _node.hashCode() ^ _point.hashCode(); 76 | } // (method) 77 | 78 | @Override 79 | public String toString() { 80 | return _node + "." + _point; 81 | } 82 | 83 | } // (class) -------------------------------------------------------------------------------- /nodel-framework/src/main/java/org/nodel/Strings.java: -------------------------------------------------------------------------------- 1 | package org.nodel; 2 | 3 | /* 4 | * This Source Code Form is subject to the terms of the Mozilla Public 5 | * License, v. 2.0. If a copy of the MPL was not distributed with this 6 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | */ 8 | 9 | /** 10 | * Convenience methods for Strings. 11 | */ 12 | public class Strings { 13 | 14 | /** 15 | * An empty array of strings. 16 | */ 17 | public static final String[] EmptyArray = new String[] {}; 18 | 19 | /** 20 | * (use 'isEmpty' instead) 21 | */ 22 | @Deprecated 23 | public static boolean isNullOrEmpty(String value) { 24 | return isEmpty(value); 25 | } 26 | 27 | /** 28 | * Returns true if the value is strictly null or has length zero. 29 | */ 30 | public static boolean isEmpty(String value) { 31 | return value == null || value.length() == 0; 32 | } 33 | 34 | /** 35 | * Returns true if the value is null or empty (or full of common whitespace), false otherwise. 36 | */ 37 | public static boolean isBlank(String value) { 38 | if (value == null) 39 | return true; 40 | 41 | // check length... 42 | int len = value.length(); 43 | 44 | if (len == 0) 45 | return true; 46 | 47 | // ...and then for any non common-whitespace, incl. 0xa0 NO-BREAK SPACE 48 | for (int a = 0; a < len; a++) { 49 | char c = value.charAt(a); 50 | 51 | if (c != ' ' && c != '\t' && c != '\r' && c != '\n' && !Character.isSpaceChar(c)) 52 | return false; 53 | } 54 | 55 | // was empty or all common whitespace 56 | return true; 57 | } 58 | 59 | /** 60 | * A safe, simple alphabetical compare function. 61 | */ 62 | public static int compare(String name1, String name2) { 63 | if (name1 == null && name2 == null) 64 | return 0; 65 | 66 | if (name1 == null) 67 | return 1; 68 | 69 | if (name2 == null) 70 | return -1; 71 | 72 | return name1.compareTo(name2); 73 | } 74 | 75 | } 76 | -------------------------------------------------------------------------------- /nodel-framework/src/main/java/org/nanohttpd/protocols/http/tempfiles/ITempFile.java: -------------------------------------------------------------------------------- 1 | package org.nanohttpd.protocols.http.tempfiles; 2 | 3 | /* 4 | * #%L 5 | * NanoHttpd-Core 6 | * %% 7 | * Copyright (C) 2012 - 2016 nanohttpd 8 | * %% 9 | * Redistribution and use in source and binary forms, with or without modification, 10 | * are permitted provided that the following conditions are met: 11 | * 12 | * 1. Redistributions of source code must retain the above copyright notice, this 13 | * list of conditions and the following disclaimer. 14 | * 15 | * 2. Redistributions in binary form must reproduce the above copyright notice, 16 | * this list of conditions and the following disclaimer in the documentation 17 | * and/or other materials provided with the distribution. 18 | * 19 | * 3. Neither the name of the nanohttpd nor the names of its contributors 20 | * may be used to endorse or promote products derived from this software without 21 | * specific prior written permission. 22 | * 23 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 24 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 25 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 26 | * IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 27 | * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 28 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 29 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 30 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 31 | * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 32 | * OF THE POSSIBILITY OF SUCH DAMAGE. 33 | * #L% 34 | */ 35 | 36 | import java.io.OutputStream; 37 | 38 | /** 39 | * A temp file. 40 | * 41 | *42 | * Temp files are responsible for managing the actual temporary storage and 43 | * cleaning themselves up when no longer needed. 44 | *
45 | */ 46 | public interface ITempFile { 47 | 48 | public void delete() throws Exception; 49 | 50 | public String getName(); 51 | 52 | public OutputStream open() throws Exception; 53 | } 54 | -------------------------------------------------------------------------------- /nodel-framework/src/main/java/org/nanohttpd/protocols/http/sockets/DefaultServerSocketFactory.java: -------------------------------------------------------------------------------- 1 | package org.nanohttpd.protocols.http.sockets; 2 | 3 | /* 4 | * #%L 5 | * NanoHttpd-Core 6 | * %% 7 | * Copyright (C) 2012 - 2016 nanohttpd 8 | * %% 9 | * Redistribution and use in source and binary forms, with or without modification, 10 | * are permitted provided that the following conditions are met: 11 | * 12 | * 1. Redistributions of source code must retain the above copyright notice, this 13 | * list of conditions and the following disclaimer. 14 | * 15 | * 2. Redistributions in binary form must reproduce the above copyright notice, 16 | * this list of conditions and the following disclaimer in the documentation 17 | * and/or other materials provided with the distribution. 18 | * 19 | * 3. Neither the name of the nanohttpd nor the names of its contributors 20 | * may be used to endorse or promote products derived from this software without 21 | * specific prior written permission. 22 | * 23 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 24 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 25 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 26 | * IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 27 | * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 28 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 29 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 30 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 31 | * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 32 | * OF THE POSSIBILITY OF SUCH DAMAGE. 33 | * #L% 34 | */ 35 | 36 | import java.io.IOException; 37 | import java.net.ServerSocket; 38 | 39 | import org.nanohttpd.util.IFactoryThrowing; 40 | 41 | /** 42 | * Creates a normal ServerSocket for TCP connections 43 | */ 44 | public class DefaultServerSocketFactory implements IFactoryThrowingString back
38 | * to its enum value.
39 | */
40 | public enum Method {
41 | GET,
42 | PUT,
43 | POST,
44 | DELETE,
45 | HEAD,
46 | OPTIONS,
47 | TRACE,
48 | CONNECT,
49 | PATCH,
50 | PROPFIND,
51 | PROPPATCH,
52 | MKCOL,
53 | MOVE,
54 | COPY,
55 | LOCK,
56 | UNLOCK,
57 | NOTIFY,
58 | SUBSCRIBE;
59 |
60 | public static Method lookup(String method) {
61 | if (method == null)
62 | return null;
63 |
64 | try {
65 | return valueOf(method);
66 | } catch (IllegalArgumentException e) {
67 | // TODO: Log it?
68 | return null;
69 | }
70 | }
71 | }
72 |
--------------------------------------------------------------------------------
/nodel-framework/src/main/java/org/nodel/diagnostics/CountableOutputStream.java:
--------------------------------------------------------------------------------
1 | package org.nodel.diagnostics;
2 |
3 | /*
4 | * This Source Code Form is subject to the terms of the Mozilla Public
5 | * License, v. 2.0. If a copy of the MPL was not distributed with this
6 | * file, You can obtain one at http://mozilla.org/MPL/2.0/.
7 | */
8 |
9 | import java.io.IOException;
10 | import java.io.OutputStream;
11 |
12 | import org.nodel.io.Stream;
13 |
14 | /**
15 | * Allows for data counting of underlying stream.
16 | */
17 | public class CountableOutputStream extends OutputStream {
18 |
19 | private SharableMeasurementProvider total;
20 |
21 | private SharableMeasurementProvider ops;
22 |
23 | private OutputStream base;
24 |
25 | public CountableOutputStream(OutputStream base, SharableMeasurementProvider ops, SharableMeasurementProvider total) {
26 | this.base = base;
27 | this.ops = ops;
28 | this.total = total;
29 | } // (init)
30 |
31 | /**
32 | * The total amount of data written.
33 | */
34 | public long getTotal() {
35 | return this.total.getMeasurement();
36 | }
37 |
38 | /**
39 | * Records the number of write operations
40 | */
41 | public long getOps() {
42 | return this.ops.getMeasurement();
43 | }
44 |
45 | /**
46 | * The underlying stream.
47 | */
48 | public OutputStream getBase() {
49 | return this.base;
50 | }
51 |
52 | /**
53 | * {@inheritDoc}
54 | */
55 | @Override
56 | public void write(int b) throws IOException {
57 | this.ops.incr();
58 | this.total.add(8);
59 |
60 | this.base.write(b);
61 | }
62 |
63 | /**
64 | * {@inheritDoc}
65 | */
66 | @Override
67 | public void write(byte b[]) throws IOException {
68 | this.ops.incr();
69 | this.total.add(b.length * 8);
70 |
71 | this.base.write(b);
72 | }
73 |
74 |
75 | /**
76 | * {@inheritDoc}
77 | */
78 | @Override
79 | public void write(byte b[], int off, int len) throws IOException {
80 | this.ops.incr();
81 | this.total.add(len * 8);
82 |
83 | this.base.write(b, off, len);
84 | }
85 |
86 | @Override
87 | public void flush() throws IOException {
88 | this.base.flush();
89 | }
90 |
91 | /**
92 | * {@inheritDoc}
93 | */
94 | @Override
95 | public void close() throws IOException {
96 | Stream.safeClose(base);
97 | }
98 |
99 | } // (class)
100 |
--------------------------------------------------------------------------------
/nodel-framework/src/main/java/org/nanohttpd/protocols/websockets/CloseCode.java:
--------------------------------------------------------------------------------
1 | package org.nanohttpd.protocols.websockets;
2 |
3 | /*
4 | * #%L
5 | * NanoHttpd-Websocket
6 | * %%
7 | * Copyright (C) 2012 - 2016 nanohttpd
8 | * %%
9 | * Redistribution and use in source and binary forms, with or without modification,
10 | * are permitted provided that the following conditions are met:
11 | *
12 | * 1. Redistributions of source code must retain the above copyright notice, this
13 | * list of conditions and the following disclaimer.
14 | *
15 | * 2. Redistributions in binary form must reproduce the above copyright notice,
16 | * this list of conditions and the following disclaimer in the documentation
17 | * and/or other materials provided with the distribution.
18 | *
19 | * 3. Neither the name of the nanohttpd nor the names of its contributors
20 | * may be used to endorse or promote products derived from this software without
21 | * specific prior written permission.
22 | *
23 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
24 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
25 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
26 | * IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
27 | * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
28 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
29 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
30 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
31 | * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
32 | * OF THE POSSIBILITY OF SUCH DAMAGE.
33 | * #L%
34 | */
35 |
36 | public enum CloseCode {
37 | NormalClosure(1000),
38 | GoingAway(1001),
39 | ProtocolError(1002),
40 | UnsupportedData(1003),
41 | NoStatusRcvd(1005),
42 | AbnormalClosure(1006),
43 | InvalidFramePayloadData(1007),
44 | PolicyViolation(1008),
45 | MessageTooBig(1009),
46 | MandatoryExt(1010),
47 | InternalServerError(1011),
48 | TLSHandshake(1015);
49 |
50 | public static CloseCode find(int value) {
51 | for (CloseCode code : values()) {
52 | if (code.getValue() == value) {
53 | return code;
54 | }
55 | }
56 | return null;
57 | }
58 |
59 | private final int code;
60 |
61 | private CloseCode(int code) {
62 | this.code = code;
63 | }
64 |
65 | public int getValue() {
66 | return this.code;
67 | }
68 | }
69 |
--------------------------------------------------------------------------------
/nodel-framework/src/main/java/org/nanohttpd/protocols/http/tempfiles/DefaultTempFileManagerFactory.java:
--------------------------------------------------------------------------------
1 | package org.nanohttpd.protocols.http.tempfiles;
2 |
3 | /*
4 | * ALTERED FROM ORIGINAL
5 | *
6 | * #%L
7 | * NanoHttpd-Core
8 | * %%
9 | * Copyright (C) 2012 - 2016 nanohttpd
10 | * %%
11 | * Redistribution and use in source and binary forms, with or without modification,
12 | * are permitted provided that the following conditions are met:
13 | *
14 | * 1. Redistributions of source code must retain the above copyright notice, this
15 | * list of conditions and the following disclaimer.
16 | *
17 | * 2. Redistributions in binary form must reproduce the above copyright notice,
18 | * this list of conditions and the following disclaimer in the documentation
19 | * and/or other materials provided with the distribution.
20 | *
21 | * 3. Neither the name of the nanohttpd nor the names of its contributors
22 | * may be used to endorse or promote products derived from this software without
23 | * specific prior written permission.
24 | *
25 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
26 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
27 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
28 | * IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
29 | * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
30 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
31 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
32 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
33 | * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
34 | * OF THE POSSIBILITY OF SUCH DAMAGE.
35 | * #L%
36 | */
37 |
38 | import org.nanohttpd.util.IFactory;
39 |
40 | import java.io.File;
41 |
42 | /**
43 | * Default strategy for creating and cleaning up temporary files.
44 | */
45 | public class DefaultTempFileManagerFactory implements IFactoryRaw node name is <%= _node.getName() %>."); 28 | pw.println(); 29 | pw.println("
HTML friendly node description is <%# _node.getDesc() %>."); 30 | pw.println(); 31 | pw.println("
ipAddress parameter is <%# param_ipAddress %>."); 32 | pw.println(); 33 | pw.println("
_ctx.req() attributes:");
36 | pw.println("
_ctx.resp() attributes:");
45 | pw.println("
locals attributes:");
53 | pw.println("
_node attributes:");
62 | pw.println("
_pysp is (can use '?_dump' querystring):
");
71 | pw.println("
<%# _pysp %>"); 72 | pw.println(""); 73 | pw.println(""); 74 | 75 | return sw.toString(); 76 | } // (method) 77 | 78 | } 79 | -------------------------------------------------------------------------------- /nodel-framework/src/main/java/org/nanohttpd/protocols/http/tempfiles/DefaultTempFile.java: -------------------------------------------------------------------------------- 1 | package org.nanohttpd.protocols.http.tempfiles; 2 | 3 | /* 4 | * #%L 5 | * NanoHttpd-Core 6 | * %% 7 | * Copyright (C) 2012 - 2016 nanohttpd 8 | * %% 9 | * Redistribution and use in source and binary forms, with or without modification, 10 | * are permitted provided that the following conditions are met: 11 | * 12 | * 1. Redistributions of source code must retain the above copyright notice, this 13 | * list of conditions and the following disclaimer. 14 | * 15 | * 2. Redistributions in binary form must reproduce the above copyright notice, 16 | * this list of conditions and the following disclaimer in the documentation 17 | * and/or other materials provided with the distribution. 18 | * 19 | * 3. Neither the name of the nanohttpd nor the names of its contributors 20 | * may be used to endorse or promote products derived from this software without 21 | * specific prior written permission. 22 | * 23 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 24 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 25 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 26 | * IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 27 | * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 28 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 29 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 30 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 31 | * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 32 | * OF THE POSSIBILITY OF SUCH DAMAGE. 33 | * #L% 34 | */ 35 | 36 | import java.io.File; 37 | import java.io.FileOutputStream; 38 | import java.io.IOException; 39 | import java.io.OutputStream; 40 | 41 | import org.nanohttpd.protocols.http.NanoHTTPD; 42 | 43 | /** 44 | * Default strategy for creating and cleaning up temporary files. 45 | * 46 | *
47 | * By default, files are created by File.createTempFile() in the
48 | * directory specified.
49 | *