OK ... then I guess that the REST service expects "+" to be enoded (%2B). Is there a way to "enforce" the encoding of the plus sign to "%2B" using the URIBuilder for uri.path? If I replace the plus sign and assign the string to uri.path it gets encoded again (%252B) by replacing the "%" with "%25" ...
 
Thanks in advance
 
Gesendet: Sonntag, 20. November 2016 um 15:39 Uhr
Von: "David Clark" <[email protected]>
An: [email protected]
Betreff: Re: HTTPBuilder & URIBuilder - plus sign will not encoded

Plus sign is legal in URI's so they don't need to get encoded to be legal:

http://stackoverflow.com/questions/1547899/which-characters-make-a-url-invalid/1547940#1547940

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:

https://github.com/dwclark/http-builder-ng

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 + "/" + objectFile.name

groovyx.net.http.HTTPBuilder doRequest
FINE: PUT http://172.16.29.10/rest/TEST/space%20space.doc - Filename: space\ space.doc - OK

groovyx.net.http.HTTPBuilder doRequest
FINE: PUT http://172.16.29.10/rest/TEST/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

Reply via email to