##// END OF EJS Templates
Backed out changeset 4879468fa28f (incorrect Content-Length on Windows)
Dirkjan Ochtman -
r6796:943f066c default
parent child Browse files
Show More
@@ -169,20 +169,20 b' class hgweb(object):'
169
169
170 req.write(content)
170 req.write(content)
171 del tmpl
171 del tmpl
172 return ''.join(content),
172 return req
173
173
174 except revlog.LookupError, err:
174 except revlog.LookupError, err:
175 req.respond(HTTP_NOT_FOUND, ctype)
175 req.respond(HTTP_NOT_FOUND, ctype)
176 msg = str(err)
176 msg = str(err)
177 if 'manifest' not in msg:
177 if 'manifest' not in msg:
178 msg = 'revision not found: %s' % err.name
178 msg = 'revision not found: %s' % err.name
179 return ''.join(tmpl('error', error=msg)),
179 req.write(tmpl('error', error=msg))
180 except (RepoError, revlog.RevlogError), inst:
180 except (RepoError, revlog.RevlogError), inst:
181 req.respond(HTTP_SERVER_ERROR, ctype)
181 req.respond(HTTP_SERVER_ERROR, ctype)
182 return ''.join(tmpl('error', error=str(inst))),
182 req.write(tmpl('error', error=str(inst)))
183 except ErrorResponse, inst:
183 except ErrorResponse, inst:
184 req.respond(inst.code, ctype)
184 req.respond(inst.code, ctype)
185 return ''.join(tmpl('error', error=inst.message)),
185 req.write(tmpl('error', error=inst.message))
186
186
187 def templater(self, req):
187 def templater(self, req):
188
188
@@ -70,7 +70,8 b' class hgwebdir(object):'
70
70
71 def __call__(self, env, respond):
71 def __call__(self, env, respond):
72 req = wsgirequest(env, respond)
72 req = wsgirequest(env, respond)
73 return self.run_wsgi(req)
73 self.run_wsgi(req)
74 return req
74
75
75 def run_wsgi(self, req):
76 def run_wsgi(self, req):
76
77
@@ -89,12 +90,14 b' class hgwebdir(object):'
89 fname = virtual[7:]
90 fname = virtual[7:]
90 else:
91 else:
91 fname = req.form['static'][0]
92 fname = req.form['static'][0]
92 return staticfile(static, fname, req),
93 req.write(staticfile(static, fname, req))
94 return
93
95
94 # top-level index
96 # top-level index
95 elif not virtual:
97 elif not virtual:
96 req.respond(HTTP_OK, ctype)
98 req.respond(HTTP_OK, ctype)
97 return ''.join(self.makeindex(req, tmpl)),
99 req.write(self.makeindex(req, tmpl))
100 return
98
101
99 # nested indexes and hgwebs
102 # nested indexes and hgwebs
100
103
@@ -105,7 +108,8 b' class hgwebdir(object):'
105 req.env['REPO_NAME'] = virtual
108 req.env['REPO_NAME'] = virtual
106 try:
109 try:
107 repo = hg.repository(self.parentui, real)
110 repo = hg.repository(self.parentui, real)
108 return hgweb(repo).run_wsgi(req)
111 hgweb(repo).run_wsgi(req)
112 return
109 except IOError, inst:
113 except IOError, inst:
110 msg = inst.strerror
114 msg = inst.strerror
111 raise ErrorResponse(HTTP_SERVER_ERROR, msg)
115 raise ErrorResponse(HTTP_SERVER_ERROR, msg)
@@ -116,7 +120,8 b' class hgwebdir(object):'
116 subdir = virtual + '/'
120 subdir = virtual + '/'
117 if [r for r in repos if r.startswith(subdir)]:
121 if [r for r in repos if r.startswith(subdir)]:
118 req.respond(HTTP_OK, ctype)
122 req.respond(HTTP_OK, ctype)
119 return ''.join(self.makeindex(req, tmpl, subdir)),
123 req.write(self.makeindex(req, tmpl, subdir))
124 return
120
125
121 up = virtual.rfind('/')
126 up = virtual.rfind('/')
122 if up < 0:
127 if up < 0:
@@ -125,11 +130,11 b' class hgwebdir(object):'
125
130
126 # prefixes not found
131 # prefixes not found
127 req.respond(HTTP_NOT_FOUND, ctype)
132 req.respond(HTTP_NOT_FOUND, ctype)
128 return ''.join(tmpl("notfound", repo=virtual)),
133 req.write(tmpl("notfound", repo=virtual))
129
134
130 except ErrorResponse, err:
135 except ErrorResponse, err:
131 req.respond(err.code, ctype)
136 req.respond(err.code, ctype)
132 return ''.join(tmpl('error', error=err.message or '')),
137 req.write(tmpl('error', error=err.message or ''))
133 finally:
138 finally:
134 tmpl = None
139 tmpl = None
135
140
@@ -43,17 +43,15 b' env = {'
43
43
44 output = StringIO()
44 output = StringIO()
45 env['QUERY_STRING'] = 'style=atom'
45 env['QUERY_STRING'] = 'style=atom'
46 content = hgweb('.', name = 'repo')(env, startrsp)
46 hgweb('.', name = 'repo')(env, startrsp)
47 sys.stdout.write(output.getvalue())
47 print output.getvalue()
48 sys.stdout.write(''.join(content))
49 print '---- ERRORS'
48 print '---- ERRORS'
50 print errors.getvalue()
49 print errors.getvalue()
51
50
52 output = StringIO()
51 output = StringIO()
53 env['QUERY_STRING'] = 'style=raw'
52 env['QUERY_STRING'] = 'style=raw'
54 content = hgwebdir({'repo': '.'})(env, startrsp)
53 hgwebdir({'repo': '.'})(env, startrsp)
55 sys.stdout.write(output.getvalue())
54 print output.getvalue()
56 sys.stdout.write(''.join(content))
57 print '---- ERRORS'
55 print '---- ERRORS'
58 print errors.getvalue()
56 print errors.getvalue()
59 EOF
57 EOF
@@ -35,6 +35,7 b' 200 Script output follows'
35 </entry>
35 </entry>
36
36
37 </feed>
37 </feed>
38
38 ---- ERRORS
39 ---- ERRORS
39
40
40 ---- HEADERS
41 ---- HEADERS
@@ -44,5 +45,6 b' 200 Script output follows'
44
45
45 repo/
46 repo/
46
47
48
47 ---- ERRORS
49 ---- ERRORS
48
50
@@ -44,36 +44,32 b' env = {'
44 output = StringIO()
44 output = StringIO()
45 env['PATH_INFO'] = '/'
45 env['PATH_INFO'] = '/'
46 env['QUERY_STRING'] = 'style=atom'
46 env['QUERY_STRING'] = 'style=atom'
47 content = hgweb('.', name = 'repo')(env, startrsp)
47 hgweb('.', name = 'repo')(env, startrsp)
48 sys.stdout.write(output.getvalue())
48 print output.getvalue()
49 sys.stdout.write(''.join(content))
50 print '---- ERRORS'
49 print '---- ERRORS'
51 print errors.getvalue()
50 print errors.getvalue()
52
51
53 output = StringIO()
52 output = StringIO()
54 env['PATH_INFO'] = '/file/tip/'
53 env['PATH_INFO'] = '/file/tip/'
55 env['QUERY_STRING'] = 'style=raw'
54 env['QUERY_STRING'] = 'style=raw'
56 content = hgweb('.', name = 'repo')(env, startrsp)
55 hgweb('.', name = 'repo')(env, startrsp)
57 sys.stdout.write(output.getvalue())
56 print output.getvalue()
58 sys.stdout.write(''.join(content))
59 print '---- ERRORS'
57 print '---- ERRORS'
60 print errors.getvalue()
58 print errors.getvalue()
61
59
62 output = StringIO()
60 output = StringIO()
63 env['PATH_INFO'] = '/'
61 env['PATH_INFO'] = '/'
64 env['QUERY_STRING'] = 'style=raw'
62 env['QUERY_STRING'] = 'style=raw'
65 content = hgwebdir({'repo': '.'})(env, startrsp)
63 hgwebdir({'repo': '.'})(env, startrsp)
66 sys.stdout.write(output.getvalue())
64 print output.getvalue()
67 sys.stdout.write(''.join(content))
68 print '---- ERRORS'
65 print '---- ERRORS'
69 print errors.getvalue()
66 print errors.getvalue()
70
67
71 output = StringIO()
68 output = StringIO()
72 env['PATH_INFO'] = '/repo/file/tip/'
69 env['PATH_INFO'] = '/repo/file/tip/'
73 env['QUERY_STRING'] = 'style=raw'
70 env['QUERY_STRING'] = 'style=raw'
74 content = hgwebdir({'repo': '.'})(env, startrsp)
71 hgwebdir({'repo': '.'})(env, startrsp)
75 sys.stdout.write(output.getvalue())
72 print output.getvalue()
76 sys.stdout.write(''.join(content))
77 print '---- ERRORS'
73 print '---- ERRORS'
78 print errors.getvalue()
74 print errors.getvalue()
79 EOF
75 EOF
@@ -35,6 +35,7 b' 200 Script output follows'
35 </entry>
35 </entry>
36
36
37 </feed>
37 </feed>
38
38 ---- ERRORS
39 ---- ERRORS
39
40
40 ---- HEADERS
41 ---- HEADERS
@@ -45,6 +46,7 b' 200 Script output follows'
45 -rw-r--r-- 4 bar
46 -rw-r--r-- 4 bar
46
47
47
48
49
48 ---- ERRORS
50 ---- ERRORS
49
51
50 ---- HEADERS
52 ---- HEADERS
@@ -54,6 +56,7 b' 200 Script output follows'
54
56
55 /repo/
57 /repo/
56
58
59
57 ---- ERRORS
60 ---- ERRORS
58
61
59 ---- HEADERS
62 ---- HEADERS
@@ -64,5 +67,6 b' 200 Script output follows'
64 -rw-r--r-- 4 bar
67 -rw-r--r-- 4 bar
65
68
66
69
70
67 ---- ERRORS
71 ---- ERRORS
68
72
General Comments 0
You need to be logged in to leave comments. Login now