Commit df021dfb authored by Jeffrey I. Schiller's avatar Jeffrey I. Schiller

Merge branch 'ucr'

parents ed0bfe01 6c4f0ac5
...@@ -200,7 +200,7 @@ public final class ProjectBuilder { ...@@ -200,7 +200,7 @@ public final class ProjectBuilder {
// Note (ralph): deleteRecursively has been removed from the guava-11.0.1 lib // Note (ralph): deleteRecursively has been removed from the guava-11.0.1 lib
// Replacing with deleteDirectory, which is supposed to delete the entire directory. // Replacing with deleteDirectory, which is supposed to delete the entire directory.
FileUtils.deleteDirectory(new File(projectRoot.getCanonicalPath())); FileUtils.deleteQuietly(new File(projectRoot.getCanonicalPath()));
} }
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
......
...@@ -122,8 +122,8 @@ public class AARLibrary { ...@@ -122,8 +122,8 @@ public class AARLibrary {
*/ */
public AARLibrary(final File aar) { public AARLibrary(final File aar) {
aarPath = aar; aarPath = aar;
String temp = aar.getAbsolutePath(); String temp = aar.getName();
name = temp.substring(temp.lastIndexOf('/'), temp.length()-4); name = temp.substring(0, temp.length()-4);
} }
public File getFile() { public File getFile() {
......
...@@ -397,7 +397,18 @@ public class NanoHTTPD ...@@ -397,7 +397,18 @@ public class NanoHTTPD
splitbyte++; splitbyte++;
// Write the part of body already read to ByteArrayOutputStream f // Write the part of body already read to ByteArrayOutputStream f
ByteArrayOutputStream f = new ByteArrayOutputStream(); OutputStream f;
if ( method.equalsIgnoreCase( "PUT" ) )
{
File tmpfile = File.createTempFile("upload", "bin");
tmpfile.deleteOnExit();
f = new FileOutputStream(tmpfile);
files.put("content", tmpfile.getAbsolutePath());
}
else
{
f = new ByteArrayOutputStream();
}
if (splitbyte < rlen) f.write(buf, splitbyte, rlen-splitbyte); if (splitbyte < rlen) f.write(buf, splitbyte, rlen-splitbyte);
// While Firefox sends on the first read all the data fitting // While Firefox sends on the first read all the data fitting
...@@ -421,17 +432,17 @@ public class NanoHTTPD ...@@ -421,17 +432,17 @@ public class NanoHTTPD
f.write(buf, 0, rlen); f.write(buf, 0, rlen);
} }
// Get the raw body as a byte []
byte [] fbuf = f.toByteArray();
// Create a BufferedReader for easily reading it as string.
ByteArrayInputStream bin = new ByteArrayInputStream(fbuf);
BufferedReader in = new BufferedReader( new InputStreamReader(bin));
// If the method is POST, there may be parameters // If the method is POST, there may be parameters
// in data section, too, read it: // in data section, too, read it:
if ( method.equalsIgnoreCase( "POST" )) if ( method.equalsIgnoreCase( "POST" ))
{ {
// Get the raw body as a byte []
byte [] fbuf = ((ByteArrayOutputStream)f).toByteArray();
// Create a BufferedReader for easily reading it as string.
ByteArrayInputStream bin = new ByteArrayInputStream(fbuf);
BufferedReader in = new BufferedReader( new InputStreamReader(bin));
String contentType = ""; String contentType = "";
String contentTypeHeader = header.getProperty("content-type"); String contentTypeHeader = header.getProperty("content-type");
StringTokenizer st = new StringTokenizer( contentTypeHeader , "; " ); StringTokenizer st = new StringTokenizer( contentTypeHeader , "; " );
...@@ -467,10 +478,12 @@ public class NanoHTTPD ...@@ -467,10 +478,12 @@ public class NanoHTTPD
postLine = postLine.trim(); postLine = postLine.trim();
decodeParms( postLine, parms ); decodeParms( postLine, parms );
} }
in.close();
}
else if ( method.equalsIgnoreCase( "PUT " ) )
{
f.close(); // Close open file
} }
if ( method.equalsIgnoreCase( "PUT" ))
files.put("content", saveTmpFile( fbuf, 0, f.size()));
// Ok, now do the serve() // Ok, now do the serve()
Response r = serve( uri, method, header, parms, files, mySocket ); Response r = serve( uri, method, header, parms, files, mySocket );
...@@ -479,7 +492,6 @@ public class NanoHTTPD ...@@ -479,7 +492,6 @@ public class NanoHTTPD
else else
sendResponse( r.status, r.mimeType, r.header, r.data ); sendResponse( r.status, r.mimeType, r.header, r.data );
in.close();
is.close(); is.close();
} }
catch ( IOException ioe ) catch ( IOException ioe )
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment