test-server/instrumentation-backend/src/sh/calaba/instrumentationbackend/actions/NanoHTTPD.java in calabash-android-0.2.12 vs test-server/instrumentation-backend/src/sh/calaba/instrumentationbackend/actions/NanoHTTPD.java in calabash-android-0.2.13
- old
+ new
@@ -350,11 +350,11 @@
// 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));
+ BufferedReader in = new BufferedReader( new InputStreamReader(bin, "UTF-8"));
// If the method is POST, there may be parameters
// in data section, too, read it:
if ( method.equalsIgnoreCase( "POST" ))
{
@@ -376,9 +376,19 @@
sendError( HTTP_BADREQUEST, "BAD REQUEST: Content type is multipart/form-data but boundary syntax error. Usage: GET /example/file.html" );
st.nextToken();
String boundary = st.nextToken();
decodeMultipartData(boundary, fbuf, in, parms, files);
+ }
+ else if (contentType.toLowerCase().startsWith("application/json"))
+ {
+ StringBuffer sb = new StringBuffer();
+ String line = null;
+ while ((line = in.readLine()) != null)
+ {
+ sb.append(line + "\n");
+ }
+ parms.put("json", sb.toString());
}
else
{
// Handle application/x-www-form-urlencoded
String postLine = "";