Skip to content

Commit

Permalink
fix nanohttpd error on Android L
Browse files Browse the repository at this point in the history
  • Loading branch information
xiaocong committed Jul 15, 2014
1 parent d2a5577 commit dbc38bc
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
2 changes: 1 addition & 1 deletion local.properties
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@
# location of the SDK. This is only used by Ant
# For customization when using a Version Control System, please read the
# header note.
sdk.dir=/home/b036/opt/adt-bundle/sdk
sdk.dir=/opt/android-studio/sdk
2 changes: 1 addition & 1 deletion nanohttpd
8 changes: 7 additions & 1 deletion src/com/github/uiautomatorstub/AutomatorHttpServer.java
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,13 @@ public Response serve(String uri, Method method,
}
} else if (router.containsKey(uri)) {
JsonRpcServer jsonRpcServer = router.get(uri);
ByteArrayInputStream is = new ByteArrayInputStream(params.get("NanoHttpd.QUERY_STRING").getBytes());
ByteArrayInputStream is = null;
if (params.get("NanoHttpd.QUERY_STRING") != null)
is = new ByteArrayInputStream(params.get("NanoHttpd.QUERY_STRING").getBytes());
else if (files.get("postData") != null)
is = new ByteArrayInputStream(files.get("postData").getBytes());
else
return new Response(Response.Status.INTERNAL_ERROR, MIME_PLAINTEXT, "Invalid http post data!");
ByteArrayOutputStream os = new ByteArrayOutputStream();
try {
jsonRpcServer.handle(is, os);
Expand Down

0 comments on commit dbc38bc

Please sign in to comment.