Julien Cristau pushed to branch master
at snapshot / snapshot
Commits:
-
0bd1c098
by Baptiste Beauplat
at 2022-09-13T21:07:47+02:00
Use 302 for redirect instead of 301
-
f58bf2e5
by Julien Cristau
at 2022-09-13T19:17:58+00:00
Merge branch 'fix/redirect' into 'master'
Use 302 for redirect instead of 301
See merge request snapshot-team/snapshot!2
2 changed files:
Changes:
web/app/snapshot/views/archive.py
... |
... |
@@ -93,7 +93,7 @@ def archive_dir(archive, date, path='/'): |
93
|
93
|
except ArchiveError as e:
|
94
|
94
|
abort(404, str(e))
|
95
|
95
|
except ArchiveRedirect as e:
|
96
|
|
- return redirect(str(e), code=301)
|
|
96
|
+ return redirect(str(e))
|
97
|
97
|
|
98
|
98
|
if isinstance(node, ArchiveDir):
|
99
|
99
|
archive_dir.cache_timeout = current_app.config[
|
web/app/tests/unit/views/test_archive.py
... |
... |
@@ -128,10 +128,10 @@ def test_archive_runs(client, archive, year, month, status, error, archive_view, |
128
|
128
|
'/été'),
|
129
|
129
|
('20200813T185438Z', 404, 'No such file or directory', None,
|
130
|
130
|
'/dists///////not-found'),
|
131
|
|
- ('20200813T185438Z', 301, None, '20200813T185438Z/dists/unstable',
|
|
131
|
+ ('20200813T185438Z', 302, None, '20200813T185438Z/dists/unstable',
|
132
|
132
|
'/dists/sid'),
|
133
|
|
- ('40000813T185438Z', 301, None, '20200813T185438Z', ''),
|
134
|
|
- ('now', 301, None, '20200813T185438Z', ''),
|
|
133
|
+ ('40000813T185438Z', 302, None, '20200813T185438Z', ''),
|
|
134
|
+ ('now', 302, None, '20200813T185438Z', ''),
|
135
|
135
|
))
|
136
|
136
|
def test_archive_files(client, date, status, error, redirect, path,
|
137
|
137
|
archive_view, breadcrumbs):
|
... |
... |
@@ -141,7 +141,7 @@ def test_archive_files(client, date, status, error, redirect, path, |
141
|
141
|
|
142
|
142
|
if status == 404:
|
143
|
143
|
assert error in unescape(response.data.decode())
|
144
|
|
- elif status == 301:
|
|
144
|
+ elif status == 302:
|
145
|
145
|
assert response.location == \
|
146
|
146
|
f'http://localhost/archive/debian/{redirect}/'
|
147
|
147
|
else:
|
... |
... |
@@ -226,7 +226,7 @@ def test_archive_redirect_farm(client, config, date, content, path): |
226
|
226
|
|
227
|
227
|
response = client.get(f'/archive/debian/{date}{path}/')
|
228
|
228
|
|
229
|
|
- assert response.status_code == 301
|
|
229
|
+ assert response.status_code == 302
|
230
|
230
|
assert '/file/' in response.location
|
231
|
231
|
|
232
|
232
|
response = client.get(response.location)
|
|