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