From dbc38bc4b57c921ac805a12bb9e8f9d5fcbf3a4b Mon Sep 17 00:00:00 2001 From: Xiaocong He Date: Tue, 15 Jul 2014 19:03:23 +0800 Subject: [PATCH] fix nanohttpd error on Android L --- local.properties | 2 +- nanohttpd | 2 +- src/com/github/uiautomatorstub/AutomatorHttpServer.java | 8 +++++++- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/local.properties b/local.properties index 374981a..468a443 100644 --- a/local.properties +++ b/local.properties @@ -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 diff --git a/nanohttpd b/nanohttpd index 8523184..ab6feae 160000 --- a/nanohttpd +++ b/nanohttpd @@ -1 +1 @@ -Subproject commit 852318439539b54ee6b4ce048df63b6c12cf0417 +Subproject commit ab6feae737b3038532d057e87fd83c58bad3b3cc diff --git a/src/com/github/uiautomatorstub/AutomatorHttpServer.java b/src/com/github/uiautomatorstub/AutomatorHttpServer.java index 589a428..f83419e 100644 --- a/src/com/github/uiautomatorstub/AutomatorHttpServer.java +++ b/src/com/github/uiautomatorstub/AutomatorHttpServer.java @@ -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);