Announcement Announcement Module
Collapse
No announcement yet.
Possible bug in RestTemplate - double checking before opening a JIRA Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Possible bug in RestTemplate - double checking before opening a JIRA

    I'm trying to consume a somewhat non-standard type of URI of a RESTful web service (built with Spring MVC) via the RestTemplate - an example of this is:
    `http://localhost:8080/rest-sec/api/privilege?q=name=value`
    So, the parameter should be:
    name = `q`
    value = `name=jDiedXRD`
    The value is definitly non-standard, but as far as I can tell from the HTTP spec, it's not prohibited. Also, the same exact HTTP requests work fine with other HTTP Clients (rest-assured wich is using Apache HTTP Client underneath, same as RestTemplate is).
    Now, what RestTemplate does is this:
    HttpUrlTemplate it uses tries to parse the URI into UriComponents:
    `UriComponentsBuilder.fromUriString(uriTemplate).b uild();`
    This essentially fails to properly break out the parameter the regex - instead of seeing one single parameter, it seems to:
    `q=name`
    `value=null`
    Which is incorrect for one, but also there is no `&` character to delimit two parameters, so it could fail at the very least.
    The `=` character is something that should be allowed, but should be escaped - my understanding is that the escaping should happen inside the RestTemplate, but escaping the `=` before passing in the URI to the RestTemplate didn't work either (the template escapes the entire URI again - which results in an invalid URI).
    Is there something I'm missing on this, or should I open an issue to fix the regex in the UriComponentsBuilder so that it correctly identifies and parses out the parameters of this kind of URIs?
    Thank you.
    Eugen.
    Last edited by eugenparaschiv; Sep 12th, 2012, 05:05 PM.

  • #2
    In case anyone else runs into this, this is the JIRA (already answered): https://jira.springsource.org/browse/SPR-9791
    Thanks.
    Eugen.

    Comment

    Working...
    X