Created
November 29, 2012 23:20
-
-
Save bryanchug/4172603 to your computer and use it in GitHub Desktop.
HTTPBuilder with Proxy
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
@Grapes( | |
@Grab(group='org.codehaus.groovy', module='http-builder', version='0.4.1') | |
) | |
import groovyx.net.http.* | |
import static groovyx.net.http.ContentType.* | |
import static groovyx.net.http.Method.* | |
import org.apache.http.auth.* | |
def http = new HTTPBuilder( 'http://www.ipchicken.com' ) | |
http.client.getCredentialsProvider().setCredentials( | |
new AuthScope("myproxy.com", 8080), | |
new UsernamePasswordCredentials("proxy-username", "proxy-password") | |
) | |
http.setProxy('myproxy.com', 8080, 'http') | |
http.request( GET, TEXT ){ req -> | |
response.success = { resp, reader -> | |
println "Response: ${reader.text}" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
will it work in conjunction with my provider advanced.name/ru ?