#!/usr/bin/env python3 import os import sys content_type = os.environ.get('CONTENT_TYPE', '') data = ''.join(sys.stdin.readlines()) sys.stdout.write( 'Content-Type: text/html; charset=UTF-8\r\n\r\n' '\n' '
\n' '\n' 'This test makes sure that forms POSTed with a content-type of text/plain actually send data in text/plain\n' '
\n' ) if content_type == 'text/plain': sys.stdout.write('SUCCESS: Content-type is text/plain.
') else: sys.stdout.write('FAIL: Content-type should be text/plain, but was \'{}\'
'.format(content_type)) if data == 'f1=This is field #1 &!@$%\r\n=\'<>\r\nf2=This is field #2 ""\r\n': sys.stdout.write('SUCCESS
') else: sys.stdout.write('FAILURE: {}
'.format(data)) sys.stdout.write( '\n' '\n' '\n' )