Skip to content

Instantly share code, notes, and snippets.

@beckje01
Created July 14, 2014 14:19
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 beckje01/30c886df1189f3d2dea7 to your computer and use it in GitHub Desktop.
Save beckje01/30c886df1189f3d2dea7 to your computer and use it in GitHub Desktop.
HttpClient Proxy Scratch
get { HttpClient httpClient ->
def result = httpClient.request("http://beckje01.com", { RequestSpec requestSpec ->
requestSpec.body.type("text/plain").stream { it << request.body.text }
requestSpec.method(request.method.toString())
request.headers.getNames().each {
requestSpec.headers.set(it, request.headers.get(it))
}
})
result.onError({
println it
context.render("Error!")
}).then({
context.render("Working: "+it.body.text)
})
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment