DataAction applies headers if the headerInfo is present but the data is a failure

For example, consider a web app using CORS (a standard for cross-site scripting), where a controller method fails with a UserError.
WithHeaderInfo(RefFailed(UserError(msg)), RefItself(HeaderInfo(...)))
In this case, the error message needs to be returned to the client (to display the user's error) which means that the CORS headers in the response needs to be set.