NetTalk Central

NetTalk Web Server => Web Server - Ask For Help => Topic started by: Larry Sand on October 01, 2013, 02:26:45 PM

Title: CORS header elements in _CreateHeader
Post by: Larry Sand 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
Title: Re: CORS header elements in _CreateHeader
Post by: Bruce on October 02, 2013, 06:25:40 AM
thanks Larry - fixed for 7.26