Uploaded image for project: 'SwitchYard'
  1. SwitchYard
  2. SWITCHYARD-1717

RESTEasy request and response headers are set as List

    Details

      Description

      Keith Says:

      I'm trying to develop a custom context mapper for a REST binding and hitting an issue with setting header values. Let's say I want to add the header "foo" to a reply with a value of "123". The following code should get that done:

      public void mapTo(Context context, RESTEasyBindingData restData) throws Exception {
          // delegate to parent to pick up existing context mapping logic for RESTEasy
          super.mapTo(context, restData);
          // add a custom header
          restData.addHeader("foo", "123");
      }
      

      I do end up with a header named "foo", but unfortunately the value is "[123]" and not "123". I believe this is due to the use of CaseInsensitiveMap underneath the covers which use List<String> as the value of the map. This turns out to be a problem in the EndpointProxy logic which maps the BindingData headers to the response builder:

      https://github.com/jboss-switchyard/components/blob/master/resteasy/src/main/java/org/switchyard/component/resteasy/util/RESTEasyProxy.java#L107

      for (Map.Entry<String, List<String>> entry : responseData.getHeaders().entrySet()) {
      builder.header(entry.getKey(), entry.getValue());
      }
      

      Note that the header being added here is a List<String> instead of a String.

        Gliffy Diagrams

          Attachments

            Issue Links

              Activity

                People

                • Assignee:
                  mageshbk Magesh Bojan
                  Reporter:
                  mageshbk Magesh Bojan
                • Votes:
                  0 Vote for this issue
                  Watchers:
                  4 Start watching this issue

                  Dates

                  • Created:
                    Updated:
                    Resolved: