Uploaded image for project: 'Hippo CMS'
  1. Hippo CMS
  2. CMS-14102

Make sure responseheaders and locale are used from channel object in case present

    XMLWordPrintable

Details

    • Bug
    • Status: Closed
    • High
    • Resolution: Fixed
    • None
    • None
    • None
    • None

    Description

      In CMS-14051 support has been added to read property like Locale and ResponseHeaders from channel configuration instead of from mount configuration. However, it does not result in desired behavior yet.

      Requirements

      On the brx-saas project on

      http://localhost:8080/cms/console/?1&logintype=local&path=/hst:brxsaas/hst:configurations/brxsaas/hst:workspace/hst:channel

      configure

      hst:responseheaders = Access-Control-Allow-Origin: test
      

      After this, request

      http://localhost:8080/site/api/brxsaas/page/

      then the expected result is the response headers 'Access-Control-Allow-Origin: test' from the channel (similar for Locale, linkurlprefix, cdnhost in the PMA response...for which you need look at links, images, etc)

      Problem

      the problem is typically in code like this:

      private Map<String, String> getDefaultResponseHeaders(final HstRequestContext requestContext) {
              final ResolvedSiteMapItem resolvedSiteMapItem = requestContext.getResolvedSiteMapItem();
      
              if (resolvedSiteMapItem != null) {
                  return resolvedSiteMapItem.getHstSiteMapItem().getResponseHeaders();
              }
      
              final ResolvedMount resolvedMount = requestContext.getResolvedMount();
      
               if (resolvedMount != null) {
                  return resolvedMount.getResponseHeaders();
              }
      
              return null;
          }
      

      the ' resolvedSiteMapItem.getHstSiteMapItem().getResponseHeaders();' returns the headers from the sitemap item, and if there are not headers on the sitemap item, it returns the headers from the mount. However, those are not the headers from the Channel!!

      The headers from the channel are only returned when accessed via the flyweight object 'resolvedMount' as follows:

          @Override
          public Map<String, String> getResponseHeaders() {
              final Channel channel = mount.getChannel();
              if (channel != null && channel.getResponseHeaders() != null) {
                  return channel.getResponseHeaders();
              }
              return mount.getResponseHeaders();
          }
      

      Solution

      In SaaS, it is never needed that on sitemap item level the response headers or locale are overridden...the use case is just not there. So simple remove that part from sitemap items and always use the ResolvedMount to ask the headers for (same for locale)

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              aschrijvers Ard Schrijvers
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: