| 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. |
| 4 |
|
| 5 |
$ hg init repo |
| 6 |
$ cd repo |
| 7 |
$ echo foo > bar |
| 8 |
$ hg add bar |
| 9 |
$ hg commit -m "test" |
| 10 |
$ hg tip |
| 11 |
changeset: 0:61c9426e69fe |
| 12 |
tag: tip |
| 13 |
user: test |
| 14 |
date: Thu Jan 01 00:00:00 1970 +0000 |
| 15 |
summary: test |
| 16 |
|
| 17 |
$ cat > request.py <<EOF |
| 18 |
> import os |
| 19 |
> import sys |
| 20 |
> from mercurial import ( |
| 21 |
> encoding, |
| 22 |
> hgweb, |
| 23 |
> util, |
| 24 |
> ) |
| 25 |
> stringio = util.stringio |
| 26 |
> |
| 27 |
> errors = stringio() |
| 28 |
> input = stringio() |
| 29 |
> |
| 30 |
> def startrsp(status, headers): |
| 31 |
> print('---- STATUS') |
| 32 |
> print(status) |
| 33 |
> print('---- HEADERS') |
| 34 |
> print([i for i in headers if i[0] != 'ETag']) |
| 35 |
> print('---- DATA') |
| 36 |
> return output.write |
| 37 |
> |
| 38 |
> env = { |
| 39 |
> 'wsgi.version': (1, 0), |
| 40 |
> 'wsgi.url_scheme': 'http', |
| 41 |
> 'wsgi.errors': errors, |
| 42 |
> 'wsgi.input': input, |
| 43 |
> 'wsgi.multithread': False, |
| 44 |
> 'wsgi.multiprocess': False, |
| 45 |
> 'wsgi.run_once': False, |
| 46 |
> 'REQUEST_METHOD': 'GET', |
| 47 |
> 'SCRIPT_NAME': '', |
| 48 |
> 'SERVER_NAME': '$LOCALIP', |
| 49 |
> 'SERVER_PORT': os.environ['HGPORT'], |
| 50 |
> 'SERVER_PROTOCOL': 'HTTP/1.0' |
| 51 |
> } |
| 52 |
> |
| 53 |
> def process(app): |
| 54 |
> content = app(env, startrsp) |
| 55 |
> sys.stdout.write(encoding.strfromlocal(output.getvalue())) |
| 56 |
> sys.stdout.write(encoding.strfromlocal(b''.join(content))) |
| 57 |
> getattr(content, 'close', lambda : None)() |
| 58 |
> print('---- ERRORS') |
| 59 |
> print(encoding.strfromlocal(errors.getvalue())) # avoid b'' output diff |
| 60 |
> |
| 61 |
> output = stringio() |
| 62 |
> env['PATH_INFO'] = '/' |
| 63 |
> env['QUERY_STRING'] = 'style=atom' |
| 64 |
> process(hgweb.hgweb(b'.', name=b'repo')) |
| 65 |
> |
| 66 |
> output = stringio() |
| 67 |
> env['PATH_INFO'] = '/file/tip/' |
| 68 |
> env['QUERY_STRING'] = 'style=raw' |
| 69 |
> process(hgweb.hgweb(b'.', name=b'repo')) |
| 70 |
> |
| 71 |
> output = stringio() |
| 72 |
> env['PATH_INFO'] = '/' |
| 73 |
> env['QUERY_STRING'] = 'style=raw' |
| 74 |
> process(hgweb.hgwebdir({b'repo': b'.'})) |
| 75 |
> |
| 76 |
> output = stringio() |
| 77 |
> env['PATH_INFO'] = '/repo/file/tip/' |
| 78 |
> env['QUERY_STRING'] = 'style=raw' |
| 79 |
> process(hgweb.hgwebdir({b'repo': b'.'})) |
| 80 |
> EOF |
| 81 |
$ "$PYTHON" request.py |
| 82 |
---- STATUS |
| 83 |
200 Script output follows |
| 84 |
---- HEADERS |
| 85 |
[('Content-Type', 'application/atom+xml; charset=ascii')] |
| 86 |
---- DATA |
| 87 |
<?xml version="1.0" encoding="ascii"?> |
| 88 |
<feed xmlns="http://www.w3.org/2005/Atom"> |
| 89 |
<!-- Changelog --> |
| 90 |
<id>http://$LOCALIP:$HGPORT/</id> (glob) |
| 91 |
<link rel="self" href="http://$LOCALIP:$HGPORT/atom-log"/> (glob) |
| 92 |
<link rel="alternate" href="http://$LOCALIP:$HGPORT/"/> (glob) |
| 93 |
<title>repo Changelog</title> |
| 94 |
<updated>1970-01-01T00:00:00+00:00</updated> |
| 95 |
|
| 96 |
<entry> |
| 97 |
<title>[default] test</title> |
| 98 |
<id>http://$LOCALIP:$HGPORT/#changeset-61c9426e69fef294feed5e2bbfc97d39944a5b1c</id> (glob) |
| 99 |
<link href="http://$LOCALIP:$HGPORT/rev/61c9426e69fe"/> (glob) |
| 100 |
<author> |
| 101 |
<name>test</name> |
| 102 |
<email>test</email> |
| 103 |
</author> |
| 104 |
<updated>1970-01-01T00:00:00+00:00</updated> |
| 105 |
<published>1970-01-01T00:00:00+00:00</published> |
| 106 |
<content type="xhtml"> |
| 107 |
<table xmlns="http://www.w3.org/1999/xhtml"> |
| 108 |
<tr> |
| 109 |
<th style="text-align:left;">changeset</th> |
| 110 |
<td>61c9426e69fe</td> |
| 111 |
</tr> |
| 112 |
<tr> |
| 113 |
<th style="text-align:left;">branch</th> |
| 114 |
<td>default</td> |
| 115 |
</tr> |
| 116 |
<tr> |
| 117 |
<th style="text-align:left;">bookmark</th> |
| 118 |
<td></td> |
| 119 |
</tr> |
| 120 |
<tr> |
| 121 |
<th style="text-align:left;">tag</th> |
| 122 |
<td>tip</td> |
| 123 |
</tr> |
| 124 |
<tr> |
| 125 |
<th style="text-align:left;">user</th> |
| 126 |
<td>test</td> |
| 127 |
</tr> |
| 128 |
<tr> |
| 129 |
<th style="text-align:left;vertical-align:top;">description</th> |
| 130 |
<td>test</td> |
| 131 |
</tr> |
| 132 |
<tr> |
| 133 |
<th style="text-align:left;vertical-align:top;">files</th> |
| 134 |
<td>bar<br /></td> |
| 135 |
</tr> |
| 136 |
</table> |
| 137 |
</content> |
| 138 |
</entry> |
| 139 |
|
| 140 |
</feed> |
| 141 |
---- ERRORS |
| 142 |
|
| 143 |
---- STATUS |
| 144 |
200 Script output follows |
| 145 |
---- HEADERS |
| 146 |
[('Content-Type', 'text/plain; charset=ascii')] |
| 147 |
---- DATA |
| 148 |
|
| 149 |
-rw-r--r-- 4 bar |
| 150 |
|
| 151 |
|
| 152 |
---- ERRORS |
| 153 |
|
| 154 |
---- STATUS |
| 155 |
200 Script output follows |
| 156 |
---- HEADERS |
| 157 |
[('Content-Type', 'text/plain; charset=ascii')] |
| 158 |
---- DATA |
| 159 |
|
| 160 |
/repo/ |
| 161 |
|
| 162 |
---- ERRORS |
| 163 |
|
| 164 |
---- STATUS |
| 165 |
200 Script output follows |
| 166 |
---- HEADERS |
| 167 |
[('Content-Type', 'text/plain; charset=ascii')] |
| 168 |
---- DATA |
| 169 |
|
| 170 |
-rw-r--r-- 4 bar |
| 171 |
|
| 172 |
|
| 173 |
---- ERRORS |
| 174 |
|
| 175 |
|
| 176 |
$ cd .. |