NetTalk Central

Author Topic: CORS header elements in _CreateHeader  (Read 1524 times)

Larry Sand

  • Full Member
  • ***
  • Posts: 101
    • View Profile
CORS header elements in _CreateHeader
« on: October 01, 2013, 02:26:45 PM »
Bruce,

NetWebServer._CreateHeader() has a couple of errors:

  if p_HeaderDetails.AccessControlAllowOrigin <> ''
    HeaderStr.Append('Access-Control-Allow-Origin ' & clip (p_HeaderDetails.AccessControlAllowOrigin) & '<13,10>')
  end
  if p_HeaderDetails.AccessControlAllowCredentials <> ''
    HeaderStr.Append('Access-Control-Allow-Credentials ' & clip (p_HeaderDetails.AccessControlAllowCredentials) & '<13,10>')
  end
  if p_HeaderDetails.AccessControlAllowOrigin <> ''
    HeaderStr.Append('Access-Control-Allow-Methods ' & clip (p_HeaderDetails.AccessControlAllowMethods) & '<13,10>')
  end
  if p_HeaderDetails.AccessControlMaxAge <> ''
    HeaderStr.Append('Access-Control-Allow-MaxAge ' & clip (p_HeaderDetails.AccessControlMaxAge) & '<13,10>')
  end



Should be:

  if p_HeaderDetails.AccessControlAllowOrigin <> ''
    HeaderStr = clip (HeaderStr) & 'Access-Control-Allow-Origin: ' & clip (p_HeaderDetails.AccessControlAllowOrigin) & '<13,10>'
  end
  if p_HeaderDetails.AccessControlAllowCredentials <> ''
    HeaderStr = clip (HeaderStr) & 'Access-Control-Allow-Credentials: ' & clip (p_HeaderDetails.AccessControlAllowCredentials) & '<13,10>'
  end
  if p_HeaderDetails.AccessControlAllowMethods <> ''
    HeaderStr = clip (HeaderStr) & 'Access-Control-Allow-Methods: ' & clip (p_HeaderDetails.AccessControlAllowMethods) & '<13,10>'
  end
  if p_HeaderDetails.AccessControlMaxAge <> ''
    HeaderStr = clip (HeaderStr) & 'Access-Control-Allow-MaxAge: ' & clip (p_HeaderDetails.AccessControlMaxAge) & '<13,10>'
  end

There are missing colons and the condition on the allow methods are changed.

Thanks,
Larry Sand

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11191
    • View Profile
Re: CORS header elements in _CreateHeader
« Reply #1 on: October 02, 2013, 06:25:40 AM »
thanks Larry - fixed for 7.26