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sbIEPxMEIJ-oXnpCc0w~3EuzV+)&UOR3Q01?a0<_~hIY{<(JShn
z6^hp?AH{
z%CbM2Nr~fsnG|NbkR!No9mp#T%0xVTF?bB&KGMJAf~UV?5o9uhe=_((8wL;v1^9i_
z{tv>h?<4r$5CBdE{`mQSGO!=bKFYxU@#a5TzV9CrGyiAy|B1qWB>eI2KNV-+KSBT7
z{^;2G{rX)A_TLQtP=ftW`@n2LG89`4_FZkLZsg
zLch@~@c)edpXA_=*pDJTzp>K@|BU^x@c(Bfe?)(jLivpzK>la+pM&xD%#Wpde=|Ma
zpMn4VKlk^r+onf~V>d`RZ~2>+Ph`5XSo|IhG0KPCPy+w)@&AG0KX_kbq&&prJA
zIg=lWAJesd6E{TunfO1+TOY9>kG6kfp-lc6`(d{I<)Hgx4<8THe)sTb{?9#p80^2l
z1wS4*{YEob{xkajj-Nhy`tix_H;(P|zu^Afw~ss4->?XWe}?`2!2V_b`qAr;o1EVr
h^?do~j{Y3qKb;4CPv`wZ!5tF-2m%1$&gqX={|`m@0UQ7T
diff --git a/app/src/main/java/org/fdroid/fdroid/net/LocalHTTPD.java b/app/src/main/java/org/fdroid/fdroid/net/LocalHTTPD.java
index dead4e7ef..4ba03df04 100644
--- a/app/src/main/java/org/fdroid/fdroid/net/LocalHTTPD.java
+++ b/app/src/main/java/org/fdroid/fdroid/net/LocalHTTPD.java
@@ -5,12 +5,13 @@ import android.content.Intent;
import android.net.Uri;
import android.util.Log;
import android.webkit.MimeTypeMap;
-
+import fi.iki.elonen.NanoHTTPD;
import org.fdroid.fdroid.BuildConfig;
import org.fdroid.fdroid.Utils;
import org.fdroid.fdroid.localrepo.LocalRepoKeyStore;
import org.fdroid.fdroid.views.swap.SwapWorkflowActivity;
+import javax.net.ssl.SSLServerSocketFactory;
import java.io.File;
import java.io.FileInputStream;
import java.io.FilenameFilter;
@@ -26,10 +27,6 @@ import java.util.List;
import java.util.Map;
import java.util.StringTokenizer;
-import javax.net.ssl.SSLServerSocketFactory;
-
-import fi.iki.elonen.NanoHTTPD;
-
public class LocalHTTPD extends NanoHTTPD {
private static final String TAG = "LocalHTTPD";
@@ -93,10 +90,10 @@ public class LocalHTTPD extends NanoHTTPD {
session.parseBody(new HashMap());
} catch (IOException e) {
Log.e(TAG, "An error occured while parsing the POST body", e);
- return new Response(Response.Status.INTERNAL_ERROR, MIME_PLAINTEXT,
+ return newFixedLengthResponse(Response.Status.INTERNAL_ERROR, MIME_PLAINTEXT,
"Internal server error, check logcat on server for details.");
} catch (ResponseException re) {
- return new Response(re.getStatus(), MIME_PLAINTEXT, re.getMessage());
+ return newFixedLengthResponse(re.getStatus(), MIME_PLAINTEXT, re.getMessage());
}
return handlePost(session);
@@ -111,13 +108,13 @@ public class LocalHTTPD extends NanoHTTPD {
if (!session.getParms().containsKey("repo")) {
Log.e(TAG, "Malformed /request-swap request to local repo HTTP server."
+ " Should have posted a 'repo' parameter.");
- return new Response(Response.Status.BAD_REQUEST, MIME_PLAINTEXT,
+ return newFixedLengthResponse(Response.Status.BAD_REQUEST, MIME_PLAINTEXT,
"Requires 'repo' parameter to be posted.");
}
requestSwap(session.getParms().get("repo"));
- return new Response(Response.Status.OK, MIME_PLAINTEXT, "Swap request received.");
+ return newFixedLengthResponse(Response.Status.OK, MIME_PLAINTEXT, "Swap request received.");
}
- return new Response("");
+ return newFixedLengthResponse("");
}
private Response handleGet(IHTTPSession session) {
@@ -155,7 +152,7 @@ public class LocalHTTPD extends NanoHTTPD {
SSLServerSocketFactory factory = NanoHTTPD.makeSSLSocketFactory(
localRepoKeyStore.getKeyStore(),
localRepoKeyStore.getKeyManagers());
- makeSecure(factory);
+ makeSecure(factory, null);
} catch (LocalRepoKeyStore.InitException | IOException e) {
Log.e(TAG, "Could not enable HTTPS", e);
}
@@ -209,7 +206,7 @@ public class LocalHTTPD extends NanoHTTPD {
}
}
- Response response = serveFile(headers, f, getMimeTypeForFile(uri));
+ Response response = serveFile(headers, f, getAndroidMimeTypeForFile(uri));
return response != null ? response :
createResponse(Response.Status.NOT_FOUND, NanoHTTPD.MIME_PLAINTEXT,
"Error 404, file not found.");
@@ -298,19 +295,19 @@ public class LocalHTTPD extends NanoHTTPD {
// Announce that the file server accepts partial content requests
private Response createResponse(Response.Status status, String mimeType, InputStream message) {
- Response res = new Response(status, mimeType, message);
+ Response res = newChunkedResponse(status, mimeType, message);
res.addHeader("Accept-Ranges", "bytes");
return res;
}
// Announce that the file server accepts partial content requests
private Response createResponse(Response.Status status, String mimeType, String message) {
- Response res = new Response(status, mimeType, message);
+ Response res = newFixedLengthResponse(status, mimeType, message);
res.addHeader("Accept-Ranges", "bytes");
return res;
}
- private static String getMimeTypeForFile(String uri) {
+ private static String getAndroidMimeTypeForFile(String uri) {
String type = null;
String extension = MimeTypeMap.getFileExtensionFromUrl(uri);
if (extension != null) {
diff --git a/extern/nanohttpd/LICENSE.md b/extern/nanohttpd/LICENSE.md
deleted file mode 100644
index 8dc4ca7c6..000000000
--- a/extern/nanohttpd/LICENSE.md
+++ /dev/null
@@ -1,12 +0,0 @@
-Copyright (c) 2012-2013 by Paul S. Hawke, 2001,2005-2013 by Jarno Elonen, 2010 by Konstantinos Togias
-All rights reserved.
-
-Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
-
-* Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
-
-* 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.
-
-* Neither the name of the NanoHttpd organization 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.
diff --git a/extern/nanohttpd/core/build.gradle b/extern/nanohttpd/core/build.gradle
deleted file mode 100644
index fa98bdbea..000000000
--- a/extern/nanohttpd/core/build.gradle
+++ /dev/null
@@ -1,14 +0,0 @@
-apply plugin: 'java'
-
-version = '2.1.0'
-
-sourceCompatibility = 1.7
-targetCompatibility = 1.7
-
-jar {
- baseName = 'nanohttpd'
-}
-
-repositories {
- mavenCentral()
-}
diff --git a/extern/nanohttpd/core/src/main/java/fi/iki/elonen/NanoHTTPD.java b/extern/nanohttpd/core/src/main/java/fi/iki/elonen/NanoHTTPD.java
deleted file mode 100644
index d34763ddf..000000000
--- a/extern/nanohttpd/core/src/main/java/fi/iki/elonen/NanoHTTPD.java
+++ /dev/null
@@ -1,1505 +0,0 @@
-package fi.iki.elonen;
-
-import java.io.BufferedReader;
-import java.io.ByteArrayInputStream;
-import java.io.Closeable;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.io.OutputStream;
-import java.io.PrintWriter;
-import java.io.RandomAccessFile;
-import java.io.PushbackInputStream;
-import java.io.UnsupportedEncodingException;
-import java.net.InetAddress;
-import java.net.InetSocketAddress;
-import java.net.ServerSocket;
-import java.net.Socket;
-import java.net.SocketException;
-import java.net.SocketTimeoutException;
-import java.net.URLDecoder;
-import java.nio.ByteBuffer;
-import java.nio.channels.FileChannel;
-import java.text.SimpleDateFormat;
-import java.util.ArrayList;
-import java.util.Calendar;
-import java.util.Date;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Locale;
-import java.util.Map;
-import java.util.Set;
-import java.util.StringTokenizer;
-import java.util.TimeZone;
-
-
-import java.security.KeyStore;
-import javax.net.ssl.*;
-
-/**
- * A simple, tiny, nicely embeddable HTTP server in Java
- *
- *
- * NanoHTTPD
- * Copyright (c) 2012-2013 by Paul S. Hawke, 2001,2005-2013 by Jarno Elonen, 2010 by Konstantinos Togias
- *
- *
- * Features + limitations:
- *
- *
- * - Only one Java file
- * - Java 5 compatible
- * - Released as open source, Modified BSD licence
- * - No fixed config files, logging, authorization etc. (Implement yourself if you need them.)
- * - Supports parameter parsing of GET and POST methods (+ rudimentary PUT support in 1.25)
- * - Supports both dynamic content and file serving
- * - Supports file upload (since version 1.2, 2010)
- * - Supports partial content (streaming)
- * - Supports ETags
- * - Never caches anything
- * - Doesn't limit bandwidth, request time or simultaneous connections
- * - Default code serves files and shows all HTTP parameters and headers
- * - File server supports directory listing, index.html and index.htm
- * - File server supports partial content (streaming)
- * - File server supports ETags
- * - File server does the 301 redirection trick for directories without '/'
- * - File server supports simple skipping for files (continue download)
- * - File server serves also very long files without memory overhead
- * - Contains a built-in list of most common mime types
- * - All header names are converted lowercase so they don't vary between browsers/clients
- *
- *
- *
- *
- * How to use:
- *
- *
- * - Subclass and implement serve() and embed to your own program
- *
- *
- *
- * See the separate "LICENSE.md" file for the distribution license (Modified BSD licence)
- */
-public abstract class NanoHTTPD {
- /**
- * Maximum time to wait on Socket.getInputStream().read() (in milliseconds)
- * This is required as the Keep-Alive HTTP connections would otherwise
- * block the socket reading thread forever (or as long the browser is open).
- */
- public static final int SOCKET_READ_TIMEOUT = 5000;
- /**
- * Common mime type for dynamic content: plain text
- */
- public static final String MIME_PLAINTEXT = "text/plain";
- /**
- * Common mime type for dynamic content: html
- */
- public static final String MIME_HTML = "text/html";
- /**
- * Pseudo-Parameter to use to store the actual query string in the parameters map for later re-processing.
- */
- private static final String QUERY_STRING_PARAMETER = "NanoHttpd.QUERY_STRING";
- private final String hostname;
- private final int myPort;
- private ServerSocket myServerSocket;
- private Set openConnections = new HashSet();
- private SSLServerSocketFactory sslServerSocketFactory;
- private Thread myThread;
- /**
- * Pluggable strategy for asynchronously executing requests.
- */
- private AsyncRunner asyncRunner;
- /**
- * Pluggable strategy for creating and cleaning up temporary files.
- */
- private TempFileManagerFactory tempFileManagerFactory;
-
- /**
- * Constructs an HTTP server on given port.
- */
- public NanoHTTPD(int port) {
- this(null, port);
- }
-
- /**
- * Constructs an HTTP server on given hostname and port.
- */
- public NanoHTTPD(String hostname, int port) {
- this.hostname = hostname;
- this.myPort = port;
- setTempFileManagerFactory(new DefaultTempFileManagerFactory());
- setAsyncRunner(new DefaultAsyncRunner());
- }
-
- private static final void safeClose(Closeable closeable) {
- if (closeable != null) {
- try {
- closeable.close();
- } catch (IOException e) {
- }
- }
- }
-
- private static final void safeClose(Socket closeable) {
- if (closeable != null) {
- try {
- closeable.close();
- } catch (IOException e) {
- }
- }
- }
-
- private static final void safeClose(ServerSocket closeable) {
- if (closeable != null) {
- try {
- closeable.close();
- } catch (IOException e) {
- }
- }
- }
-
- /**
- * Creates an SSLSocketFactory for HTTPS.
- *
- * Pass a KeyStore resource with your certificate and passphrase
- */
- public static SSLServerSocketFactory makeSSLSocketFactory(String keyAndTrustStoreClasspathPath, char[] passphrase) throws IOException {
- SSLServerSocketFactory res = null;
- try {
- KeyStore keystore = KeyStore.getInstance(KeyStore.getDefaultType());
- InputStream keystoreStream = NanoHTTPD.class.getResourceAsStream(keyAndTrustStoreClasspathPath);
- keystore.load(keystoreStream, passphrase);
- TrustManagerFactory trustManagerFactory = TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm());
- trustManagerFactory.init(keystore);
- KeyManagerFactory keyManagerFactory = KeyManagerFactory.getInstance(KeyManagerFactory.getDefaultAlgorithm());
- keyManagerFactory.init(keystore, passphrase);
- SSLContext ctx = SSLContext.getInstance("TLS");
- ctx.init(keyManagerFactory.getKeyManagers(), trustManagerFactory.getTrustManagers(), null);
- res = ctx.getServerSocketFactory();
- } catch (Exception e) {
- throw new IOException(e.getMessage());
- }
- return res;
- }
-
- /**
- * Creates an SSLSocketFactory for HTTPS.
- *
- * Pass a loaded KeyStore and a loaded KeyManagerFactory.
- * These objects must properly loaded/initialized by the caller.
- */
- public static SSLServerSocketFactory makeSSLSocketFactory(KeyStore loadedKeyStore, KeyManagerFactory loadedKeyFactory) throws IOException {
- SSLServerSocketFactory res = null;
- try {
- TrustManagerFactory trustManagerFactory = TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm());
- trustManagerFactory.init(loadedKeyStore);
- SSLContext ctx = SSLContext.getInstance("TLS");
- ctx.init(loadedKeyFactory.getKeyManagers(), trustManagerFactory.getTrustManagers(), null);
- res = ctx.getServerSocketFactory();
- } catch (Exception e) {
- throw new IOException(e.getMessage());
- }
- return res;
- }
-
- /**
- * Creates an SSLSocketFactory for HTTPS.
- *
- * Pass a loaded KeyStore and an array of loaded KeyManagers.
- * These objects must properly loaded/initialized by the caller.
- */
- public static SSLServerSocketFactory makeSSLSocketFactory(KeyStore loadedKeyStore, KeyManager[] keyManagers) throws IOException {
- SSLServerSocketFactory res = null;
- try {
- TrustManagerFactory trustManagerFactory = TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm());
- trustManagerFactory.init(loadedKeyStore);
- SSLContext ctx = SSLContext.getInstance("TLS");
- ctx.init(keyManagers, trustManagerFactory.getTrustManagers(), null);
- res = ctx.getServerSocketFactory();
- } catch (Exception e) {
- throw new IOException(e.getMessage());
- }
- return res;
- }
-
- /**
- * Call before start() to serve over HTTPS instead of HTTP
- */
- public void makeSecure(SSLServerSocketFactory sslServerSocketFactory) {
- this.sslServerSocketFactory = sslServerSocketFactory;
- }
-
- /**
- * Start the server.
- *
- * @throws IOException if the socket is in use.
- */
- public void start() throws IOException {
- if (sslServerSocketFactory != null) {
- SSLServerSocket ss = (SSLServerSocket) sslServerSocketFactory.createServerSocket();
- ss.setNeedClientAuth(false);
- myServerSocket = ss;
- } else {
- myServerSocket = new ServerSocket();
- }
-
- myServerSocket.bind((hostname != null) ? new InetSocketAddress(hostname, myPort) : new InetSocketAddress(myPort));
-
- myThread = new Thread(new Runnable() {
- @Override
- public void run() {
- do {
- try {
- final Socket finalAccept = myServerSocket.accept();
- registerConnection(finalAccept);
- finalAccept.setSoTimeout(SOCKET_READ_TIMEOUT);
- final InputStream inputStream = finalAccept.getInputStream();
- asyncRunner.exec(new Runnable() {
- @Override
- public void run() {
- OutputStream outputStream = null;
- try {
- outputStream = finalAccept.getOutputStream();
- TempFileManager tempFileManager = tempFileManagerFactory.create();
- HTTPSession session = new HTTPSession(tempFileManager, inputStream, outputStream, finalAccept.getInetAddress());
- while (!finalAccept.isClosed()) {
- session.execute();
- }
- } catch (Exception e) {
- // When the socket is closed by the client, we throw our own SocketException
- // to break the "keep alive" loop above. If the exception was anything other
- // than the expected SocketException OR a SocketTimeoutException, print the
- // stacktrace
- if (!(e instanceof SocketException && "NanoHttpd Shutdown".equals(e.getMessage())) &&
- !(e instanceof SocketTimeoutException)) {
- e.printStackTrace();
- }
- } finally {
- safeClose(outputStream);
- safeClose(inputStream);
- safeClose(finalAccept);
- unRegisterConnection(finalAccept);
- }
- }
- });
- } catch (IOException e) {
- }
- } while (!myServerSocket.isClosed());
- }
- });
- myThread.setDaemon(true);
- myThread.setName("NanoHttpd Main Listener");
- myThread.start();
- }
-
- /**
- * Stop the server.
- */
- public void stop() {
- try {
- safeClose(myServerSocket);
- closeAllConnections();
- myThread.join();
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
-
- /**
- * Registers that a new connection has been set up.
- *
- * @param socket
- * the {@link Socket} for the connection.
- */
- public synchronized void registerConnection(Socket socket) {
- openConnections.add(socket);
- }
-
- /**
- * Registers that a connection has been closed
- *
- * @param socket
- * the {@link Socket} for the connection.
- */
- public synchronized void unRegisterConnection(Socket socket) {
- openConnections.remove(socket);
- }
-
- /**
- * Forcibly closes all connections that are open.
- */
- public synchronized void closeAllConnections() {
- for (Socket socket : openConnections) {
- safeClose(socket);
- }
- }
-
- public final int getListeningPort() {
- return myServerSocket == null ? -1 : myServerSocket.getLocalPort();
- }
-
- public final boolean wasStarted() {
- return myServerSocket != null && myThread != null;
- }
-
- public final boolean isAlive() {
- return wasStarted() && !myServerSocket.isClosed() && myThread.isAlive();
- }
-
- /**
- * Override this to customize the server.
- *
- *
- * (By default, this delegates to serveFile() and allows directory listing.)
- *
- * @param uri Percent-decoded URI without parameters, for example "/index.cgi"
- * @param method "GET", "POST" etc.
- * @param parms Parsed, percent decoded parameters from URI and, in case of POST, data.
- * @param headers Header entries, percent decoded
- * @return HTTP response, see class Response for details
- */
- @Deprecated
- public Response serve(String uri, Method method, Map headers, Map parms,
- Map files) {
- return new Response(Response.Status.NOT_FOUND, MIME_PLAINTEXT, "Not Found");
- }
-
- /**
- * Override this to customize the server.
- *
- *
- * (By default, this delegates to serveFile() and allows directory listing.)
- *
- * @param session The HTTP session
- * @return HTTP response, see class Response for details
- */
- public Response serve(IHTTPSession session) {
- Map files = new HashMap();
- Method method = session.getMethod();
- if (Method.PUT.equals(method) || Method.POST.equals(method)) {
- try {
- session.parseBody(files);
- } catch (IOException ioe) {
- return new Response(Response.Status.INTERNAL_ERROR, MIME_PLAINTEXT, "SERVER INTERNAL ERROR: IOException: " + ioe.getMessage());
- } catch (ResponseException re) {
- return new Response(re.getStatus(), MIME_PLAINTEXT, re.getMessage());
- }
- }
-
- Map parms = session.getParms();
- parms.put(QUERY_STRING_PARAMETER, session.getQueryParameterString());
- return serve(session.getUri(), method, session.getHeaders(), parms, files);
- }
-
- /**
- * Decode percent encoded String values.
- *
- * @param str the percent encoded String
- * @return expanded form of the input, for example "foo%20bar" becomes "foo bar"
- */
- protected String decodePercent(String str) {
- String decoded = null;
- try {
- decoded = URLDecoder.decode(str, "UTF8");
- } catch (UnsupportedEncodingException ignored) {
- }
- return decoded;
- }
-
- /**
- * Decode parameters from a URL, handing the case where a single parameter name might have been
- * supplied several times, by return lists of values. In general these lists will contain a single
- * element.
- *
- * @param parms original NanoHttpd parameters values, as passed to the serve() method.
- * @return a map of String (parameter name) to List<String> (a list of the values supplied).
- */
- protected Map> decodeParameters(Map parms) {
- return this.decodeParameters(parms.get(QUERY_STRING_PARAMETER));
- }
-
- /**
- * Decode parameters from a URL, handing the case where a single parameter name might have been
- * supplied several times, by return lists of values. In general these lists will contain a single
- * element.
- *
- * @param queryString a query string pulled from the URL.
- * @return a map of String (parameter name) to List<String> (a list of the values supplied).
- */
- protected Map> decodeParameters(String queryString) {
- Map> parms = new HashMap>();
- if (queryString != null) {
- StringTokenizer st = new StringTokenizer(queryString, "&");
- while (st.hasMoreTokens()) {
- String e = st.nextToken();
- int sep = e.indexOf('=');
- String propertyName = (sep >= 0) ? decodePercent(e.substring(0, sep)).trim() : decodePercent(e).trim();
- if (!parms.containsKey(propertyName)) {
- parms.put(propertyName, new ArrayList());
- }
- String propertyValue = (sep >= 0) ? decodePercent(e.substring(sep + 1)) : null;
- if (propertyValue != null) {
- parms.get(propertyName).add(propertyValue);
- }
- }
- }
- return parms;
- }
-
- // ------------------------------------------------------------------------------- //
- //
- // Threading Strategy.
- //
- // ------------------------------------------------------------------------------- //
-
- /**
- * Pluggable strategy for asynchronously executing requests.
- *
- * @param asyncRunner new strategy for handling threads.
- */
- public void setAsyncRunner(AsyncRunner asyncRunner) {
- this.asyncRunner = asyncRunner;
- }
-
- // ------------------------------------------------------------------------------- //
- //
- // Temp file handling strategy.
- //
- // ------------------------------------------------------------------------------- //
-
- /**
- * Pluggable strategy for creating and cleaning up temporary files.
- *
- * @param tempFileManagerFactory new strategy for handling temp files.
- */
- public void setTempFileManagerFactory(TempFileManagerFactory tempFileManagerFactory) {
- this.tempFileManagerFactory = tempFileManagerFactory;
- }
-
- /**
- * HTTP Request methods, with the ability to decode a String back to its enum value.
- */
- public enum Method {
- GET, PUT, POST, DELETE, HEAD, OPTIONS;
-
- static Method lookup(String method) {
- for (Method m : Method.values()) {
- if (m.toString().equalsIgnoreCase(method)) {
- return m;
- }
- }
- return null;
- }
- }
-
- /**
- * Pluggable strategy for asynchronously executing requests.
- */
- public interface AsyncRunner {
- void exec(Runnable code);
- }
-
- /**
- * Factory to create temp file managers.
- */
- public interface TempFileManagerFactory {
- TempFileManager create();
- }
-
- // ------------------------------------------------------------------------------- //
-
- /**
- * Temp file manager.
- *
- * Temp file managers are created 1-to-1 with incoming requests, to create and cleanup
- * temporary files created as a result of handling the request.
- */
- public interface TempFileManager {
- TempFile createTempFile() throws Exception;
-
- void clear();
- }
-
- /**
- * A temp file.
- *
- * Temp files are responsible for managing the actual temporary storage and cleaning
- * themselves up when no longer needed.
- */
- public interface TempFile {
- OutputStream open() throws Exception;
-
- void delete() throws Exception;
-
- String getName();
- }
-
- /**
- * Default threading strategy for NanoHttpd.
- *
- * By default, the server spawns a new Thread for every incoming request. These are set
- * to daemon status, and named according to the request number. The name is
- * useful when profiling the application.
- */
- public static class DefaultAsyncRunner implements AsyncRunner {
- private long requestCount;
-
- @Override
- public void exec(Runnable code) {
- ++requestCount;
- Thread t = new Thread(code);
- t.setDaemon(true);
- t.setName("NanoHttpd Request Processor (#" + requestCount + ")");
- t.start();
- }
- }
-
- /**
- * Default strategy for creating and cleaning up temporary files.
- *
- * This class stores its files in the standard location (that is,
- * wherever java.io.tmpdir points to). Files are added
- * to an internal list, and deleted when no longer needed (that is,
- * when clear() is invoked at the end of processing a
- * request).