Commits

Alexander Shorin  committed 3abf6c3

Allow to specify custom header prefixes to ignore in strict mode

  • Participants
  • Parent commits cefaa14
  • Branches optional-strict-mode

Comments (0)

Files changed (2)

File httpdomain/doc/index.rst

 
 .. versionadded:: 1.3.0
 
+``http_headers_ignore_prefixes``
+   List of HTTP header prefixes which should be ignored in strict mode::
+
+       http_headers_ignore_prefixes = ['X-']
+
 ``http_index_ignore_prefixes``
    Strips the leading segments from the endpoint paths by given list
    of prefixes::

File httpdomain/sphinxcontrib/httpdomain.py

             if _header not in HEADER_REFS:
                 if not config['http_strict_mode']:
                     return [nodes.emphasis(header, header)], []
-                if _header.startswith('X-'):
+                _header = _header.lower()
+                if any([_header.startswith(prefix.lower())
+                        for prefix in config['http_headers_ignore_prefixes']]):
                     return [nodes.emphasis(header, header)], []
                 reporter = document.reporter
                 msg = reporter.error('%s is not unknown HTTP header' % header,
     app.add_config_value('http_index_shortname', 'routing table', True)
     app.add_config_value('http_index_localname', 'HTTP Routing Table', True)
     app.add_config_value('http_strict_mode', True, None)
+    app.add_config_value('http_headers_ignore_prefixes', ['X-'], None)