Show More
@@ -1,61 +1,108 | |||
|
1 | #!/bin/sh | |
|
2 | # This tests if hgweb and hgwebdir still work if the REQUEST_URI variable is | |
|
3 | # no longer passed with the request. Instead, SCRIPT_NAME and PATH_INFO | |
|
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 | |
|
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. | |
|
13 | 4 | |
|
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 | |
|
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 | |
|
29 | 17 | |
|
30 | env = { | |
|
31 | 'wsgi.version': (1, 0), | |
|
32 | 'wsgi.url_scheme': 'http', | |
|
33 | 'wsgi.errors': errors, | |
|
34 | 'wsgi.input': input, | |
|
35 | 'wsgi.multithread': False, | |
|
36 | 'wsgi.multiprocess': False, | |
|
37 | 'wsgi.run_once': False, | |
|
38 | 'REQUEST_METHOD': 'GET', | |
|
39 | 'SCRIPT_NAME': '', | |
|
40 | 'SERVER_NAME': '127.0.0.1', | |
|
41 | 'SERVER_PORT': os.environ['HGPORT'], | |
|
42 | 'SERVER_PROTOCOL': 'HTTP/1.0' | |
|
43 | } | |
|
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 | > 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> | |
|
44 | 78 | |
|
45 | def process(app): | |
|
46 | content = app(env, startrsp) | |
|
47 | sys.stdout.write(output.getvalue()) | |
|
48 | sys.stdout.write(''.join(content)) | |
|
49 | print '---- ERRORS' | |
|
50 | print errors.getvalue() | |
|
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> | |
|
51 | 95 | |
|
52 | output = StringIO() | |
|
53 | env['QUERY_STRING'] = 'style=atom' | |
|
54 | process(hgweb('.', name='repo')) | |
|
96 | </feed> | |
|
97 | ---- ERRORS | |
|
55 | 98 | |
|
56 | output = StringIO() | |
|
57 | env['QUERY_STRING'] = 'style=raw' | |
|
58 | process(hgwebdir({'repo': '.'})) | |
|
59 | EOF | |
|
99 | ---- STATUS | |
|
100 | 200 Script output follows | |
|
101 | ---- HEADERS | |
|
102 | [('Content-Type', 'text/plain; charset=ascii')] | |
|
103 | ---- DATA | |
|
60 | 104 | |
|
61 | python request.py | sed "s/http:\/\/127\.0\.0\.1:[0-9]*\//http:\/\/127.0.0.1\//" | |
|
105 | repo/ | |
|
106 | ||
|
107 | ---- ERRORS | |
|
108 |
|
1 | NO CONTENT: file was removed |
General Comments 0
You need to be logged in to leave comments.
Login now