Please enable JavaScript to use RhodeCode Enterprise
##// END OF EJS Templates
Dirkjan Ochtman
- Thu, 03 Apr 2008 11:21:42
Show More
tests/test-hgweb-no-path-info
0
created
755
+59
0
@@
-0,0
+1,59
b''
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" -d "0 0" -u "Testing"
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(headers, data):
23
print '---- HEADERS'
24
print headers
25
print '---- DATA'
26
print data
27
return output.write
28
29
env = {
30
'wsgi.version': (1, 0),
31
'wsgi.url_scheme': 'http',
32
'wsgi.errors': errors,
33
'wsgi.input': input,
34
'wsgi.multithread': False,
35
'wsgi.multiprocess': False,
36
'wsgi.run_once': False,
37
'REQUEST_METHOD': 'GET',
38
'SCRIPT_NAME': '',
39
'SERVER_NAME': '127.0.0.1',
40
'SERVER_PORT': os.environ['HGPORT'],
41
'SERVER_PROTOCOL': 'HTTP/1.0'
42
}
43
44
output = StringIO()
45
env['QUERY_STRING'] = 'style=atom'
46
hgweb('.', name = 'repo')(env, startrsp)
47
print output.getvalue()
48
print '---- ERRORS'
49
print errors.getvalue()
50
51
output = StringIO()
52
env['QUERY_STRING'] = 'style=raw'
53
hgwebdir({'repo': '.'})(env, startrsp)
54
print output.getvalue()
55
print '---- ERRORS'
56
print errors.getvalue()
57
EOF
58
59
python request.py | sed "s/http:\/\/127\.0\.0\.1:[0-9]*\//http:\/\/127.0.0.1\//"
tests/test-hgweb-no-path-info.out
0
created
644
+50
0
@@
-0,0
+1,50
b''
1
changeset: 0:4cbec7e6f8c4
2
tag: tip
3
user: Testing
4
date: Thu Jan 01 00:00:00 1970 +0000
5
summary: test
6
7
---- HEADERS
8
200 Script output follows
9
---- DATA
10
[('Content-Type', 'application/atom+xml; charset=ascii')]
11
<?xml version="1.0" encoding="ascii"?>
12
<feed xmlns="http://www.w3.org/2005/Atom">
13
<!-- Changelog -->
14
<id>http://127.0.0.1/</id>
15
<link rel="self" href="http://127.0.0.1/atom-log"/>
16
<link rel="alternate" href="http://127.0.0.1/"/>
17
<title>repo Changelog</title>
18
<updated>1970-01-01T00:00:00+00:00</updated>
19
20
<entry>
21
<title>test</title>
22
<id>http://www.selenic.com/mercurial/#changeset-4cbec7e6f8c42eb52b6b52670e1f7560ae9a101e</id>
23
<link href="http://127.0.0.1/rev/4cbec7e6f8c42eb52b6b52670e1f7560ae9a101e"/>
24
<author>
25
<name>Testing</name>
26
<email>Testing</email>
27
</author>
28
<updated>1970-01-01T00:00:00+00:00</updated>
29
<published>1970-01-01T00:00:00+00:00</published>
30
<content type="xhtml">
31
<div xmlns="http://www.w3.org/1999/xhtml">
32
<pre xml:space="preserve">test</pre>
33
</div>
34
</content>
35
</entry>
36
37
</feed>
38
39
---- ERRORS
40
41
---- HEADERS
42
200 Script output follows
43
---- DATA
44
[('Content-Type', 'text/plain; charset=ascii')]
45
46
repo/
47
48
49
---- ERRORS
50
mercurial/hgweb/hgweb_mod.py
0
+2
-2
@@
-123,8
+123,8
b' class hgweb(object):'
123
if 'REPO_NAME' in req . env :
123
if 'REPO_NAME' in req . env :
124
req . url += req . env [ 'REPO_NAME' ] + '/'
124
req . url += req . env [ 'REPO_NAME' ] + '/'
125
125
126
if req . env .get('PATH_INFO'):
126
if 'PATH_INFO' in req . env :
127
parts = req . env .get('PATH_INFO' ). strip ( '/' ) . split ( '/' )
127
parts = req . env [ 'PATH_INFO' ] . strip ( '/' ) . split ( '/' )
128
repo_parts = req . env . get ( 'REPO_NAME' , '' ) . split ( '/' )
128
repo_parts = req . env . get ( 'REPO_NAME' , '' ) . split ( '/' )
129
if parts [: len ( repo_parts )] == repo_parts :
129
if parts [: len ( repo_parts )] == repo_parts :
130
parts = parts [ len ( repo_parts ):]
130
parts = parts [ len ( repo_parts ):]
mercurial/hgweb/hgwebdir_mod.py
0
+3
-1
@@
-181,7
+181,9
b' class hgwebdir(object):'
181
if u . configbool ( "web" , "hidden" , untrusted = True ):
181
if u . configbool ( "web" , "hidden" , untrusted = True ):
182
continue
182
continue
183
183
184
parts = [ req.env['PATH_INFO'].rstrip('/'), name ]
184
parts = [ name ]
185
if 'PATH_INFO' in req . env :
186
parts . insert ( 0 , req . env [ 'PATH_INFO' ] . rstrip ( '/' ))
185
if req . env [ 'SCRIPT_NAME' ]:
187
if req . env [ 'SCRIPT_NAME' ]:
186
parts . insert ( 0 , req . env [ 'SCRIPT_NAME' ])
188
parts . insert ( 0 , req . env [ 'SCRIPT_NAME' ])
187
url = ( '/' . join ( parts ) . replace ( "//" , "/" )) + '/'
189
url = ( '/' . join ( parts ) . replace ( "//" , "/" )) + '/'
Site-wide shortcuts
/
Use quick search box
g h
Goto home page
g g
Goto my private gists page
g G
Goto my public gists page
g 0-9
Goto bookmarked items from 0-9
n r
New repository page
n g
New gist page
Repositories
g s
Goto summary page
g c
Goto changelog page
g f
Goto files page
g F
Goto files page with file search activated
g p
Goto pull requests page
g o
Goto repository settings
g O
Goto repository access permissions settings
t s
Toggle sidebar on some pages