Skip to content

Instantly share code, notes, and snippets.

@felipero
Created March 13, 2010 16:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save felipero/331403 to your computer and use it in GitHub Desktop.
Save felipero/331403 to your computer and use it in GitHub Desktop.
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