Skip to content
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

Wrong Host header sent when server on different hostname #47

Open
graue opened this issue Dec 7, 2012 · 1 comment
Open

Wrong Host header sent when server on different hostname #47

graue opened this issue Dec 7, 2012 · 1 comment

Comments

@graue
Copy link

graue commented Dec 7, 2012

My entity is https://scott.mn. My server (right now) is http://tent.toxicsli.me. I found that the last step of auth (exchanging code for an access token) was failing because python-tent-client was making the request to http://scott.mn. This change fixed it:

--- tentapp.py.orig 2012-12-06 17:59:36.653636916 -0600
+++ tentapp.py  2012-12-06 17:59:28.529637767 -0600
@@ -210,7 +210,6 @@
         # we don't have auth keys yet, so make a non-auth session.
         # if authenticate is run later, this session will be replaced with a session that does authentication
         headers = dict(DEFAULT_HEADERS)
-        headers['Host'] = urlparse(self.entityUrl).netloc
         self.session = requests.session(hooks={"pre_request": self._authHook}, headers=headers)

         # this list of api roots will be filled in by _discoverAPIurls()
@@ -220,7 +219,6 @@
         # now that we've run discovery, the entityUrl might have changed
         # so we have to make a new session again.
         headers = dict(DEFAULT_HEADERS)
-        headers['Host'] = urlparse(self.entityUrl).netloc
         self.session = requests.session(hooks={"pre_request": self._authHook}, headers=headers)

Now I'm wondering why the Host header was explicitly set in the first place. Everything seems to work without it, but is there something I'm missing? Why would you explicitly set the Host header rather than leave it up to Requests?

@longears
Copy link
Owner

longears commented Dec 7, 2012

Looks like it came from this commit: 097c825

I'm not sure why it's there. Doesn't seem like we need to override Requests.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants