Skip to content

Instantly share code, notes, and snippets.

@snydergd
Created June 11, 2019 02:57
Show Gist options
  • Save snydergd/ab00bcbb11e445963f43ec0c303b4244 to your computer and use it in GitHub Desktop.
Save snydergd/ab00bcbb11e445963f43ec0c303b4244 to your computer and use it in GitHub Desktop.
TCP Dumper Groovy
/*
Quick and dirty way to see raw requests made, for debugging.
*/
import java.net.ServerSocket
def server = new ServerSocket(4444)
while(true) {
server.accept { socket ->
socket.withStreams { input, output ->
byte[] buf = new byte[256]
def len
while ((len = input.read(buf)) == 256) {
System.out.write(buf, 0, len)
}
System.out.write(buf, 0, len)
output << "HTTP/1.1 200 OK\r\n"
output << "Content-Type: text/plain\r\n"
output << "\r\n"
output << "Success!\n\r"
}
println ""
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment