Created
June 11, 2019 01:46
-
-
Save snydergd/49dbf63d3614e7ad242a324014ca98d0 to your computer and use it in GitHub Desktop.
HTTP Dumper
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
import com.sun.net.httpserver.HttpServer | |
HttpServer.create(new InetSocketAddress(8899), 0).with { | |
createContext("/") { http -> | |
http.with { | |
println (requestMethod + " " + requestURI + " HTTP/1.1") | |
requestHeaders.each{ | |
a,b -> b.each{ | |
y -> println a + ": " + y | |
} | |
} | |
println "" | |
System.out << requestBody | |
requestBody.close() | |
println "" | |
} | |
http.responseHeaders.add("Content-type", "text/plain") | |
http.sendResponseHeaders(200, 0) | |
http.responseBody.withWriter { out -> | |
out << "Hello ${http.remoteAddress.hostName}!" | |
} | |
} | |
start() | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment