Skip to content

Commit

Permalink
SERV_NAME test does not rely on loopback hostname
Browse files Browse the repository at this point in the history
  • Loading branch information
Mathieu Sornay committed Oct 5, 2015
1 parent 633b862 commit becaee4
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions tests/http/base.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import os
from base64 import b64decode
import socket
import unittest

import examples
Expand Down Expand Up @@ -694,9 +695,9 @@ def test_servername(self):
http.headers.remove_header('host')
self.assertNotIn('host', http.headers)
http.headers['host'] = 'fakehost'

response = yield from http.get(self.httpbin('servername'))
self.assertEqual(response.status_code, 200)

result = response.decode_content().strip()
self.assertIn(result, ['localhost', ])
# result should resolve to loopback address
ips = {sockaddr[0] for _, _, _, _, sockaddr in socket.getaddrinfo(result, None)}
self.assertTrue({'127.0.0.1', '::1'} & ips)

0 comments on commit becaee4

Please sign in to comment.