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