Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

INT-2455: HTTP outbound 'encode-uri' flag support #755

Closed
wants to merge 4 commits into
from

Conversation

Projects
None yet
2 participants
Member

artembilan commented Feb 27, 2013

Now <http:outbound-channel-adapter> and <http:outbound-gateway> provide
encode-uri="false" option do not encode request uri.
It can be useful in some scenarios with non standard URL, e.g. RabbitMQ REST API:
'http://foo.RabbitMQ.com/api/queues/%2f/bar.queue'

https://jira.springsource.org/browse/INT-2455

@garyrussell garyrussell commented on an outdated diff Mar 13, 2013

...http/outbound/HttpRequestExecutingMessageHandler.java
@@ -348,7 +362,9 @@ protected Object handleRequestMessage(Message<?> requestMessage) {
Class<?> expectedResponseType = this.determineExpectedResponseType(requestMessage);
HttpEntity<?> httpRequest = this.generateHttpRequest(requestMessage, httpMethod);
- ResponseEntity<?> httpResponse = this.restTemplate.exchange(uri, httpMethod, httpRequest, expectedResponseType, uriVariables);
+ UriComponents uriComponents = UriComponentsBuilder.fromHttpUrl(uri).buildAndExpand(uriVariables);
@garyrussell

garyrussell Mar 13, 2013

Member

Artem, I believe you need to continue to use fromUriString() as is currently used by the RestTemplate. The problem with using fromHttpUrl is that if there's a fragment component (e.g http://......xyz?foo#bar), and encode-url="true" the # will incorrectly be encoded...

junit.framework.ComparisonFailure: null expected:<...xx/si.test.queue?foo[#]bar> but was:<...xx/si.test.queue?foo[%23]bar>
at junit.framework.Assert.assertEquals(Assert.java:81)
Member

artembilan commented Mar 13, 2013

Exactly, Gary!
So, pushed with test to cover '#' issue.

Member

garyrussell commented Mar 15, 2013

Hmmm - we have some inconsistency here with uri Vs. url (url, url-expression, encode-uri, uri-variable).

I wonder if we should take this opportunity to make them consistent - or at least, perhaps, provide aliases for url and url-expression (uri, uri-expression).

Member

artembilan commented Mar 15, 2013

IMO we may leave it as is. See UriComponentsBuilder: fromHttpUrl, uriVariableValues, encode URI. This is established tradition, that we say about HTTP as URL, but tell about its parts as URI.

Member

artembilan commented Apr 5, 2013

BTW, if it's OK I'll add a note to the Reference Manual

Member

garyrussell commented Apr 5, 2013

Yes, I think it's ok

artembilan added some commits Feb 26, 2013

@artembilan artembilan INT-2455: HTTP outbound 'encode-uri' flag support
Now `<http:outbound-channel-adapter>` and `<http:outbound-gateway>` provide
`encode-uri="false"` option do not encode request uri.
It can be useful in some scenarios with non standard URL, e.g. RabbitMQ REST API:
'http://foo.RabbitMQ.com/api/queues/%2f/bar.queue'

https://jira.springsource.org/browse/INT-2455
d3a28ae
@artembilan artembilan INT-2455: Polishing according PR comments 302df71
@artembilan artembilan INT-2455: Add 'encode-uri' to the Manual 9fe8a83
@artembilan artembilan INT-2455: 'encode-uri' in the Reference Manual 3ed098d
Member

artembilan commented Apr 10, 2013

Pushed Reference Manual commit.

Member

garyrussell commented Apr 30, 2013

LGTM; merging

@garyrussell garyrussell added a commit that referenced this pull request Apr 30, 2013

@garyrussell garyrussell Merge pull request #755 from artembilan/INT-2455
* INT-2455:
  INT-2455: Support HTTP Outbound 'encode-uri' Flag
5d1759c
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment