Created
June 11, 2019 02:57
-
-
Save snydergd/ab00bcbb11e445963f43ec0c303b4244 to your computer and use it in GitHub Desktop.
TCP Dumper Groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
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