diff --git a/src/teaonly/droideye/MainActivity.java b/src/teaonly/droideye/MainActivity.java index 72e3a60..64f10d5 100644 --- a/src/teaonly/droideye/MainActivity.java +++ b/src/teaonly/droideye/MainActivity.java @@ -128,14 +128,6 @@ private void initCamera() { } public String getLocalIpAddress() { - - AssetManager aman = getAssets(); - try { - AssetFileDescriptor assetFile = aman.openFd("demo.html"); - Log.d(TAG, "File length = " + assetFile.getLength() ); - } catch ( IOException ex) { - Log.d(TAG, ex.toString()); - } try { for (Enumeration en = NetworkInterface.getNetworkInterfaces(); en.hasMoreElements();) { diff --git a/src/teaonly/droideye/NanoHTTPD.java b/src/teaonly/droideye/NanoHTTPD.java index ad923b0..504c1f4 100644 --- a/src/teaonly/droideye/NanoHTTPD.java +++ b/src/teaonly/droideye/NanoHTTPD.java @@ -27,6 +27,7 @@ import android.content.res.Resources; import android.content.res.AssetManager; import android.content.res.AssetFileDescriptor; +import android.util.Log; /** * A simple, tiny, nicely embeddable HTTP 1.0 (partially 1.1) server in Java @@ -244,7 +245,7 @@ public NanoHTTPD( int port, File wwwroot ) throws IOException myTcpPort = port; myRootDir = wwwroot; myAssets = null; - + myServerSocket = new ServerSocket( myTcpPort ); beginDaemon(); } @@ -254,7 +255,7 @@ public NanoHTTPD( int port, AssetManager wwwroot ) throws IOException myTcpPort = port; myAssets = wwwroot; myRootDir = null; - + myServerSocket = new ServerSocket( myTcpPort ); beginDaemon(); } @@ -899,7 +900,7 @@ public Response serveFile( String uri, Properties header, File homeDir, Response res = null; if ( homeDir == null) { - serveAssets(uri, header); + return serveAssets(uri, header); } // Make sure we won't die of an exception later if ( !homeDir.isDirectory()) @@ -1090,6 +1091,9 @@ private Response serveAssets( String uri, Properties header) { // Remove URL arguments uri = uri.trim().replace( File.separatorChar, '/' ); + if ( uri.startsWith("/") ) { + uri = uri.substring(1, uri.length()); + } if ( uri.indexOf( '?' ) >= 0 ) uri = uri.substring(0, uri.indexOf( '?' )); @@ -1098,7 +1102,7 @@ private Response serveAssets( String uri, Properties header) { res = new Response( HTTP_FORBIDDEN, MIME_PLAINTEXT, "FORBIDDEN: Won't serve ../ for security reasons." ); } - + AssetFileDescriptor assetFile = null; try { assetFile = myAssets.openFd(uri);