MCPcopy
hub / github.com/benoitc/gunicorn / write_error

Function write_error

gunicorn/util.py:354–374  ·  view source on GitHub ↗
(sock, status_int, reason, mesg)

Source from the content-addressed store, hash-verified

352
353
354def write_error(sock, status_int, reason, mesg):
355 html_error = textwrap.dedent("""\
356 <html>
357 <head>
358 <title>%(reason)s</title>
359 </head>
360 <body>
361 <h1><p>%(reason)s</p></h1>
362 %(mesg)s
363 </body>
364 </html>
365 """) % {"reason": reason, "mesg": html.escape(mesg)}
366
367 http = textwrap.dedent("""\
368 HTTP/1.1 %s %s\r
369 Connection: close\r
370 Content-Type: text/html\r
371 Content-Length: %d\r
372 \r
373 %s""") % (str(status_int), reason, len(html_error), html_error)
374 write_nonblock(sock, http.encode('latin1'))
375
376
377def _called_with_wrong_args(f):

Callers

nothing calls this directly

Calls 2

write_nonblockFunction · 0.85
encodeMethod · 0.80

Tested by

no test coverage detected