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 {
// Note (ralph): deleteRecursively has been removed from the guava-11.0.1 lib
// 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) {
e.printStackTrace();
......
......@@ -122,8 +122,8 @@ public class AARLibrary {
*/
public AARLibrary(final File aar) {
aarPath = aar;
String temp = aar.getAbsolutePath();
name = temp.substring(temp.lastIndexOf('/'), temp.length()-4);
String temp = aar.getName();
name = temp.substring(0, temp.length()-4);
}
public File getFile() {
......
......@@ -397,7 +397,18 @@ public class NanoHTTPD
splitbyte++;
// 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);
// While Firefox sends on the first read all the data fitting
......@@ -421,17 +432,17 @@ public class NanoHTTPD
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
// in data section, too, read it:
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 contentTypeHeader = header.getProperty("content-type");
StringTokenizer st = new StringTokenizer( contentTypeHeader , "; " );
......@@ -467,10 +478,12 @@ public class NanoHTTPD
postLine = postLine.trim();
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()
Response r = serve( uri, method, header, parms, files, mySocket );
......@@ -479,7 +492,6 @@ public class NanoHTTPD
else
sendResponse( r.status, r.mimeType, r.header, r.data );
in.close();
is.close();
}
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