groovy-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From David Clark <>
Subject Re: HTTPBuilder & URIBuilder - plus sign will not encoded
Date Sun, 20 Nov 2016 19:20:32 GMT
I haven't used groovy-wslite, so any comparisons may be ignorant on my 
part. The main design goals of http-builder-ng are:

1) Use modern groovy DSL design 
( The original 
HTTPBuilder was nice but depended on propertyMissing/methodMissing magic 
to work.

2) Support full use of @CompileStatic/@TypeChecked.

3) Make IDE support natural through using @DelegatesTo everywhere (this 
also makes #2 possible).

4) Support multiple http clients. Right now both Apache Http Client and 
the native Java HttpURLConnection are fully supported. Adding new http 
clients should hopefully be simple.

5) Support threading and asynchronous calls safely and with no 
additional work on the part of users of http-builder-ng. Just give it an 
Executor and then use the async variants of the http verbs: getAsync() 
instead of get(), putAsync() instead of put() etc.

6) Adding new encoders and decoders is very easy.

7) Configuration should be cummulative and natural. This one is hard to 
describe, but it allows for applications to configure a single instance 
of HttpBuilder with default options and then every request can override 
or inherit those settings without affecting any other request or the 
single HttpBuilder instance.

8) Support interception of requests and responses to allow for logging, 
metrics, debugging etc.

9) High performance. We are using http-builder-ng for production 
applications at my job. We have seen cases where http-builder-ng + 
Apache Http Client will overwhelm a server with the load it can generate.

The README and User Guide go into this in more detail.

Taking a quick peek at groovy-wslite:

1) SOAP and multipart are supported natively by wslite. Adding SOAP 
support to http-builder-ng would mainly involve either using the native 
xml support directly or writing a custom encoder/decoder (should be 
pretty easy) that uses a SOAP library. Mulitpart support is on our list 
of things to do.

2) wslite allows for using Java 5. http-builder-ng requires Java 8.

3) wslite uses different classes to support different use cases 
(RESTClient, SOAPClient, etc.). http-builder-ng provides a single class 
that handles everything (HttpBuilder). Extending HttpBuilder is a matter 
of adding new encoders/decoders at runtime.

4) wslite handles network configuration at the top level. 
http-builder-ng depends upon http clients being configured correctly. 
This is nice because all features of the native clients 
(HttpURLConnection, Apache Http Client) are available. This is bad 
because you have to know about the features of the native clients, some 
of which are confusing.

Hope this helps.

On 11/20/2016 09:02 AM, Guillaume Laforge wrote:
> I didn't know about NG, David!
> These days, I tend to use groovy wslite:
> What are the pros & cons of http-builder-ng and wslite?
> On Sun, Nov 20, 2016 at 3:39 PM, David Clark < 
> <>> wrote:
>     Plus sign is legal in URI's so they don't need to get encoded to
>     be legal:
>     <>
>     This is complicated by the fact that they are url encoded when
>     part of the query string, but that's not what you are doing here.
>     It sounds to me like the problem is on the server or there some
>     other part of your request that is incorrect.
>     If there is a problem inside HTTPBuilder, you are probably out of
>     luck, that project has been dead for a while.
>     However, I have created a successor to HTTPBuilder called
>     http-builder-ng that is active here:
>     <>
>     It is NOT a backwards compatible upgrade. When I was examining the
>     original source code I found many threading issues, code
>     duplication, it was imposible to use @TypeChecked/@CompileStatic,
>     and found it hard to integrated different clients inside
>     HTTPBuilder. The result of these frustrations was a ground up
>     re-write. Bug reports/pull requests are encouraged.
>     On 11/20/2016 07:25 AM, Christian Lotz wrote:
>>     Hi all,
>>     I try to upload files via HTTPBuilder (Groovy Version: 2.4.7 JVM:
>>     1.8.0_40 Vendor: Oracle Corporation OS: Mac OS X). After a couple
>>     of test I realized, that filenames containing a plus sign ("+")
>>     can't be uploaded. The REST Service responds with HTTP/1.1 400
>>     Bad Request. After some more debugging I think these filenames
>>     will not get encoded correctly:
>>     uri.path = "/rest/" + objectNamespace + "/" +
>> doRequest
>>     FINE: PUT
>>     <>*pace%20space.doc* - Filename:
>>     space\ space.doc - OK
>> doRequest
>>     FINE: PUT*plus+plus.doc* -Filename
>>     plus+plus.doc - ERROR
>>     All other "special" characters like spaces, #, &, % or ? will
>>     get encoded correctly ...
>>     Does anybody know how to resolve this issue?
>>     Thanks in advance
>>     Paolo
> -- 
> Guillaume Laforge
> Apache Groovy committer & PMC Vice-President
> Developer Advocate @ Google Cloud Platform
> Blog:
> Social: @glaforge <> / Google+ 
> <>

View raw message