module documentation

Tests for twisted.web.twcgi.

Class CGIDirectoryTests Tests for twcgi.CGIDirectory.
Class CGIProcessProtocolTests Tests for twcgi.CGIProcessProtocol.
Class CGIScriptTests Tests for twcgi.CGIScript.
Class CGITests Tests for twcgi.FilteredScript.
Class PythonScript Undocumented
Function discardBody Discard the body of a HTTP response.
Constant BROKEN_HEADER_CGI Undocumented
Constant DUAL_HEADER_CGI Undocumented
Constant DUMMY_CGI Undocumented
Constant HEADER_OUTPUT_CGI Undocumented
Constant NO_DUPLICATE_CONTENT_TYPE_HEADER_CGI Undocumented
Constant READALLINPUT_CGI Undocumented
Constant READINPUT_CGI Undocumented
Constant SPECIAL_HEADER_CGI Undocumented
Constant URL_PARAMETER_CGI Undocumented
Class _StartServerAndTearDownMixin Undocumented
def discardBody(response): (source)

Discard the body of a HTTP response.

Parameters
responseThe response.
Returns
The response.
BROKEN_HEADER_CGI: str = (source)

Undocumented

Value
'''print("XYZ")
print("")
print("cgi output")
'''
DUAL_HEADER_CGI: str = (source)

Undocumented

Value
'''print("Header: spam")
print("Header: eggs")
print("")
print("cgi output")
'''
DUMMY_CGI: str = (source)

Undocumented

Value
'''print("Header: OK")
print("")
print("cgi output")
'''
HEADER_OUTPUT_CGI: str = (source)

Undocumented

Value
'''import json
import os
print("")
print("")
vals = {x:y for x,y in os.environ.items() if x.startswith("HTTP_")}
print(json.dumps(vals))
'''
NO_DUPLICATE_CONTENT_TYPE_HEADER_CGI: str = (source)

Undocumented

Value
'''print("content-type: text/cgi-duplicate-test")
print("")
print("cgi output")
'''
READALLINPUT_CGI: str = (source)

Undocumented

Value
'''# This is an example of the typical (incorrect) CGI script which expects
# the server to close stdin when the body of the request is complete.
# A correct CGI should only read env[\'CONTENT_LENGTH\'] bytes.

import sys

indata = sys.stdin.read()
...
READINPUT_CGI: str = (source)

Undocumented

Value
'''# This is an example of a correctly-written CGI script which reads a body
# from stdin, which only reads env[\'CONTENT_LENGTH\'] bytes.

import os, sys

body_length = int(os.environ.get(\'CONTENT_LENGTH\',0))
indata = sys.stdin.read(body_length)
...
SPECIAL_HEADER_CGI: str = (source)

Undocumented

Value
'''print("Server: monkeys")
print("Date: last year")
print("")
print("cgi output")
'''
URL_PARAMETER_CGI: str = (source)

Undocumented

Value
'''import cgi
fs = cgi.FieldStorage()
param = fs.getvalue("param")
print("Header: OK")
print("")
print(param)
'''