##// END OF EJS Templates
tests: fix style issue of importing hgweb in embedded code fragments...
FUJIWARA Katsunori -
r40239:f80f7a67 default
parent child Browse files
Show More
@@ -1,150 +1,147 b''
1 This tests if hgweb and hgwebdir still work if the REQUEST_URI variable is
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
2 no longer passed with the request. Instead, SCRIPT_NAME and PATH_INFO
3 should be used from d74fc8dec2b4 onward to route the request.
3 should be used from d74fc8dec2b4 onward to route the request.
4
4
5 $ hg init repo
5 $ hg init repo
6 $ cd repo
6 $ cd repo
7 $ echo foo > bar
7 $ echo foo > bar
8 $ hg add bar
8 $ hg add bar
9 $ hg commit -m "test"
9 $ hg commit -m "test"
10 $ hg tip
10 $ hg tip
11 changeset: 0:61c9426e69fe
11 changeset: 0:61c9426e69fe
12 tag: tip
12 tag: tip
13 user: test
13 user: test
14 date: Thu Jan 01 00:00:00 1970 +0000
14 date: Thu Jan 01 00:00:00 1970 +0000
15 summary: test
15 summary: test
16
16
17 $ cat > request.py <<EOF
17 $ cat > request.py <<EOF
18 > from __future__ import absolute_import
18 > from __future__ import absolute_import
19 > import os
19 > import os
20 > import sys
20 > import sys
21 > from mercurial.hgweb import (
21 > from mercurial import (
22 > hgweb,
22 > hgweb,
23 > hgwebdir,
24 > )
25 > from mercurial import (
26 > util,
23 > util,
27 > )
24 > )
28 > stringio = util.stringio
25 > stringio = util.stringio
29 >
26 >
30 > errors = stringio()
27 > errors = stringio()
31 > input = stringio()
28 > input = stringio()
32 >
29 >
33 > def startrsp(status, headers):
30 > def startrsp(status, headers):
34 > print('---- STATUS')
31 > print('---- STATUS')
35 > print(status)
32 > print(status)
36 > print('---- HEADERS')
33 > print('---- HEADERS')
37 > print([i for i in headers if i[0] != 'ETag'])
34 > print([i for i in headers if i[0] != 'ETag'])
38 > print('---- DATA')
35 > print('---- DATA')
39 > sys.stdout.flush()
36 > sys.stdout.flush()
40 > return output.write
37 > return output.write
41 >
38 >
42 > env = {
39 > env = {
43 > 'wsgi.version': (1, 0),
40 > 'wsgi.version': (1, 0),
44 > 'wsgi.url_scheme': 'http',
41 > 'wsgi.url_scheme': 'http',
45 > 'wsgi.errors': errors,
42 > 'wsgi.errors': errors,
46 > 'wsgi.input': input,
43 > 'wsgi.input': input,
47 > 'wsgi.multithread': False,
44 > 'wsgi.multithread': False,
48 > 'wsgi.multiprocess': False,
45 > 'wsgi.multiprocess': False,
49 > 'wsgi.run_once': False,
46 > 'wsgi.run_once': False,
50 > 'REQUEST_METHOD': 'GET',
47 > 'REQUEST_METHOD': 'GET',
51 > 'PATH_INFO': '/',
48 > 'PATH_INFO': '/',
52 > 'SCRIPT_NAME': '',
49 > 'SCRIPT_NAME': '',
53 > 'SERVER_NAME': '$LOCALIP',
50 > 'SERVER_NAME': '$LOCALIP',
54 > 'SERVER_PORT': os.environ['HGPORT'],
51 > 'SERVER_PORT': os.environ['HGPORT'],
55 > 'SERVER_PROTOCOL': 'HTTP/1.0'
52 > 'SERVER_PROTOCOL': 'HTTP/1.0'
56 > }
53 > }
57 >
54 >
58 > def process(app):
55 > def process(app):
59 > try:
56 > try:
60 > stdout = sys.stdout.buffer
57 > stdout = sys.stdout.buffer
61 > except AttributeError:
58 > except AttributeError:
62 > stdout = sys.stdout
59 > stdout = sys.stdout
63 > content = app(env, startrsp)
60 > content = app(env, startrsp)
64 > stdout.write(output.getvalue())
61 > stdout.write(output.getvalue())
65 > stdout.write(b''.join(content))
62 > stdout.write(b''.join(content))
66 > stdout.flush()
63 > stdout.flush()
67 > getattr(content, 'close', lambda : None)()
64 > getattr(content, 'close', lambda : None)()
68 > if errors.getvalue():
65 > if errors.getvalue():
69 > print('---- ERRORS')
66 > print('---- ERRORS')
70 > print(errors.getvalue())
67 > print(errors.getvalue())
71 > sys.stdout.flush()
68 > sys.stdout.flush()
72 >
69 >
73 > output = stringio()
70 > output = stringio()
74 > env['QUERY_STRING'] = 'style=atom'
71 > env['QUERY_STRING'] = 'style=atom'
75 > process(hgweb(b'.', name=b'repo'))
72 > process(hgweb.hgweb(b'.', name=b'repo'))
76 >
73 >
77 > output = stringio()
74 > output = stringio()
78 > env['QUERY_STRING'] = 'style=raw'
75 > env['QUERY_STRING'] = 'style=raw'
79 > process(hgwebdir({b'repo': b'.'}))
76 > process(hgweb.hgwebdir({b'repo': b'.'}))
80 > EOF
77 > EOF
81 $ "$PYTHON" request.py
78 $ "$PYTHON" request.py
82 ---- STATUS
79 ---- STATUS
83 200 Script output follows
80 200 Script output follows
84 ---- HEADERS
81 ---- HEADERS
85 [('Content-Type', 'application/atom+xml; charset=ascii')]
82 [('Content-Type', 'application/atom+xml; charset=ascii')]
86 ---- DATA
83 ---- DATA
87 <?xml version="1.0" encoding="ascii"?>
84 <?xml version="1.0" encoding="ascii"?>
88 <feed xmlns="http://www.w3.org/2005/Atom">
85 <feed xmlns="http://www.w3.org/2005/Atom">
89 <!-- Changelog -->
86 <!-- Changelog -->
90 <id>http://$LOCALIP:$HGPORT/</id> (glob)
87 <id>http://$LOCALIP:$HGPORT/</id> (glob)
91 <link rel="self" href="http://$LOCALIP:$HGPORT/atom-log"/> (glob)
88 <link rel="self" href="http://$LOCALIP:$HGPORT/atom-log"/> (glob)
92 <link rel="alternate" href="http://$LOCALIP:$HGPORT/"/> (glob)
89 <link rel="alternate" href="http://$LOCALIP:$HGPORT/"/> (glob)
93 <title>repo Changelog</title>
90 <title>repo Changelog</title>
94 <updated>1970-01-01T00:00:00+00:00</updated>
91 <updated>1970-01-01T00:00:00+00:00</updated>
95
92
96 <entry>
93 <entry>
97 <title>[default] test</title>
94 <title>[default] test</title>
98 <id>http://$LOCALIP:$HGPORT/#changeset-61c9426e69fef294feed5e2bbfc97d39944a5b1c</id> (glob)
95 <id>http://$LOCALIP:$HGPORT/#changeset-61c9426e69fef294feed5e2bbfc97d39944a5b1c</id> (glob)
99 <link href="http://$LOCALIP:$HGPORT/rev/61c9426e69fe"/> (glob)
96 <link href="http://$LOCALIP:$HGPORT/rev/61c9426e69fe"/> (glob)
100 <author>
97 <author>
101 <name>test</name>
98 <name>test</name>
102 <email>&#116;&#101;&#115;&#116;</email>
99 <email>&#116;&#101;&#115;&#116;</email>
103 </author>
100 </author>
104 <updated>1970-01-01T00:00:00+00:00</updated>
101 <updated>1970-01-01T00:00:00+00:00</updated>
105 <published>1970-01-01T00:00:00+00:00</published>
102 <published>1970-01-01T00:00:00+00:00</published>
106 <content type="xhtml">
103 <content type="xhtml">
107 <table xmlns="http://www.w3.org/1999/xhtml">
104 <table xmlns="http://www.w3.org/1999/xhtml">
108 <tr>
105 <tr>
109 <th style="text-align:left;">changeset</th>
106 <th style="text-align:left;">changeset</th>
110 <td>61c9426e69fe</td>
107 <td>61c9426e69fe</td>
111 </tr>
108 </tr>
112 <tr>
109 <tr>
113 <th style="text-align:left;">branch</th>
110 <th style="text-align:left;">branch</th>
114 <td>default</td>
111 <td>default</td>
115 </tr>
112 </tr>
116 <tr>
113 <tr>
117 <th style="text-align:left;">bookmark</th>
114 <th style="text-align:left;">bookmark</th>
118 <td></td>
115 <td></td>
119 </tr>
116 </tr>
120 <tr>
117 <tr>
121 <th style="text-align:left;">tag</th>
118 <th style="text-align:left;">tag</th>
122 <td>tip</td>
119 <td>tip</td>
123 </tr>
120 </tr>
124 <tr>
121 <tr>
125 <th style="text-align:left;">user</th>
122 <th style="text-align:left;">user</th>
126 <td>&#116;&#101;&#115;&#116;</td>
123 <td>&#116;&#101;&#115;&#116;</td>
127 </tr>
124 </tr>
128 <tr>
125 <tr>
129 <th style="text-align:left;vertical-align:top;">description</th>
126 <th style="text-align:left;vertical-align:top;">description</th>
130 <td>test</td>
127 <td>test</td>
131 </tr>
128 </tr>
132 <tr>
129 <tr>
133 <th style="text-align:left;vertical-align:top;">files</th>
130 <th style="text-align:left;vertical-align:top;">files</th>
134 <td>bar<br /></td>
131 <td>bar<br /></td>
135 </tr>
132 </tr>
136 </table>
133 </table>
137 </content>
134 </content>
138 </entry>
135 </entry>
139
136
140 </feed>
137 </feed>
141 ---- STATUS
138 ---- STATUS
142 200 Script output follows
139 200 Script output follows
143 ---- HEADERS
140 ---- HEADERS
144 [('Content-Type', 'text/plain; charset=ascii')]
141 [('Content-Type', 'text/plain; charset=ascii')]
145 ---- DATA
142 ---- DATA
146
143
147 /repo/
144 /repo/
148
145
149
146
150 $ cd ..
147 $ cd ..
@@ -1,180 +1,177 b''
1 This tests if hgweb and hgwebdir still work if the REQUEST_URI variable is
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
2 no longer passed with the request. Instead, SCRIPT_NAME and PATH_INFO
3 should be used from d74fc8dec2b4 onward to route the request.
3 should be used from d74fc8dec2b4 onward to route the request.
4
4
5 $ hg init repo
5 $ hg init repo
6 $ cd repo
6 $ cd repo
7 $ echo foo > bar
7 $ echo foo > bar
8 $ hg add bar
8 $ hg add bar
9 $ hg commit -m "test"
9 $ hg commit -m "test"
10 $ hg tip
10 $ hg tip
11 changeset: 0:61c9426e69fe
11 changeset: 0:61c9426e69fe
12 tag: tip
12 tag: tip
13 user: test
13 user: test
14 date: Thu Jan 01 00:00:00 1970 +0000
14 date: Thu Jan 01 00:00:00 1970 +0000
15 summary: test
15 summary: test
16
16
17 $ cat > request.py <<EOF
17 $ cat > request.py <<EOF
18 > from __future__ import absolute_import
18 > from __future__ import absolute_import
19 > import os
19 > import os
20 > import sys
20 > import sys
21 > from mercurial.hgweb import (
22 > hgweb,
23 > hgwebdir,
24 > )
25 > from mercurial import (
21 > from mercurial import (
26 > encoding,
22 > encoding,
23 > hgweb,
27 > util,
24 > util,
28 > )
25 > )
29 > stringio = util.stringio
26 > stringio = util.stringio
30 >
27 >
31 > errors = stringio()
28 > errors = stringio()
32 > input = stringio()
29 > input = stringio()
33 >
30 >
34 > def startrsp(status, headers):
31 > def startrsp(status, headers):
35 > print('---- STATUS')
32 > print('---- STATUS')
36 > print(status)
33 > print(status)
37 > print('---- HEADERS')
34 > print('---- HEADERS')
38 > print([i for i in headers if i[0] != 'ETag'])
35 > print([i for i in headers if i[0] != 'ETag'])
39 > print('---- DATA')
36 > print('---- DATA')
40 > return output.write
37 > return output.write
41 >
38 >
42 > env = {
39 > env = {
43 > 'wsgi.version': (1, 0),
40 > 'wsgi.version': (1, 0),
44 > 'wsgi.url_scheme': 'http',
41 > 'wsgi.url_scheme': 'http',
45 > 'wsgi.errors': errors,
42 > 'wsgi.errors': errors,
46 > 'wsgi.input': input,
43 > 'wsgi.input': input,
47 > 'wsgi.multithread': False,
44 > 'wsgi.multithread': False,
48 > 'wsgi.multiprocess': False,
45 > 'wsgi.multiprocess': False,
49 > 'wsgi.run_once': False,
46 > 'wsgi.run_once': False,
50 > 'REQUEST_METHOD': 'GET',
47 > 'REQUEST_METHOD': 'GET',
51 > 'SCRIPT_NAME': '',
48 > 'SCRIPT_NAME': '',
52 > 'SERVER_NAME': '$LOCALIP',
49 > 'SERVER_NAME': '$LOCALIP',
53 > 'SERVER_PORT': os.environ['HGPORT'],
50 > 'SERVER_PORT': os.environ['HGPORT'],
54 > 'SERVER_PROTOCOL': 'HTTP/1.0'
51 > 'SERVER_PROTOCOL': 'HTTP/1.0'
55 > }
52 > }
56 >
53 >
57 > def process(app):
54 > def process(app):
58 > content = app(env, startrsp)
55 > content = app(env, startrsp)
59 > sys.stdout.write(encoding.strfromlocal(output.getvalue()))
56 > sys.stdout.write(encoding.strfromlocal(output.getvalue()))
60 > sys.stdout.write(encoding.strfromlocal(b''.join(content)))
57 > sys.stdout.write(encoding.strfromlocal(b''.join(content)))
61 > getattr(content, 'close', lambda : None)()
58 > getattr(content, 'close', lambda : None)()
62 > print('---- ERRORS')
59 > print('---- ERRORS')
63 > print(encoding.strfromlocal(errors.getvalue())) # avoid b'' output diff
60 > print(encoding.strfromlocal(errors.getvalue())) # avoid b'' output diff
64 >
61 >
65 > output = stringio()
62 > output = stringio()
66 > env['PATH_INFO'] = '/'
63 > env['PATH_INFO'] = '/'
67 > env['QUERY_STRING'] = 'style=atom'
64 > env['QUERY_STRING'] = 'style=atom'
68 > process(hgweb(b'.', name = b'repo'))
65 > process(hgweb.hgweb(b'.', name = b'repo'))
69 >
66 >
70 > output = stringio()
67 > output = stringio()
71 > env['PATH_INFO'] = '/file/tip/'
68 > env['PATH_INFO'] = '/file/tip/'
72 > env['QUERY_STRING'] = 'style=raw'
69 > env['QUERY_STRING'] = 'style=raw'
73 > process(hgweb(b'.', name = b'repo'))
70 > process(hgweb.hgweb(b'.', name = b'repo'))
74 >
71 >
75 > output = stringio()
72 > output = stringio()
76 > env['PATH_INFO'] = '/'
73 > env['PATH_INFO'] = '/'
77 > env['QUERY_STRING'] = 'style=raw'
74 > env['QUERY_STRING'] = 'style=raw'
78 > process(hgwebdir({b'repo': b'.'}))
75 > process(hgweb.hgwebdir({b'repo': b'.'}))
79 >
76 >
80 > output = stringio()
77 > output = stringio()
81 > env['PATH_INFO'] = '/repo/file/tip/'
78 > env['PATH_INFO'] = '/repo/file/tip/'
82 > env['QUERY_STRING'] = 'style=raw'
79 > env['QUERY_STRING'] = 'style=raw'
83 > process(hgwebdir({b'repo': b'.'}))
80 > process(hgweb.hgwebdir({b'repo': b'.'}))
84 > EOF
81 > EOF
85 $ "$PYTHON" request.py
82 $ "$PYTHON" request.py
86 ---- STATUS
83 ---- STATUS
87 200 Script output follows
84 200 Script output follows
88 ---- HEADERS
85 ---- HEADERS
89 [('Content-Type', 'application/atom+xml; charset=ascii')]
86 [('Content-Type', 'application/atom+xml; charset=ascii')]
90 ---- DATA
87 ---- DATA
91 <?xml version="1.0" encoding="ascii"?>
88 <?xml version="1.0" encoding="ascii"?>
92 <feed xmlns="http://www.w3.org/2005/Atom">
89 <feed xmlns="http://www.w3.org/2005/Atom">
93 <!-- Changelog -->
90 <!-- Changelog -->
94 <id>http://$LOCALIP:$HGPORT/</id> (glob)
91 <id>http://$LOCALIP:$HGPORT/</id> (glob)
95 <link rel="self" href="http://$LOCALIP:$HGPORT/atom-log"/> (glob)
92 <link rel="self" href="http://$LOCALIP:$HGPORT/atom-log"/> (glob)
96 <link rel="alternate" href="http://$LOCALIP:$HGPORT/"/> (glob)
93 <link rel="alternate" href="http://$LOCALIP:$HGPORT/"/> (glob)
97 <title>repo Changelog</title>
94 <title>repo Changelog</title>
98 <updated>1970-01-01T00:00:00+00:00</updated>
95 <updated>1970-01-01T00:00:00+00:00</updated>
99
96
100 <entry>
97 <entry>
101 <title>[default] test</title>
98 <title>[default] test</title>
102 <id>http://$LOCALIP:$HGPORT/#changeset-61c9426e69fef294feed5e2bbfc97d39944a5b1c</id> (glob)
99 <id>http://$LOCALIP:$HGPORT/#changeset-61c9426e69fef294feed5e2bbfc97d39944a5b1c</id> (glob)
103 <link href="http://$LOCALIP:$HGPORT/rev/61c9426e69fe"/> (glob)
100 <link href="http://$LOCALIP:$HGPORT/rev/61c9426e69fe"/> (glob)
104 <author>
101 <author>
105 <name>test</name>
102 <name>test</name>
106 <email>&#116;&#101;&#115;&#116;</email>
103 <email>&#116;&#101;&#115;&#116;</email>
107 </author>
104 </author>
108 <updated>1970-01-01T00:00:00+00:00</updated>
105 <updated>1970-01-01T00:00:00+00:00</updated>
109 <published>1970-01-01T00:00:00+00:00</published>
106 <published>1970-01-01T00:00:00+00:00</published>
110 <content type="xhtml">
107 <content type="xhtml">
111 <table xmlns="http://www.w3.org/1999/xhtml">
108 <table xmlns="http://www.w3.org/1999/xhtml">
112 <tr>
109 <tr>
113 <th style="text-align:left;">changeset</th>
110 <th style="text-align:left;">changeset</th>
114 <td>61c9426e69fe</td>
111 <td>61c9426e69fe</td>
115 </tr>
112 </tr>
116 <tr>
113 <tr>
117 <th style="text-align:left;">branch</th>
114 <th style="text-align:left;">branch</th>
118 <td>default</td>
115 <td>default</td>
119 </tr>
116 </tr>
120 <tr>
117 <tr>
121 <th style="text-align:left;">bookmark</th>
118 <th style="text-align:left;">bookmark</th>
122 <td></td>
119 <td></td>
123 </tr>
120 </tr>
124 <tr>
121 <tr>
125 <th style="text-align:left;">tag</th>
122 <th style="text-align:left;">tag</th>
126 <td>tip</td>
123 <td>tip</td>
127 </tr>
124 </tr>
128 <tr>
125 <tr>
129 <th style="text-align:left;">user</th>
126 <th style="text-align:left;">user</th>
130 <td>&#116;&#101;&#115;&#116;</td>
127 <td>&#116;&#101;&#115;&#116;</td>
131 </tr>
128 </tr>
132 <tr>
129 <tr>
133 <th style="text-align:left;vertical-align:top;">description</th>
130 <th style="text-align:left;vertical-align:top;">description</th>
134 <td>test</td>
131 <td>test</td>
135 </tr>
132 </tr>
136 <tr>
133 <tr>
137 <th style="text-align:left;vertical-align:top;">files</th>
134 <th style="text-align:left;vertical-align:top;">files</th>
138 <td>bar<br /></td>
135 <td>bar<br /></td>
139 </tr>
136 </tr>
140 </table>
137 </table>
141 </content>
138 </content>
142 </entry>
139 </entry>
143
140
144 </feed>
141 </feed>
145 ---- ERRORS
142 ---- ERRORS
146
143
147 ---- STATUS
144 ---- STATUS
148 200 Script output follows
145 200 Script output follows
149 ---- HEADERS
146 ---- HEADERS
150 [('Content-Type', 'text/plain; charset=ascii')]
147 [('Content-Type', 'text/plain; charset=ascii')]
151 ---- DATA
148 ---- DATA
152
149
153 -rw-r--r-- 4 bar
150 -rw-r--r-- 4 bar
154
151
155
152
156 ---- ERRORS
153 ---- ERRORS
157
154
158 ---- STATUS
155 ---- STATUS
159 200 Script output follows
156 200 Script output follows
160 ---- HEADERS
157 ---- HEADERS
161 [('Content-Type', 'text/plain; charset=ascii')]
158 [('Content-Type', 'text/plain; charset=ascii')]
162 ---- DATA
159 ---- DATA
163
160
164 /repo/
161 /repo/
165
162
166 ---- ERRORS
163 ---- ERRORS
167
164
168 ---- STATUS
165 ---- STATUS
169 200 Script output follows
166 200 Script output follows
170 ---- HEADERS
167 ---- HEADERS
171 [('Content-Type', 'text/plain; charset=ascii')]
168 [('Content-Type', 'text/plain; charset=ascii')]
172 ---- DATA
169 ---- DATA
173
170
174 -rw-r--r-- 4 bar
171 -rw-r--r-- 4 bar
175
172
176
173
177 ---- ERRORS
174 ---- ERRORS
178
175
179
176
180 $ cd ..
177 $ cd ..
@@ -1,96 +1,94 b''
1 Tests if hgweb can run without touching sys.stdin, as is required
1 Tests if hgweb can run without touching sys.stdin, as is required
2 by the WSGI standard and strictly implemented by mod_wsgi.
2 by the WSGI standard and strictly implemented by mod_wsgi.
3
3
4 $ hg init repo
4 $ hg init repo
5 $ cd repo
5 $ cd repo
6 $ echo foo > bar
6 $ echo foo > bar
7 $ hg add bar
7 $ hg add bar
8 $ hg commit -m "test"
8 $ hg commit -m "test"
9 $ cat > request.py <<EOF
9 $ cat > request.py <<EOF
10 > from __future__ import absolute_import
10 > from __future__ import absolute_import
11 > import os
11 > import os
12 > import sys
12 > import sys
13 > from mercurial import (
13 > from mercurial import (
14 > dispatch,
14 > dispatch,
15 > encoding,
15 > encoding,
16 > hg,
16 > hg,
17 > pycompat,
17 > pycompat,
18 > ui as uimod,
18 > ui as uimod,
19 > util,
19 > util,
20 > )
20 > )
21 > ui = uimod.ui
21 > ui = uimod.ui
22 > from mercurial.hgweb.hgweb_mod import (
22 > from mercurial.hgweb import hgweb_mod
23 > hgweb,
24 > )
25 > stringio = util.stringio
23 > stringio = util.stringio
26 >
24 >
27 > class FileLike(object):
25 > class FileLike(object):
28 > def __init__(self, real):
26 > def __init__(self, real):
29 > self.real = real
27 > self.real = real
30 > def fileno(self):
28 > def fileno(self):
31 > print >> sys.__stdout__, 'FILENO'
29 > print >> sys.__stdout__, 'FILENO'
32 > return self.real.fileno()
30 > return self.real.fileno()
33 > def read(self):
31 > def read(self):
34 > print >> sys.__stdout__, 'READ'
32 > print >> sys.__stdout__, 'READ'
35 > return self.real.read()
33 > return self.real.read()
36 > def readline(self):
34 > def readline(self):
37 > print >> sys.__stdout__, 'READLINE'
35 > print >> sys.__stdout__, 'READLINE'
38 > return self.real.readline()
36 > return self.real.readline()
39 >
37 >
40 > sys.stdin = FileLike(sys.stdin)
38 > sys.stdin = FileLike(sys.stdin)
41 > errors = stringio()
39 > errors = stringio()
42 > input = stringio()
40 > input = stringio()
43 > output = stringio()
41 > output = stringio()
44 >
42 >
45 > def startrsp(status, headers):
43 > def startrsp(status, headers):
46 > print('---- STATUS')
44 > print('---- STATUS')
47 > print(status)
45 > print(status)
48 > print('---- HEADERS')
46 > print('---- HEADERS')
49 > print([i for i in headers if i[0] != 'ETag'])
47 > print([i for i in headers if i[0] != 'ETag'])
50 > print('---- DATA')
48 > print('---- DATA')
51 > return output.write
49 > return output.write
52 >
50 >
53 > env = {
51 > env = {
54 > 'wsgi.version': (1, 0),
52 > 'wsgi.version': (1, 0),
55 > 'wsgi.url_scheme': 'http',
53 > 'wsgi.url_scheme': 'http',
56 > 'wsgi.errors': errors,
54 > 'wsgi.errors': errors,
57 > 'wsgi.input': input,
55 > 'wsgi.input': input,
58 > 'wsgi.multithread': False,
56 > 'wsgi.multithread': False,
59 > 'wsgi.multiprocess': False,
57 > 'wsgi.multiprocess': False,
60 > 'wsgi.run_once': False,
58 > 'wsgi.run_once': False,
61 > 'REQUEST_METHOD': 'GET',
59 > 'REQUEST_METHOD': 'GET',
62 > 'SCRIPT_NAME': '',
60 > 'SCRIPT_NAME': '',
63 > 'PATH_INFO': '',
61 > 'PATH_INFO': '',
64 > 'QUERY_STRING': '',
62 > 'QUERY_STRING': '',
65 > 'SERVER_NAME': '$LOCALIP',
63 > 'SERVER_NAME': '$LOCALIP',
66 > 'SERVER_PORT': os.environ['HGPORT'],
64 > 'SERVER_PORT': os.environ['HGPORT'],
67 > 'SERVER_PROTOCOL': 'HTTP/1.0'
65 > 'SERVER_PROTOCOL': 'HTTP/1.0'
68 > }
66 > }
69 >
67 >
70 > i = hgweb(b'.')
68 > i = hgweb_mod.hgweb(b'.')
71 > for c in i(env, startrsp):
69 > for c in i(env, startrsp):
72 > pass
70 > pass
73 > sys.stdout.flush()
71 > sys.stdout.flush()
74 > pycompat.stdout.write(b'---- ERRORS\n')
72 > pycompat.stdout.write(b'---- ERRORS\n')
75 > pycompat.stdout.write(b'%s\n' % errors.getvalue())
73 > pycompat.stdout.write(b'%s\n' % errors.getvalue())
76 > print('---- OS.ENVIRON wsgi variables')
74 > print('---- OS.ENVIRON wsgi variables')
77 > print(sorted([x for x in os.environ if x.startswith('wsgi')]))
75 > print(sorted([x for x in os.environ if x.startswith('wsgi')]))
78 > print('---- request.ENVIRON wsgi variables')
76 > print('---- request.ENVIRON wsgi variables')
79 > with i._obtainrepo() as repo:
77 > with i._obtainrepo() as repo:
80 > print(sorted([encoding.strfromlocal(x) for x in repo.ui.environ
78 > print(sorted([encoding.strfromlocal(x) for x in repo.ui.environ
81 > if x.startswith(b'wsgi')]))
79 > if x.startswith(b'wsgi')]))
82 > EOF
80 > EOF
83 $ "$PYTHON" request.py
81 $ "$PYTHON" request.py
84 ---- STATUS
82 ---- STATUS
85 200 Script output follows
83 200 Script output follows
86 ---- HEADERS
84 ---- HEADERS
87 [('Content-Type', 'text/html; charset=ascii')]
85 [('Content-Type', 'text/html; charset=ascii')]
88 ---- DATA
86 ---- DATA
89 ---- ERRORS
87 ---- ERRORS
90
88
91 ---- OS.ENVIRON wsgi variables
89 ---- OS.ENVIRON wsgi variables
92 []
90 []
93 ---- request.ENVIRON wsgi variables
91 ---- request.ENVIRON wsgi variables
94 ['wsgi.errors', 'wsgi.input', 'wsgi.multiprocess', 'wsgi.multithread', 'wsgi.run_once', 'wsgi.url_scheme', 'wsgi.version']
92 ['wsgi.errors', 'wsgi.input', 'wsgi.multiprocess', 'wsgi.multithread', 'wsgi.run_once', 'wsgi.url_scheme', 'wsgi.version']
95
93
96 $ cd ..
94 $ cd ..
General Comments 0
You need to be logged in to leave comments. Login now