File: test.cgi

package info (click to toggle)
python-httplib2 0.9%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 1,728 kB
  • ctags: 1,234
  • sloc: python: 5,183; makefile: 101
file content (28 lines) | stat: -rwxr-xr-x 695 bytes parent folder | download | duplicates (10)
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 ""