|
1 This tests if hgweb and hgwebdir still work if the REQUEST_URI variable is |
|
2 no longer passed with the request. Instead, SCRIPT_NAME and PATH_INFO |
|
3 should be used from d74fc8dec2b4 onward to route the request. |
|
4 |
|
5 $ mkdir repo |
|
6 $ cd repo |
|
7 $ hg init |
|
8 $ echo foo > bar |
|
9 $ hg add bar |
|
10 $ hg commit -m "test" |
|
11 $ hg tip |
|
12 changeset: 0:61c9426e69fe |
|
13 tag: tip |
|
14 user: test |
|
15 date: Thu Jan 01 00:00:00 1970 +0000 |
|
16 summary: test |
|
17 |
|
18 $ cat > request.py <<EOF |
|
19 > from mercurial.hgweb import hgweb, hgwebdir |
|
20 > from StringIO import StringIO |
|
21 > import os, sys |
|
22 > |
|
23 > errors = StringIO() |
|
24 > input = StringIO() |
|
25 > |
|
26 > def startrsp(status, headers): |
|
27 > print '---- STATUS' |
|
28 > print status |
|
29 > print '---- HEADERS' |
|
30 > print [i for i in headers if i[0] != 'ETag'] |
|
31 > print '---- DATA' |
|
32 > return output.write |
|
33 > |
|
34 > env = { |
|
35 > 'wsgi.version': (1, 0), |
|
36 > 'wsgi.url_scheme': 'http', |
|
37 > 'wsgi.errors': errors, |
|
38 > 'wsgi.input': input, |
|
39 > 'wsgi.multithread': False, |
|
40 > 'wsgi.multiprocess': False, |
|
41 > 'wsgi.run_once': False, |
|
42 > 'REQUEST_METHOD': 'GET', |
|
43 > 'SCRIPT_NAME': '', |
|
44 > 'SERVER_NAME': '127.0.0.1', |
|
45 > 'SERVER_PORT': os.environ['HGPORT'], |
|
46 > 'SERVER_PROTOCOL': 'HTTP/1.0' |
|
47 > } |
|
48 > |
|
49 > def process(app): |
|
50 > content = app(env, startrsp) |
|
51 > sys.stdout.write(output.getvalue()) |
|
52 > sys.stdout.write(''.join(content)) |
|
53 > print '---- ERRORS' |
|
54 > print errors.getvalue() |
|
55 > |
|
56 > |
|
57 > output = StringIO() |
|
58 > env['PATH_INFO'] = '/' |
|
59 > env['QUERY_STRING'] = 'style=atom' |
|
60 > process(hgweb('.', name = 'repo')) |
|
61 > |
|
62 > output = StringIO() |
|
63 > env['PATH_INFO'] = '/file/tip/' |
|
64 > env['QUERY_STRING'] = 'style=raw' |
|
65 > process(hgweb('.', name = 'repo')) |
|
66 > |
|
67 > output = StringIO() |
|
68 > env['PATH_INFO'] = '/' |
|
69 > env['QUERY_STRING'] = 'style=raw' |
|
70 > process(hgwebdir({'repo': '.'})) |
|
71 > |
|
72 > output = StringIO() |
|
73 > env['PATH_INFO'] = '/repo/file/tip/' |
|
74 > env['QUERY_STRING'] = 'style=raw' |
|
75 > process(hgwebdir({'repo': '.'})) |
|
76 > EOF |
|
77 $ python request.py |
|
78 ---- STATUS |
|
79 200 Script output follows |
|
80 ---- HEADERS |
|
81 [('Content-Type', 'application/atom+xml; charset=ascii')] |
|
82 ---- DATA |
|
83 <?xml version="1.0" encoding="ascii"?> |
|
84 <feed xmlns="http://www.w3.org/2005/Atom"> |
|
85 <!-- Changelog --> |
|
86 <id>http://127.0.0.1:*/</id> (glob) |
|
87 <link rel="self" href="http://127.0.0.1:*/atom-log"/> (glob) |
|
88 <link rel="alternate" href="http://127.0.0.1:*/"/> (glob) |
|
89 <title>repo Changelog</title> |
|
90 <updated>1970-01-01T00:00:00+00:00</updated> |
|
91 |
|
92 <entry> |
|
93 <title>test</title> |
|
94 <id>http://127.0.0.1:*/#changeset-61c9426e69fef294feed5e2bbfc97d39944a5b1c</id> (glob) |
|
95 <link href="http://127.0.0.1:*/rev/61c9426e69fe"/> (glob) |
|
96 <author> |
|
97 <name>test</name> |
|
98 <email>test</email> |
|
99 </author> |
|
100 <updated>1970-01-01T00:00:00+00:00</updated> |
|
101 <published>1970-01-01T00:00:00+00:00</published> |
|
102 <content type="xhtml"> |
|
103 <div xmlns="http://www.w3.org/1999/xhtml"> |
|
104 <pre xml:space="preserve">test</pre> |
|
105 </div> |
|
106 </content> |
|
107 </entry> |
|
108 |
|
109 </feed> |
|
110 ---- ERRORS |
|
111 |
|
112 ---- STATUS |
|
113 200 Script output follows |
|
114 ---- HEADERS |
|
115 [('Content-Type', 'text/plain; charset=ascii')] |
|
116 ---- DATA |
|
117 |
|
118 -rw-r--r-- 4 bar |
|
119 |
|
120 |
|
121 ---- ERRORS |
|
122 |
|
123 ---- STATUS |
|
124 200 Script output follows |
|
125 ---- HEADERS |
|
126 [('Content-Type', 'text/plain; charset=ascii')] |
|
127 ---- DATA |
|
128 |
|
129 /repo/ |
|
130 |
|
131 ---- ERRORS |
|
132 |
|
133 ---- STATUS |
|
134 200 Script output follows |
|
135 ---- HEADERS |
|
136 [('Content-Type', 'text/plain; charset=ascii')] |
|
137 ---- DATA |
|
138 |
|
139 -rw-r--r-- 4 bar |
|
140 |
|
141 |
|
142 ---- ERRORS |
|
143 |