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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
|
from paste import wsgilib
from optparse import Option
def serve(conf, app):
url = conf.get('url', '/')
query_string = ''
if '?' in url:
url, query_string = url.split('?', 1)
quiet = conf.get('quiet', False)
status, headers, content, errors = wsgilib.raw_interactive(
app, url, QUERY_STRING=query_string)
any_header = False
if not quiet or int(status.split()[0]) != 200:
print 'Status:', status
any_header = True
for header, value in headers:
if quiet and (
header.lower() in ('content-type', 'content-length')
or (header.lower() == 'set-cookie'
and value.startswith('_SID_'))):
continue
print '%s: %s' % (header, value)
any_header = True
if any_header:
print
if conf.get('compact', False):
# Remove empty lines
content = '\n'.join([l for l in content.splitlines()
if l.strip()])
print content
if errors:
sys.stderr.write('-'*25 + ' Errors ' + '-'*25 + '\n')
sys.stderr.write(errors + '\n')
description = """\
Displays a single request to stdout
"""
options = [
Option('--url',
metavar='URL',
help="The URL (not including domain or port!) to GET"),
]
|