dvGlobalPrivacyControl function

bool dvGlobalPrivacyControl(
  1. Map<String, String> headers
)

Whether headers carry a Global Privacy Control signal.

One value counts. Sec-GPC: 0 is a browser saying it is not sending the signal, which is not consent to anything and is certainly not an opt-out, and no other value is defined.

Header names are matched without case, because they arrive lower-cased from every server this runs behind and are written Sec-GPC everywhere else.

Implementation

bool dvGlobalPrivacyControl(Map<String, String> headers) {
  for (final MapEntry<String, String> header in headers.entries) {
    if (header.key.toLowerCase() != 'sec-gpc') continue;
    if (header.value.trim() == '1') return true;
  }
  return false;
}