agentdebug icon indicating copy to clipboard operation
agentdebug copied to clipboard

Java Agent to remote debug HTTP

agentdebug

Place cloned classes in to the source tree

Add a dependency in build.gradle.kts

https://github.com/yschimke/agentdebug/blob/master/build.gradle.kts#L29

dependencies {
    implementation("com.squareup.okhttp3:okhttp:4.7.2")
}

Redefine classes without adding new methods.

https://github.com/yschimke/agentdebug/commit/e5d6c9af611cb275908984a099bd6bf5415aa4fe#diff-ddd8d9ae0cd2f8e615d74dad3e65acb6

  /**
   * Invoked immediately after receiving response headers.
   *
   * This method is always invoked after [responseHeadersStart].
   *
   * @param response the response received over the network. It is an error to access the body of
   *     this response.
   */
  open fun responseHeadersEnd(
    call: Call,
    response: Response
  ) {
+    println("RES: " + response.headers)
  }

Java Agent to remote debug HTTP

$ ./gradlew installDist
$ ./build/install/agent/bin/agent  37817

Process 37817 will start printing out any headers or whatever you program it to do.

okurl https://httpbin.org/delay/20
RES: date: Mon, 15 Jun 2020 20:12:13 GMT
content-type: application/json
content-length: 329
server: gunicorn/19.9.0
access-control-allow-origin: *
access-control-allow-credentials: true

...
Program output