0x1949 Team - FAZEMRX - MANAGER
Edit File: test_cgi.cpython-310.pyc
o �b; � @ sT 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 dd� dej+�Z,G dd� d�Z-G dd� de-ej.�Z/G dd� de-ej.�Z0G dd� dej.�Z1G dd � d ej.�Z2d!d"� Z3dS )#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)) zkimport cgi fs = cgi.FieldStorage() param = fs.getvalue("param") print("Header: OK") print("") print(param) c @ s e Zd ZejZdS )�PythonScriptN)�__name__� __module__�__qualname__�sys� executable�filter� r r �;/usr/lib/python3/dist-packages/twisted/web/test/test_cgi.pyr c s r c @ s$ e Zd Zdd� Zdd� Zdd� ZdS )�_StartServerAndTearDownMixinc C sH t �� }t�t|�}|�dt|�� t�|�}t � d|�| _| j�� j S )Ns cgir )r �Resourcer �sibpath�__file__�putChildr r �Siter � listenTCP�p�getHost�port)�self�cgi�root�cgipath�siter r r �startServerh s z(_StartServerAndTearDownMixin.startServerc C s t | dd �r| j�� S d S )Nr'