Skip to content

Only use HostHeaderSSLAdapter for SSL/HTTPS connections #4498

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Aug 9, 2018
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
7 changes: 6 additions & 1 deletion readthedocs/api/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,12 @@

def setup_api():
session = Session()
session.mount(API_HOST, host_header_ssl.HostHeaderSSLAdapter())
if API_HOST.startswith('https'):
# Only use the HostHeaderSSLAdapter for HTTPS connections
session.mount(
API_HOST,
host_header_ssl.HostHeaderSSLAdapter(),
)
session.headers.update({'Host': PRODUCTION_DOMAIN})
api_config = {
'base_url': '%s/api/v1/' % API_HOST,
Expand Down
14 changes: 8 additions & 6 deletions readthedocs/restapi/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,14 @@ def dumps(self, data):

def setup_api():
session = requests.Session()
session.mount(
API_HOST,
host_header_ssl.HostHeaderSSLAdapter(
max_retries=3,
),
)
if API_HOST.startswith('https'):
# Only use the HostHeaderSSLAdapter for HTTPS connections
session.mount(
API_HOST,
host_header_ssl.HostHeaderSSLAdapter(
max_retries=3,
),
)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

max_retries was from the original adapter, we should add this with the standard http adapter if the connection is not ssl.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That was not there prior to the PR that added the HostHeaderSSLAdapter. Do you think it is necessary to support retries in dev?

session.headers.update({'Host': PRODUCTION_DOMAIN})
api_config = {
'base_url': '%s/api/v2/' % API_HOST,
Expand Down