1#!/usr/bin/env python 2import os 3 4# Always returns an empty response body 5# and adds in the X-Method: header with the 6# method that was sent to the CGI 7 8method = os.environ['REQUEST_METHOD'] 9if "GET" == method: 10 if "123456789" == os.environ.get('HTTP_IF_NONE_MATCH', ''): 11 print "Status: 304 Not Modified" 12 else: 13 print "Status: 200 Ok" 14 print "ETag: 123456789" 15 print "" 16elif method in ["PUT", "PATCH", "DELETE"]: 17 if "123456789" == os.environ.get('HTTP_IF_MATCH', ''): 18 print "Status: 200 Ok" 19 print "" 20 else: 21 print "Status: 412 Precondition Failed" 22 print "" 23else: 24 print "Status: 405 Method Not Allowed" 25 print "" 26 27 28 29