Mercurial > hg
annotate tests/test-hgweb-no-path-info @ 12329:7458de933f26
bundle: push chunkbuffer down into decompress
We replace the fixup iterator with a file-like object so that
uncompressed file streams can be passed end to end through the stack.
author | Matt Mackall <mpm@selenic.com> |
---|---|
date | Fri, 17 Sep 2010 19:02:26 -0500 |
parents | f64b416b0ac8 |
children |
rev | line source |
---|---|
6459
8189e03adb44
hgweb: make hgwebdir work in the absence of PATH_INFO
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
1 #!/bin/sh |
8189e03adb44
hgweb: make hgwebdir work in the absence of PATH_INFO
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
2 # This tests if hgweb and hgwebdir still work if the REQUEST_URI variable is |
8189e03adb44
hgweb: make hgwebdir work in the absence of PATH_INFO
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
3 # no longer passed with the request. Instead, SCRIPT_NAME and PATH_INFO |
8189e03adb44
hgweb: make hgwebdir work in the absence of PATH_INFO
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
4 # should be used from d74fc8dec2b4 onward to route the request. |
8189e03adb44
hgweb: make hgwebdir work in the absence of PATH_INFO
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
5 |
8189e03adb44
hgweb: make hgwebdir work in the absence of PATH_INFO
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
6 mkdir repo |
8189e03adb44
hgweb: make hgwebdir work in the absence of PATH_INFO
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
7 cd repo |
8189e03adb44
hgweb: make hgwebdir work in the absence of PATH_INFO
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
8 hg init |
8189e03adb44
hgweb: make hgwebdir work in the absence of PATH_INFO
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
9 echo foo > bar |
8189e03adb44
hgweb: make hgwebdir work in the absence of PATH_INFO
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
10 hg add bar |
12161
dfb11f9922c1
tests: remove unneeded -u flags
Martin Geisler <mg@lazybytes.net>
parents:
8167
diff
changeset
|
11 hg commit -m "test" |
6459
8189e03adb44
hgweb: make hgwebdir work in the absence of PATH_INFO
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
12 hg tip |
8189e03adb44
hgweb: make hgwebdir work in the absence of PATH_INFO
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
13 |
8189e03adb44
hgweb: make hgwebdir work in the absence of PATH_INFO
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
14 cat > request.py <<EOF |
8189e03adb44
hgweb: make hgwebdir work in the absence of PATH_INFO
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
15 from mercurial.hgweb import hgweb, hgwebdir |
8189e03adb44
hgweb: make hgwebdir work in the absence of PATH_INFO
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
16 from StringIO import StringIO |
8189e03adb44
hgweb: make hgwebdir work in the absence of PATH_INFO
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
17 import os, sys |
8189e03adb44
hgweb: make hgwebdir work in the absence of PATH_INFO
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
18 |
8189e03adb44
hgweb: make hgwebdir work in the absence of PATH_INFO
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
19 errors = StringIO() |
8189e03adb44
hgweb: make hgwebdir work in the absence of PATH_INFO
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
20 input = StringIO() |
8189e03adb44
hgweb: make hgwebdir work in the absence of PATH_INFO
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
21 |
12181
045c9e8db0d8
tests: fix test output for test-hgweb-no* tests
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
12161
diff
changeset
|
22 def startrsp(status, headers): |
045c9e8db0d8
tests: fix test output for test-hgweb-no* tests
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
12161
diff
changeset
|
23 print '---- STATUS' |
045c9e8db0d8
tests: fix test output for test-hgweb-no* tests
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
12161
diff
changeset
|
24 print status |
6459
8189e03adb44
hgweb: make hgwebdir work in the absence of PATH_INFO
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
25 print '---- HEADERS' |
12183
f64b416b0ac8
hgweb: support very simple caching model (issue1845)
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
12181
diff
changeset
|
26 print [i for i in headers if i[0] != 'ETag'] |
6459
8189e03adb44
hgweb: make hgwebdir work in the absence of PATH_INFO
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
27 print '---- DATA' |
8189e03adb44
hgweb: make hgwebdir work in the absence of PATH_INFO
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
28 return output.write |
8189e03adb44
hgweb: make hgwebdir work in the absence of PATH_INFO
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
29 |
8189e03adb44
hgweb: make hgwebdir work in the absence of PATH_INFO
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
30 env = { |
8189e03adb44
hgweb: make hgwebdir work in the absence of PATH_INFO
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
31 'wsgi.version': (1, 0), |
8189e03adb44
hgweb: make hgwebdir work in the absence of PATH_INFO
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
32 'wsgi.url_scheme': 'http', |
8189e03adb44
hgweb: make hgwebdir work in the absence of PATH_INFO
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
33 'wsgi.errors': errors, |
8189e03adb44
hgweb: make hgwebdir work in the absence of PATH_INFO
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
34 'wsgi.input': input, |
8189e03adb44
hgweb: make hgwebdir work in the absence of PATH_INFO
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
35 'wsgi.multithread': False, |
8189e03adb44
hgweb: make hgwebdir work in the absence of PATH_INFO
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
36 'wsgi.multiprocess': False, |
8189e03adb44
hgweb: make hgwebdir work in the absence of PATH_INFO
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
37 'wsgi.run_once': False, |
8189e03adb44
hgweb: make hgwebdir work in the absence of PATH_INFO
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
38 'REQUEST_METHOD': 'GET', |
8189e03adb44
hgweb: make hgwebdir work in the absence of PATH_INFO
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
39 'SCRIPT_NAME': '', |
8189e03adb44
hgweb: make hgwebdir work in the absence of PATH_INFO
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
40 'SERVER_NAME': '127.0.0.1', |
8189e03adb44
hgweb: make hgwebdir work in the absence of PATH_INFO
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
41 'SERVER_PORT': os.environ['HGPORT'], |
8189e03adb44
hgweb: make hgwebdir work in the absence of PATH_INFO
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
42 'SERVER_PROTOCOL': 'HTTP/1.0' |
8189e03adb44
hgweb: make hgwebdir work in the absence of PATH_INFO
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
43 } |
8189e03adb44
hgweb: make hgwebdir work in the absence of PATH_INFO
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
44 |
6945
2cfdabe235fb
hgweb: return content iterator instead of using write() callable
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
6796
diff
changeset
|
45 def process(app): |
2cfdabe235fb
hgweb: return content iterator instead of using write() callable
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
6796
diff
changeset
|
46 content = app(env, startrsp) |
2cfdabe235fb
hgweb: return content iterator instead of using write() callable
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
6796
diff
changeset
|
47 sys.stdout.write(output.getvalue()) |
2cfdabe235fb
hgweb: return content iterator instead of using write() callable
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
6796
diff
changeset
|
48 sys.stdout.write(''.join(content)) |
2cfdabe235fb
hgweb: return content iterator instead of using write() callable
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
6796
diff
changeset
|
49 print '---- ERRORS' |
2cfdabe235fb
hgweb: return content iterator instead of using write() callable
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
6796
diff
changeset
|
50 print errors.getvalue() |
2cfdabe235fb
hgweb: return content iterator instead of using write() callable
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
6796
diff
changeset
|
51 |
6459
8189e03adb44
hgweb: make hgwebdir work in the absence of PATH_INFO
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
52 output = StringIO() |
8189e03adb44
hgweb: make hgwebdir work in the absence of PATH_INFO
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
53 env['QUERY_STRING'] = 'style=atom' |
6945
2cfdabe235fb
hgweb: return content iterator instead of using write() callable
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
6796
diff
changeset
|
54 process(hgweb('.', name='repo')) |
6459
8189e03adb44
hgweb: make hgwebdir work in the absence of PATH_INFO
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
55 |
8189e03adb44
hgweb: make hgwebdir work in the absence of PATH_INFO
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
56 output = StringIO() |
8189e03adb44
hgweb: make hgwebdir work in the absence of PATH_INFO
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
57 env['QUERY_STRING'] = 'style=raw' |
6945
2cfdabe235fb
hgweb: return content iterator instead of using write() callable
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
6796
diff
changeset
|
58 process(hgwebdir({'repo': '.'})) |
6459
8189e03adb44
hgweb: make hgwebdir work in the absence of PATH_INFO
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
59 EOF |
8189e03adb44
hgweb: make hgwebdir work in the absence of PATH_INFO
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
60 |
8189e03adb44
hgweb: make hgwebdir work in the absence of PATH_INFO
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
61 python request.py | sed "s/http:\/\/127\.0\.0\.1:[0-9]*\//http:\/\/127.0.0.1\//" |