httpbuilder

Cannot install HTTPBuilder

拟墨画扇 提交于 2019-12-01 06:50:45
I'm trying to install HTTPBuilder like this: @Grab(group='org.codehaus.groovy.modules.http-builder', module='http-builder', version='0.7.2') However, I'm getting this error: java.lang.RuntimeException: Error grabbing Grapes -- [download failed: commons-lang#commons-lang;2.4!commons-lang.jar] $ grape -V resolve org.codehaus.groovy.modules.http-builder http-builder 0.7.2 :: loading settings :: url = jar:file:/home/zoran/.gvm/groovy/2.4.4/lib/ivy-2.4.0.jar!/org/apache/ivy/core/settings/ivysettings.xml no default ivy user dir defined: set to /home/zoran/.ivy2 including url: jar:file:/home/zoran/

Is there an easier way to tell HTTPBuilder to ignore an invalid cert?

六眼飞鱼酱① 提交于 2019-11-30 04:57:06
Per the docs , you can go through a rather clunky process of export a cert from a browser manually and getting it recognized locally. Is there anything similar to curl's --insecure switch to make this practical? Good news everyone! :-) Just found out that new version (0.7.1) of HttpBuilder introduces method: ignoreSSLIssues() This solves all problems regarding invalid SSL certificates (of course you have to be aware that it also decreases security). More information about this method: https://github.com/jgritman/httpbuilder/wiki/SSL (section at the bottom) Found a way that non involve import

POST with HTTPBuilder -> NullPointerException?

给你一囗甜甜゛ 提交于 2019-11-30 03:21:05
问题 I'm trying to make a simple HTTP POST request, and I have no idea why the following is failing. I tried following the examples here, and I don't see where I'm going wrong. Exception java.lang.NullPointerException at groovyx.net.http.HTTPBuilder$RequestConfigDelegate.setBody(HTTPBuilder.java:1131) ... Code def List<String> search(String query, int maxResults) { def http = new HTTPBuilder("mywebsite") http.request(POST) { uri.path = '/search/' body = [string1: "", query: "test"]

Groovy HTTPBuilder Mocking the Response

a 夏天 提交于 2019-11-28 11:08:46
I am trying to figure out how to write my Test cases for a service I am going to write. The service will use HTTPBuilder to request a response from some URL. The HTTPBuilder request only needs to check the response for a success or failure. The service implementation will be be something as simple as: boolean isOk() { httpBuilder.request(GET) { response.success = { return true } response.failure = { return false } } } So, I want to be able to mock the HTTPBuilder so that I can set the response to be either success/failure in my test so I can assert that my service's isOk method returns True

How to import groovyx.net.http

隐身守侯 提交于 2019-11-27 17:43:10
问题 I don't understand maven or grape, and I'm an idiot so give me the step by step if your answer is "go grap X-dependency manager and then rtfm and you're set." Where do i find and dump files to make this line work: import groovyx.net.http.HTTPBuilder It says Groovy: unable to resolve class groovyx.net.http.HTTPBuilder Also I am unable to import groovyx.net.http.ContentType.URLENC It says unable to resolve class groovyx.net.http.ContentType.URLENC Update: apparently you can uncomment the line

Groovy built-in REST/HTTP client?

孤人 提交于 2019-11-27 06:20:33
I heard that Groovy has a built-in REST/HTTP client. The only library I can find is HttpBuilder , is this it? Basically I'm looking for a way to do HTTP GETs from inside Groovy code without having to import any libraries (if at all possible). But since this module doesn't appear to be a part of core Groovy I'm not sure if I have the right lib here. Native Groovy GET and POST // GET def get = new URL("https://httpbin.org/get").openConnection(); def getRC = get.getResponseCode(); println(getRC); if(getRC.equals(200)) { println(get.getInputStream().getText()); } // POST def post = new URL("https:

Groovy HTTPBuilder Mocking the Response

橙三吉。 提交于 2019-11-27 05:58:57
问题 I am trying to figure out how to write my Test cases for a service I am going to write. The service will use HTTPBuilder to request a response from some URL. The HTTPBuilder request only needs to check the response for a success or failure. The service implementation will be be something as simple as: boolean isOk() { httpBuilder.request(GET) { response.success = { return true } response.failure = { return false } } } So, I want to be able to mock the HTTPBuilder so that I can set the