Created
March 13, 2010 16:15
-
-
Save felipero/331403 to your computer and use it in GitHub Desktop.
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
import groovyx.net.http.HTTPBuilder | |
import static groovyx.net.http.Method.GET | |
import static groovyx.net.http.ContentType.TEXT | |
class HTTPTester { | |
static void main(String[] args){ | |
def http = new HTTPBuilder( 'http://fratechit.appspot.com' ) | |
while(true) { | |
print new Date().time + ": " | |
http.request(GET,TEXT){ req -> | |
uri.path = '/recache'; | |
headers.'User-Agent' = 'Mozilla/5.0'; | |
response.success = { resp, reader -> | |
assert resp.statusLine.statusCode == 200 | |
println "My response handler got response: ${resp.statusLine}" | |
} | |
response.'404' = {resp -> | |
println 'Not found' | |
} | |
http.handler.failure = {resp -> | |
println "Unexpected failure: ${resp.statusLine}" | |
} | |
} | |
Thread.sleep(30000); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment