Mercurial > hg
annotate tests/test-hgweb-no-request-uri @ 6374:31a01e3d99cc
hgweb: fix breakage in python < 2.5 introduced in 2c370f08c486
author | Dirkjan Ochtman <dirkjan@ochtman.nl> |
---|---|
date | Mon, 24 Mar 2008 16:20:15 +0100 |
parents | f429e0e067a8 |
children | 4879468fa28f |
rev | line source |
---|---|
5579
e15f7db0f0ee
Use SCRIPT_NAME and PATH_INFO instead of REQUEST_URI. This is required by WSGI (fixes issue846).
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
1 #!/bin/sh |
5580
f429e0e067a8
Fix style nit and add some comments to tests.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
5579
diff
changeset
|
2 # This tests if hgweb and hgwebdir still work if the REQUEST_URI variable is |
f429e0e067a8
Fix style nit and add some comments to tests.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
5579
diff
changeset
|
3 # no longer passed with the request. Instead, SCRIPT_NAME and PATH_INFO |
f429e0e067a8
Fix style nit and add some comments to tests.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
5579
diff
changeset
|
4 # should be used from d74fc8dec2b4 onward to route the request. |
5579
e15f7db0f0ee
Use SCRIPT_NAME and PATH_INFO instead of REQUEST_URI. This is required by WSGI (fixes issue846).
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
5 |
e15f7db0f0ee
Use SCRIPT_NAME and PATH_INFO instead of REQUEST_URI. This is required by WSGI (fixes issue846).
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
6 mkdir repo |
e15f7db0f0ee
Use SCRIPT_NAME and PATH_INFO instead of REQUEST_URI. This is required by WSGI (fixes issue846).
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
7 cd repo |
e15f7db0f0ee
Use SCRIPT_NAME and PATH_INFO instead of REQUEST_URI. This is required by WSGI (fixes issue846).
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
8 hg init |
e15f7db0f0ee
Use SCRIPT_NAME and PATH_INFO instead of REQUEST_URI. This is required by WSGI (fixes issue846).
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
9 echo foo > bar |
e15f7db0f0ee
Use SCRIPT_NAME and PATH_INFO instead of REQUEST_URI. This is required by WSGI (fixes issue846).
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
10 hg add bar |
e15f7db0f0ee
Use SCRIPT_NAME and PATH_INFO instead of REQUEST_URI. This is required by WSGI (fixes issue846).
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
11 hg commit -m "test" -d "0 0" -u "Testing" |
e15f7db0f0ee
Use SCRIPT_NAME and PATH_INFO instead of REQUEST_URI. This is required by WSGI (fixes issue846).
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
12 hg tip |
e15f7db0f0ee
Use SCRIPT_NAME and PATH_INFO instead of REQUEST_URI. This is required by WSGI (fixes issue846).
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
13 |
e15f7db0f0ee
Use SCRIPT_NAME and PATH_INFO instead of REQUEST_URI. This is required by WSGI (fixes issue846).
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
14 cat > request.py <<EOF |
e15f7db0f0ee
Use SCRIPT_NAME and PATH_INFO instead of REQUEST_URI. This is required by WSGI (fixes issue846).
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
15 from mercurial.hgweb import hgweb, hgwebdir |
e15f7db0f0ee
Use SCRIPT_NAME and PATH_INFO instead of REQUEST_URI. This is required by WSGI (fixes issue846).
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
16 from StringIO import StringIO |
e15f7db0f0ee
Use SCRIPT_NAME and PATH_INFO instead of REQUEST_URI. This is required by WSGI (fixes issue846).
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
17 import os, sys |
e15f7db0f0ee
Use SCRIPT_NAME and PATH_INFO instead of REQUEST_URI. This is required by WSGI (fixes issue846).
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
18 |
e15f7db0f0ee
Use SCRIPT_NAME and PATH_INFO instead of REQUEST_URI. This is required by WSGI (fixes issue846).
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
19 errors = StringIO() |
e15f7db0f0ee
Use SCRIPT_NAME and PATH_INFO instead of REQUEST_URI. This is required by WSGI (fixes issue846).
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
20 input = StringIO() |
e15f7db0f0ee
Use SCRIPT_NAME and PATH_INFO instead of REQUEST_URI. This is required by WSGI (fixes issue846).
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
21 |
e15f7db0f0ee
Use SCRIPT_NAME and PATH_INFO instead of REQUEST_URI. This is required by WSGI (fixes issue846).
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
22 def startrsp(headers, data): |
e15f7db0f0ee
Use SCRIPT_NAME and PATH_INFO instead of REQUEST_URI. This is required by WSGI (fixes issue846).
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
23 print '---- HEADERS' |
e15f7db0f0ee
Use SCRIPT_NAME and PATH_INFO instead of REQUEST_URI. This is required by WSGI (fixes issue846).
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
24 print headers |
e15f7db0f0ee
Use SCRIPT_NAME and PATH_INFO instead of REQUEST_URI. This is required by WSGI (fixes issue846).
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
25 print '---- DATA' |
e15f7db0f0ee
Use SCRIPT_NAME and PATH_INFO instead of REQUEST_URI. This is required by WSGI (fixes issue846).
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
26 print data |
e15f7db0f0ee
Use SCRIPT_NAME and PATH_INFO instead of REQUEST_URI. This is required by WSGI (fixes issue846).
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
27 return output.write |
e15f7db0f0ee
Use SCRIPT_NAME and PATH_INFO instead of REQUEST_URI. This is required by WSGI (fixes issue846).
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
28 |
e15f7db0f0ee
Use SCRIPT_NAME and PATH_INFO instead of REQUEST_URI. This is required by WSGI (fixes issue846).
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
29 env = { |
e15f7db0f0ee
Use SCRIPT_NAME and PATH_INFO instead of REQUEST_URI. This is required by WSGI (fixes issue846).
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
30 'wsgi.version': (1, 0), |
e15f7db0f0ee
Use SCRIPT_NAME and PATH_INFO instead of REQUEST_URI. This is required by WSGI (fixes issue846).
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
31 'wsgi.url_scheme': 'http', |
e15f7db0f0ee
Use SCRIPT_NAME and PATH_INFO instead of REQUEST_URI. This is required by WSGI (fixes issue846).
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
32 'wsgi.errors': errors, |
e15f7db0f0ee
Use SCRIPT_NAME and PATH_INFO instead of REQUEST_URI. This is required by WSGI (fixes issue846).
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
33 'wsgi.input': input, |
e15f7db0f0ee
Use SCRIPT_NAME and PATH_INFO instead of REQUEST_URI. This is required by WSGI (fixes issue846).
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
34 'wsgi.multithread': False, |
e15f7db0f0ee
Use SCRIPT_NAME and PATH_INFO instead of REQUEST_URI. This is required by WSGI (fixes issue846).
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
35 'wsgi.multiprocess': False, |
e15f7db0f0ee
Use SCRIPT_NAME and PATH_INFO instead of REQUEST_URI. This is required by WSGI (fixes issue846).
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
36 'wsgi.run_once': False, |
e15f7db0f0ee
Use SCRIPT_NAME and PATH_INFO instead of REQUEST_URI. This is required by WSGI (fixes issue846).
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
37 'REQUEST_METHOD': 'GET', |
e15f7db0f0ee
Use SCRIPT_NAME and PATH_INFO instead of REQUEST_URI. This is required by WSGI (fixes issue846).
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
38 'SCRIPT_NAME': '', |
e15f7db0f0ee
Use SCRIPT_NAME and PATH_INFO instead of REQUEST_URI. This is required by WSGI (fixes issue846).
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
39 'SERVER_NAME': '127.0.0.1', |
e15f7db0f0ee
Use SCRIPT_NAME and PATH_INFO instead of REQUEST_URI. This is required by WSGI (fixes issue846).
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
40 'SERVER_PORT': os.environ['HGPORT'], |
e15f7db0f0ee
Use SCRIPT_NAME and PATH_INFO instead of REQUEST_URI. This is required by WSGI (fixes issue846).
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
41 'SERVER_PROTOCOL': 'HTTP/1.0' |
e15f7db0f0ee
Use SCRIPT_NAME and PATH_INFO instead of REQUEST_URI. This is required by WSGI (fixes issue846).
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
42 } |
e15f7db0f0ee
Use SCRIPT_NAME and PATH_INFO instead of REQUEST_URI. This is required by WSGI (fixes issue846).
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
43 |
e15f7db0f0ee
Use SCRIPT_NAME and PATH_INFO instead of REQUEST_URI. This is required by WSGI (fixes issue846).
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
44 output = StringIO() |
e15f7db0f0ee
Use SCRIPT_NAME and PATH_INFO instead of REQUEST_URI. This is required by WSGI (fixes issue846).
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
45 env['PATH_INFO'] = '/' |
e15f7db0f0ee
Use SCRIPT_NAME and PATH_INFO instead of REQUEST_URI. This is required by WSGI (fixes issue846).
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
46 env['QUERY_STRING'] = 'style=atom' |
e15f7db0f0ee
Use SCRIPT_NAME and PATH_INFO instead of REQUEST_URI. This is required by WSGI (fixes issue846).
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
47 hgweb('.', name = 'repo')(env, startrsp) |
e15f7db0f0ee
Use SCRIPT_NAME and PATH_INFO instead of REQUEST_URI. This is required by WSGI (fixes issue846).
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
48 print output.getvalue() |
e15f7db0f0ee
Use SCRIPT_NAME and PATH_INFO instead of REQUEST_URI. This is required by WSGI (fixes issue846).
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
49 print '---- ERRORS' |
e15f7db0f0ee
Use SCRIPT_NAME and PATH_INFO instead of REQUEST_URI. This is required by WSGI (fixes issue846).
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
50 print errors.getvalue() |
e15f7db0f0ee
Use SCRIPT_NAME and PATH_INFO instead of REQUEST_URI. This is required by WSGI (fixes issue846).
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
51 |
e15f7db0f0ee
Use SCRIPT_NAME and PATH_INFO instead of REQUEST_URI. This is required by WSGI (fixes issue846).
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
52 output = StringIO() |
e15f7db0f0ee
Use SCRIPT_NAME and PATH_INFO instead of REQUEST_URI. This is required by WSGI (fixes issue846).
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
53 env['PATH_INFO'] = '/file/tip/' |
e15f7db0f0ee
Use SCRIPT_NAME and PATH_INFO instead of REQUEST_URI. This is required by WSGI (fixes issue846).
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
54 env['QUERY_STRING'] = 'style=raw' |
e15f7db0f0ee
Use SCRIPT_NAME and PATH_INFO instead of REQUEST_URI. This is required by WSGI (fixes issue846).
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
55 hgweb('.', name = 'repo')(env, startrsp) |
e15f7db0f0ee
Use SCRIPT_NAME and PATH_INFO instead of REQUEST_URI. This is required by WSGI (fixes issue846).
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
56 print output.getvalue() |
e15f7db0f0ee
Use SCRIPT_NAME and PATH_INFO instead of REQUEST_URI. This is required by WSGI (fixes issue846).
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
57 print '---- ERRORS' |
e15f7db0f0ee
Use SCRIPT_NAME and PATH_INFO instead of REQUEST_URI. This is required by WSGI (fixes issue846).
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
58 print errors.getvalue() |
e15f7db0f0ee
Use SCRIPT_NAME and PATH_INFO instead of REQUEST_URI. This is required by WSGI (fixes issue846).
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
59 |
e15f7db0f0ee
Use SCRIPT_NAME and PATH_INFO instead of REQUEST_URI. This is required by WSGI (fixes issue846).
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
60 output = StringIO() |
e15f7db0f0ee
Use SCRIPT_NAME and PATH_INFO instead of REQUEST_URI. This is required by WSGI (fixes issue846).
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
61 env['PATH_INFO'] = '/' |
e15f7db0f0ee
Use SCRIPT_NAME and PATH_INFO instead of REQUEST_URI. This is required by WSGI (fixes issue846).
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
62 env['QUERY_STRING'] = 'style=raw' |
e15f7db0f0ee
Use SCRIPT_NAME and PATH_INFO instead of REQUEST_URI. This is required by WSGI (fixes issue846).
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
63 hgwebdir({'repo': '.'})(env, startrsp) |
e15f7db0f0ee
Use SCRIPT_NAME and PATH_INFO instead of REQUEST_URI. This is required by WSGI (fixes issue846).
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
64 print output.getvalue() |
e15f7db0f0ee
Use SCRIPT_NAME and PATH_INFO instead of REQUEST_URI. This is required by WSGI (fixes issue846).
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
65 print '---- ERRORS' |
e15f7db0f0ee
Use SCRIPT_NAME and PATH_INFO instead of REQUEST_URI. This is required by WSGI (fixes issue846).
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
66 print errors.getvalue() |
e15f7db0f0ee
Use SCRIPT_NAME and PATH_INFO instead of REQUEST_URI. This is required by WSGI (fixes issue846).
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
67 |
e15f7db0f0ee
Use SCRIPT_NAME and PATH_INFO instead of REQUEST_URI. This is required by WSGI (fixes issue846).
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
68 output = StringIO() |
e15f7db0f0ee
Use SCRIPT_NAME and PATH_INFO instead of REQUEST_URI. This is required by WSGI (fixes issue846).
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
69 env['PATH_INFO'] = '/repo/file/tip/' |
e15f7db0f0ee
Use SCRIPT_NAME and PATH_INFO instead of REQUEST_URI. This is required by WSGI (fixes issue846).
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
70 env['QUERY_STRING'] = 'style=raw' |
e15f7db0f0ee
Use SCRIPT_NAME and PATH_INFO instead of REQUEST_URI. This is required by WSGI (fixes issue846).
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
71 hgwebdir({'repo': '.'})(env, startrsp) |
e15f7db0f0ee
Use SCRIPT_NAME and PATH_INFO instead of REQUEST_URI. This is required by WSGI (fixes issue846).
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
72 print output.getvalue() |
e15f7db0f0ee
Use SCRIPT_NAME and PATH_INFO instead of REQUEST_URI. This is required by WSGI (fixes issue846).
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
73 print '---- ERRORS' |
e15f7db0f0ee
Use SCRIPT_NAME and PATH_INFO instead of REQUEST_URI. This is required by WSGI (fixes issue846).
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
74 print errors.getvalue() |
e15f7db0f0ee
Use SCRIPT_NAME and PATH_INFO instead of REQUEST_URI. This is required by WSGI (fixes issue846).
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
75 EOF |
e15f7db0f0ee
Use SCRIPT_NAME and PATH_INFO instead of REQUEST_URI. This is required by WSGI (fixes issue846).
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
76 |
e15f7db0f0ee
Use SCRIPT_NAME and PATH_INFO instead of REQUEST_URI. This is required by WSGI (fixes issue846).
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
77 python request.py | sed "s/http:\/\/127\.0\.0\.1:[0-9]*\//http:\/\/127.0.0.1\//" |