Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions pytest_httpbin/serve.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ def finish_request(self, request, client_address):
server_side=True,
suppress_ragged_eofs=False,
)
self.base_environ['HTTPS'] = 'yes'
self.RequestHandlerClass(ssock, client_address, self)
except Exception as e:
print("pytest-httpbin server hit an exception serving request: %s" % e)
Expand Down
11 changes: 11 additions & 0 deletions tests/test_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,3 +92,14 @@ def test_fixed_port_environment_variables(protocol):
del os.environ[envvar]
else:
os.environ[envvar] = envvar_original


def test_redirect_location_is_https_for_secure_server(httpbin_secure):
assert httpbin_secure.url.startswith('https://')
response = requests.get(
httpbin_secure + "/redirect-to?url=/html",
allow_redirects=False
)
assert response.status_code == 302
assert response.headers.get('Location')
assert response.headers['Location'].startswith('https://')