Created
February 20, 2018 21:45
-
-
Save t3knoid/f1ce4c1848915c194d0cb2538eb63a6b to your computer and use it in GitHub Desktop.
Groovy example of printing groovy header fields after openConnection() call
This file contains hidden or 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
def NEW_LINE = System.getProperty("line.separator") | |
if (args.length < 1) | |
{ | |
println "Enter a URL as an argument." | |
System.exit(-1) | |
} | |
def address = args[0] | |
def urlInfo = address.toURL() | |
println "====================================================================" | |
println "====== HEADER FIELDS FOR URL ${address}" | |
println "====================================================================" | |
def connection = urlInfo.openConnection() | |
headerFields = connection.getHeaderFields() | |
headerFields.each {println it} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment