%PDF- %PDF-
Direktori : /lib/python3/dist-packages/twisted/web/test/__pycache__/ |
Current File : //lib/python3/dist-packages/twisted/web/test/__pycache__/test_cgi.cpython-312.pyc |
� Ϫ�f; � �� � d Z ddlZddlZddlZddlmZ ddlmZmZm Z m Z ddlmZ ddl mZmZmZ ddlmZ ddlmZmZmZmZmZmZ dd lmZmZ dd lmZ ddlm Z m!Z! dZ"d Z#dZ$dZ%dZ&dZ'dZ(dZ)dZ* G d� dejV � Z, G d� d� Z- G d� de-ej\ � Z/ G d� de-ej\ � Z0 G d� dej\ � Z1 G d� d ej\ � Z2d!� Z3y)"z! Tests for L{twisted.web.twcgi}. � N)�BytesIO)�address�error� interfaces�reactor)�ConnectionLost)�failure�log�util)�unittest)�client�http�http_headers�resource�server�twcgi)�INTERNAL_SERVER_ERROR� NOT_FOUND)�_render)�DummyChannel�DummyRequestz2print("Header: OK") print("") print("cgi output") zJprint("Header: spam") print("Header: eggs") print("") print("cgi output") z+print("XYZ") print("") print("cgi output") zPprint("Server: monkeys") print("Date: last year") print("") print("cgi output") a& # 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) print("Header: OK") print("") print("readinput ok") a+ # 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() print("Header: OK") print("") print("readallinput ok") zMprint("content-type: text/cgi-duplicate-test") print("") print("cgi output") z�import json import os print("") print("") vals = {x:y for x,y in os.environ.items() if x.startswith("HTTP_")} print(json.dumps(vals)) z]import os param = str(os.environ['QUERY_STRING']) print("Header: OK") print("") print(param) c �$ � e Zd Zej Zy)�PythonScriptN)�__name__� __module__�__qualname__�sys� executable�filter� � �;/usr/lib/python3/dist-packages/twisted/web/test/test_cgi.pyr r b s � � �^�^�Fr! r c � � e Zd Zd� Zd� Zd� Zy)�_StartServerAndTearDownMixinc �< � t j � }t j t |� }|j dt |� � t j |� }t j d|� | _ | j j � j S )Ns cgir )r �Resourcer �sibpath�__file__�putChildr r �Siter � listenTCP�p�getHost�port)�self�cgi�root�cgipath�sites r"