File: test-hgweb-no-path-info

package info (click to toggle)
mercurial 1.6.4-1%2Bdeb6u1
  • links: PTS, VCS
  • area: main
  • in suites: squeeze-lts
  • size: 17,928 kB
  • ctags: 6,062
  • sloc: python: 44,238; sh: 20,985; tcl: 3,578; ansic: 2,557; lisp: 1,412; makefile: 176; xml: 15
file content (60 lines) | stat: -rwxr-xr-x 1,371 bytes parent folder | download | duplicates (2)
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#!/bin/sh
# This tests if hgweb and hgwebdir still work if the REQUEST_URI variable is
# no longer passed with the request. Instead, SCRIPT_NAME and PATH_INFO
# should be used from d74fc8dec2b4 onward to route the request.

mkdir repo
cd repo
hg init
echo foo > bar
hg add bar
hg commit -m "test" -u "Testing"
hg tip

cat > request.py <<EOF
from mercurial.hgweb import hgweb, hgwebdir
from StringIO import StringIO
import os, sys

errors = StringIO()
input = StringIO()

def startrsp(headers, data):
	print '---- HEADERS'
	print headers
	print '---- DATA'
	print data
	return output.write

env = {
	'wsgi.version': (1, 0),
	'wsgi.url_scheme': 'http',
	'wsgi.errors': errors,
	'wsgi.input': input,
	'wsgi.multithread': False,
	'wsgi.multiprocess': False,
	'wsgi.run_once': False,
	'REQUEST_METHOD': 'GET',
	'SCRIPT_NAME': '',
	'SERVER_NAME': '127.0.0.1',
	'SERVER_PORT': os.environ['HGPORT'],
	'SERVER_PROTOCOL': 'HTTP/1.0'
}

def process(app):
    content = app(env, startrsp)
    sys.stdout.write(output.getvalue())
    sys.stdout.write(''.join(content))
    print '---- ERRORS'
    print errors.getvalue()

output = StringIO()
env['QUERY_STRING'] = 'style=atom'
process(hgweb('.', name='repo'))

output = StringIO()
env['QUERY_STRING'] = 'style=raw'
process(hgwebdir({'repo': '.'}))
EOF

python request.py | sed "s/http:\/\/127\.0\.0\.1:[0-9]*\//http:\/\/127.0.0.1\//"