One comment on “Xposed: Hook and Read okhttp3.Response Body Without Failures

  1. Hello, I’m trying to do same thing in Android 6.0 API 23 which uses package as “com.android.okhttp” , here is my edited code based on your approach. But it always returns an empty response body.

    XposedHelpers.findAndHookConstructor(“com.android.okhttp.Response”, lpparam.classLoader, “com.android.okhttp.Response$Builder”, new XC_MethodHook() {
    @Override
    protected void afterHookedMethod(MethodHookParam param) throws Throwable {
    Object responseBody = XposedHelpers.getObjectField(param.args[0], “body”);
    if (responseBody != null) {
    if (responseBody.getClass().getCanonicalName().equals(“com.android.okhttp.internal.http.RealResponseBody”)) {
    Object source = XposedHelpers.getObjectField(responseBody, “source”);
    Object buffer = XposedHelpers.callMethod(source, “buffer”);
    Object copy = XposedHelpers.callMethod(buffer, “clone”);
    Object body = XposedHelpers.callMethod(copy, “readUtf8”);
    new MyLogger().log(TAG, “okhttp3.Response constructor body : ” + body);
    }
    }
    }

    });

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s