in stetho/src/main/java/com/facebook/stetho/dumpapp/DumpappHttpSocketLikeHandler.java [66:105]
public boolean handleRequest(
SocketLike socket,
LightHttpRequest request,
LightHttpResponse response) throws IOException {
boolean postMethod = "POST".equals(request.method);
boolean getMethod = !postMethod && "GET".equals(request.method);
if (getMethod || postMethod) {
List<String> argv = request.uri.getQueryParameters(QUERY_PARAM_ARGV);
ByteArrayOutputStream outputBuffer = new ByteArrayOutputStream();
Framer framer = new Framer(
new ByteArrayInputStream(new byte[0]),
outputBuffer);
String warningPrefix = postMethod ? "ERROR" : "WARNING";
framer.getStderr().println(
"*** " + warningPrefix + ": Using legacy HTTP protocol; update dumpapp script! ***");
if (getMethod) {
DumpappSocketLikeHandler.dump(mDumper, framer, argv.toArray(new String[argv.size()]));
} else {
// stdin access is completely unsupported, so we can't allow any dumper plugins
// to run...
framer.writeExitCode(1);
}
response.code = HttpStatus.HTTP_OK;
response.reasonPhrase = "OK";
response.addHeader(RESPONSE_HEADER_ALLOW_ORIGIN, "*");
response.body = LightHttpBody.create(outputBuffer.toByteArray(), CONTENT_TYPE);
} else {
response.code = HttpStatus.HTTP_NOT_IMPLEMENTED;
response.reasonPhrase = "Not implemented";
response.body = LightHttpBody.create(request.method + " not implemented", "text/plain");
}
return true;
}