Definition at line 437 of file httpdomain.py.
◆ result_nodes()
def httpdomain.httpdomain.HTTPXRefStatusRole.result_nodes |
( |
|
self, |
|
|
|
document, |
|
|
|
env, |
|
|
|
node, |
|
|
|
is_ref |
|
) |
| |
Definition at line 439 of file httpdomain.py.
439 def result_nodes(self, document, env, node, is_ref):
440 def get_code_status(text):
443 return code, HTTP_STATUS_CODES.get(code)
446 code, status = re.split(
r'\s', text.strip(), 1)
450 known_status = HTTP_STATUS_CODES.get(code)
451 if known_status
is None:
453 elif known_status.lower() != status.lower():
458 def report_unknown_code():
459 if not config[
'http_strict_mode']:
460 return [nodes.emphasis(text, text)], []
461 reporter = document.reporter
462 msg = reporter.error(
'%d is unknown HTTP status code' % code,
464 prb = nodes.problematic(text, text)
467 def report_invalid_code():
468 if not config[
'http_strict_mode']:
469 return [nodes.emphasis(text, text)], []
470 reporter = document.reporter
471 msg = reporter.error(
472 'HTTP status code must be an integer (e.g. `200`) or '
473 'start with an integer (e.g. `200 OK`); %r is invalid' %
477 prb = nodes.problematic(text, text)
481 rawsource = node[0].rawsource
482 config = env.domains[
'http'].env.config
484 code, status = get_code_status(text)
486 return report_invalid_code()
488 return report_unknown_code()
490 url =
'http://www.ietf.org/rfc/rfc3229.txt'
492 url =
'http://www.ietf.org/rfc/rfc2324.txt'
494 url =
'http://tools.ietf.org/html/rfc6585#section-4'
496 url =
'http://msdn.microsoft.com/en-us/library/dd891478(v=prot.10).aspx'
498 url =
'http://www.ietf.org/rfc/rfc7725.txt'
499 elif code
in WEBDAV_STATUS_CODES:
500 url =
'http://tools.ietf.org/html/rfc4918#section-11.%d' % (WEBDAV_STATUS_CODES.index(code) + 1)
501 elif code
in HTTP_STATUS_CODES:
502 url =
'http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html' \
503 '#sec10.' + (
'%d.%d' % (code // 100, 1 + code % 100))
506 node = nodes.reference(rawsource,
'%d %s' % (code, status), refuri=url)
References consensus-simulation.int.
The documentation for this class was generated from the following file: