Spring Integration
  1. Spring Integration
  2. INT-2455

Spring Integration Http's HttpRequestExecutingMessageHandler and URI encoding

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Complete
    • Affects Version/s: 2.2.1
    • Fix Version/s: 3.0 M2
    • Component/s: HTTP Support
    • Labels:

      Description

      I'm trying to configure an http outbound-channel-adapter that performs a GET operation to URL "http://localhost/service?parameter=%2bsomething":

      <int-http:outbound-channel-adapter id="httpAdapter"
      url="http://localhost/service?parameter=%2bsomething
      channel="httpOutChannel"
      http-method="GET"
      expected-response-type="java.lang.String" />

      The url encoded '' character %2b gets encoded twice, and the server receives the parameter as "%252bsomething". If I exchange %2b with unencoded character '', it gets passed to the request as such ("/service?parameter=something") as '' is a valid URL character. The problem seems to be with HttpRequestExecutingMessageHandler passing the URI as a String to RestTemplate.exchange(), which only encodes characters that are not valid URL characters. RestTemplate URI encoding is discussed in issue
      SPR-5516.

        Activity

        Hide
        Richard Braman added a comment -

        I feel this should get backported to 2.2. I have tried to do two REST integrations (Amazon Web Services and RabbitMQ Http API and have run into this issue twice. Is there a workaround in 2.2.4 in the XML?

        Show
        Richard Braman added a comment - I feel this should get backported to 2.2. I have tried to do two REST integrations (Amazon Web Services and RabbitMQ Http API and have run into this issue twice. Is there a workaround in 2.2.4 in the XML?
        Hide
        Artem Bilan added a comment -

        Gary Russell, any objections?
        I can prepare minimal backport.
        The main concern is about encode-uri attribute to the 2.2 XSD...

        Show
        Artem Bilan added a comment - Gary Russell , any objections? I can prepare minimal backport. The main concern is about encode-uri attribute to the 2.2 XSD...
        Hide
        Richard Braman added a comment -

        just as a note, i tested the encode-uri attribute by simply updating SIversion in my project POM to <spring.integration.version>3.0.0.M2</spring.integration.version>. My program still uses http://www.springframework.org/schema/integration/http/spring-integration-http.xsd, and it recognizes encode-uri attribute anyway and works. not sure why...

        Show
        Richard Braman added a comment - just as a note, i tested the encode-uri attribute by simply updating SIversion in my project POM to <spring.integration.version>3.0.0.M2</spring.integration.version>. My program still uses http://www.springframework.org/schema/integration/http/spring-integration-http.xsd , and it recognizes encode-uri attribute anyway and works. not sure why...
        Hide
        Richard Braman added a comment -

        maybe because outbound-channel-adapter is not in the XSD???

        Show
        Richard Braman added a comment - maybe because outbound-channel-adapter is not in the XSD???
        Hide
        Artem Bilan added a comment -

        maybe because outbound-channel-adapter is not in the XSD?

        No. It is, because versionless XSD match to the latest version in the classpath. See here: https://github.com/SpringSource/spring-integration/blob/master/spring-integration-http/src/main/resources/META-INF/spring.schemas
        It is a Spring Handler strategy.
        BTW. If you already switched to the SI 3.0, stay with it. It fully backward compatible and doesn't have a lot new features (potentially 'bugged' )

        Show
        Artem Bilan added a comment - maybe because outbound-channel-adapter is not in the XSD? No. It is, because versionless XSD match to the latest version in the classpath. See here: https://github.com/SpringSource/spring-integration/blob/master/spring-integration-http/src/main/resources/META-INF/spring.schemas It is a Spring Handler strategy. BTW. If you already switched to the SI 3.0, stay with it. It fully backward compatible and doesn't have a lot new features (potentially 'bugged' )

          People

          • Assignee:
            Artem Bilan
            Reporter:
            janne kytömäki
          • Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Time Tracking

              Estimated:
              Original Estimate - Not Specified
              Not Specified
              Remaining:
              Remaining Estimate - 0d
              0d
              Logged:
              Time Spent - 1h
              1h