groovy-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Christian Lotz" <qoc...@gmx.de>
Subject Aw: Re: HTTPBuilder & URIBuilder - plus sign will not encoded
Date Sun, 20 Nov 2016 15:12:59 GMT
<html><head></head><body><div style="font-family: Verdana;font-size:
12.0px;"><div>OK&nbsp;... then I guess that the REST service expects &quot;+&quot;
to be enoded (%2B). Is there a way to &quot;enforce&quot; the encoding of the plus
sign to &quot;%2B&quot; using the URIBuilder for uri.path? If I&nbsp;replace the
plus sign&nbsp;and assign the string to uri.path it gets encoded again (%252B) by replacing
the &quot;%&quot; with &quot;%25&quot; ...</div>

<div>&nbsp;</div>

<div>Thanks in advance</div>

<div>&nbsp;
<div name="quote" style="margin:10px 5px 5px 10px; padding: 10px 0 10px 10px; border-left:2px
solid #C3D9E5; word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;">
<div style="margin:0 0 10px 0;"><b>Gesendet:</b>&nbsp;Sonntag, 20. November
2016 um 15:39 Uhr<br/>
<b>Von:</b>&nbsp;&quot;David Clark&quot; &lt;plotinussmith@gmail.com&gt;<br/>
<b>An:</b>&nbsp;users@groovy.apache.org<br/>
<b>Betreff:</b>&nbsp;Re: HTTPBuilder &amp; URIBuilder - plus sign will
not encoded</div>

<div name="quoted-content">
<div style="background-color: rgb(255,255,255);">
<p>Plus sign is legal in URI&#39;s so they don&#39;t need to get encoded to
be legal:</p>

<p><a class="moz-txt-link-freetext" href="http://stackoverflow.com/questions/1547899/which-characters-make-a-url-invalid/1547940#1547940"
target="_blank">http://stackoverflow.com/questions/1547899/which-characters-make-a-url-invalid/1547940#1547940</a></p>
This is complicated by the fact that they are url encoded when part of the query string, but
that&#39;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.<br/>
<br/>
If there is a problem inside HTTPBuilder, you are probably out of luck, that project has been
dead for a while.<br/>
<br/>
However, I have created a successor to HTTPBuilder called http-builder-ng that is active here:<br/>
<br/>
<a class="moz-txt-link-freetext" href="https://github.com/dwclark/http-builder-ng" target="_blank">https://github.com/dwclark/http-builder-ng</a><br/>
<br/>
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.<br/>
<br/>
&nbsp;
<div class="moz-cite-prefix">On 11/20/2016 07:25 AM, Christian Lotz wrote:</div>

<blockquote>
<div style="font-family: Verdana;font-size: 12.0px;">
<div><span style="font-family: lucida sans unicode , lucida grande , sans-serif;">Hi
all,</span></div>

<div>
<div><span style="font-family: lucida sans unicode , lucida grande , sans-serif;">I
try to&nbsp;upload&nbsp;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&nbsp;containing
a plus sign (&quot;+&quot;) can&#39;t be uploaded. The REST Service responds with&nbsp;HTTP/1.1
400 Bad Request. After some more debugging I think&nbsp;these filenames will not get encoded
correctly:</span></div>

<div>&nbsp;</div>

<div><span style="font-family: lucida sans unicode , lucida grande , sans-serif;">uri.path
= &quot;/rest/&quot; + objectNamespace + &quot;/&quot; + objectFile.name</span></div>

<div>
<p><span style="font-family: lucida sans unicode , lucida grande , sans-serif;">groovyx.net.http.HTTPBuilder
doRequest<br/>
FINE: PUT <a class="moz-txt-link-freetext" href="http://172.16.29.10/rest/TEST/s" target="_blank">http://172.16.29.10/rest/TEST/s</a><strong>pace%20space.doc</strong>
- Filename: space&#92; space.doc - OK</span></p>
</div>

<div>
<p><span style="font-family: lucida sans unicode , lucida grande , sans-serif;">groovyx.net.http.HTTPBuilder
doRequest<br/>
FINE: PUT <a class="moz-txt-link-freetext" href="http://172.16.29.10/rest/TEST/" target="_blank">http://172.16.29.10/rest/TEST/</a><strong>plus+plus.doc</strong>
-Filename plus+plus.doc - ERROR</span></p>
</div>

<div>&nbsp;</div>

<div><span style="font-family: lucida sans unicode , lucida grande , sans-serif;">All
other &quot;special&quot; characters like spaces, #, &amp;, % or ? will get&nbsp;encoded
correctly ... </span></div>

<div>&nbsp;</div>

<div><span style="font-family: lucida sans unicode , lucida grande , sans-serif;">Does
anybody know how to resolve this issue?</span></div>

<div>&nbsp;</div>

<div><span style="font-family: lucida sans unicode , lucida grande , sans-serif;">Thanks
in advance</span></div>

<div><span style="font-family: lucida sans unicode , lucida grande , sans-serif;">Paolo</span></div>
</div>
</div>
</blockquote>
</div>
</div>
</div>
</div></div></body></html>

Mime
View raw message