Skip to content

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

New issue

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

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 4 commits into from

Conversation

artembilan
Copy link
Member

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

@@ -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);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)

@artembilan
Copy link
Member Author

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

@garyrussell
Copy link
Contributor

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).

@artembilan
Copy link
Member Author

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.

@artembilan
Copy link
Member Author

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

@garyrussell
Copy link
Contributor

Yes, I think it's ok

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
@artembilan
Copy link
Member Author

Pushed Reference Manual commit.

@garyrussell
Copy link
Contributor

LGTM; merging

garyrussell added a commit that referenced this pull request Apr 30, 2013
* INT-2455:
  INT-2455: Support HTTP Outbound 'encode-uri' Flag
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants