diff --git a/swh/web/api/views/content.py b/swh/web/api/views/content.py --- a/swh/web/api/views/content.py +++ b/swh/web/api/views/content.py @@ -241,8 +241,9 @@ query_params['per_page'] = per_page result['headers'] = { - 'link-next': reverse('api-1-content-symbol', url_args={'q': q}, - query_params=query_params) + 'link-next': request.build_absolute_uri( + reverse('api-1-content-symbol', url_args={'q': q}, + query_params=query_params)) } result.update({ diff --git a/swh/web/api/views/origin.py b/swh/web/api/views/origin.py --- a/swh/web/api/views/origin.py +++ b/swh/web/api/views/origin.py @@ -127,10 +127,10 @@ response = {'results': results, 'headers': {}} if len(results) > origin_count: origin_from = results.pop()['id'] - response['headers']['link-next'] = reverse( - 'api-1-origins', - query_params={'origin_from': origin_from, - 'origin_count': origin_count}) + response['headers']['link-next'] = request.build_absolute_uri( + reverse('api-1-origins', + query_params={'origin_from': origin_from, + 'origin_count': origin_count})) return response @@ -236,9 +236,10 @@ query_params['regexp'] = regexp result['headers'] = { - 'link-next': reverse('api-1-origin-search', - url_args={'url_pattern': url_pattern}, - query_params=query_params) + 'link-next': request.build_absolute_uri( + reverse('api-1-origin-search', + url_args={'url_pattern': url_pattern}, + query_params=query_params)) } result.update({ @@ -372,9 +373,10 @@ query_params['per_page'] = per_page result['headers'] = { - 'link-next': reverse('api-1-origin-visits', - url_args=url_args_next, - query_params=query_params) + 'link-next': request.build_absolute_uri( + reverse('api-1-origin-visits', + url_args=url_args_next, + query_params=query_params)) } result.update({ diff --git a/swh/web/api/views/revision.py b/swh/web/api/views/revision.py --- a/swh/web/api/views/revision.py +++ b/swh/web/api/views/revision.py @@ -231,9 +231,10 @@ query_params['per_page'] = per_page result['headers'] = { - 'link-next': reverse('api-1-revision-log', - url_args={'sha1_git': new_last_sha1}, - query_params=query_params) + 'link-next': request.build_absolute_uri( + reverse('api-1-revision-log', + url_args={'sha1_git': new_last_sha1}, + query_params=query_params)) } else: diff --git a/swh/web/api/views/snapshot.py b/swh/web/api/views/snapshot.py --- a/swh/web/api/views/snapshot.py +++ b/swh/web/api/views/snapshot.py @@ -114,11 +114,11 @@ response = {'results': results, 'headers': {}} if results['next_branch'] is not None: - response['headers']['link-next'] = \ + response['headers']['link-next'] = request.build_absolute_uri( reverse('api-1-snapshot', url_args={'snapshot_id': snapshot_id}, query_params={'branches_from': results['next_branch'], 'branches_count': branches_count, - 'target_types': target_types}) + 'target_types': target_types})) return response diff --git a/swh/web/tests/api/views/test_content.py b/swh/web/tests/api/views/test_content.py --- a/swh/web/tests/api/views/test_content.py +++ b/swh/web/tests/api/views/test_content.py @@ -117,10 +117,11 @@ query_params={'per_page': 2}) rv = api_client.get(url) - next_url = reverse('api-1-content-symbol', - url_args={'q': contents_with_ctags['symbol_name']}, - query_params={'last_sha1': rv.data[1]['sha1'], - 'per_page': 2}) + next_url = rv.wsgi_request.build_absolute_uri( + reverse('api-1-content-symbol', + url_args={'q': contents_with_ctags['symbol_name']}, + query_params={'last_sha1': rv.data[1]['sha1'], + 'per_page': 2})) assert rv['Link'] == '<%s>; rel="next"' % next_url diff --git a/swh/web/tests/api/views/test_revision.py b/swh/web/tests/api/views/test_revision.py --- a/swh/web/tests/api/views/test_revision.py +++ b/swh/web/tests/api/views/test_revision.py @@ -89,10 +89,10 @@ if has_next: assert 'Link' in rv - next_log_url = reverse( - 'api-1-revision-log', - url_args={'sha1_git': expected_log[-1]['id']}, - query_params={'per_page': per_page}) + next_log_url = rv.wsgi_request.build_absolute_uri( + reverse('api-1-revision-log', + url_args={'sha1_git': expected_log[-1]['id']}, + query_params={'per_page': per_page})) assert next_log_url in rv['Link'] diff --git a/swh/web/tests/api/views/test_snapshot.py b/swh/web/tests/api/views/test_snapshot.py --- a/swh/web/tests/api/views/test_snapshot.py +++ b/swh/web/tests/api/views/test_snapshot.py @@ -72,11 +72,11 @@ whole_snapshot['branches'].update(expected_data['branches']) if branches_offset < len(snapshot_branches): - next_url = reverse( - 'api-1-snapshot', - url_args={'snapshot_id': snapshot}, - query_params={'branches_from': next_branch, - 'branches_count': branches_count}) + next_url = rv.wsgi_request.build_absolute_uri( + reverse('api-1-snapshot', + url_args={'snapshot_id': snapshot}, + query_params={'branches_from': next_branch, + 'branches_count': branches_count})) assert rv['Link'] == '<%s>; rel="next"' % next_url else: assert not rv.has_header('Link')