diff options
author | Aleksey Lim <alsroot@sugarlabs.org> | 2012-09-20 06:38:12 (GMT) |
---|---|---|
committer | Aleksey Lim <alsroot@sugarlabs.org> | 2012-09-20 06:38:12 (GMT) |
commit | 8810659d6ac49e8d6bf127aa731b36e776e91f21 (patch) | |
tree | 0aa5f8233e84223386c8379febf017a16cb43b01 | |
parent | ce2214e2094df9bc0eb2e0c15934ce82539c19cd (diff) |
Avoid using --host, that is host to bind, while returing BLOBs' urls
-rw-r--r-- | sugar_network/node/commands.py | 6 | ||||
-rwxr-xr-x | tests/units/node.py | 15 |
2 files changed, 11 insertions, 10 deletions
diff --git a/sugar_network/node/commands.py b/sugar_network/node/commands.py index 6bceb68..5a6fc13 100644 --- a/sugar_network/node/commands.py +++ b/sugar_network/node/commands.py @@ -157,9 +157,9 @@ class NodeCommands(ad.VolumeCommands, Commands): if value is None: value = '/'.join(['', document, guid, name]) if value.startswith('/'): - value = 'http://%s:%s%s' % \ - (node.host.value, node.port.value, value) - return value + return 'http://' + request.environ['HTTP_HOST'] + value + else: + return value url = None meta = doc.meta(name) diff --git a/tests/units/node.py b/tests/units/node.py index 66e92e5..51882e8 100755 --- a/tests/units/node.py +++ b/tests/units/node.py @@ -298,28 +298,28 @@ class NodeTest(tests.Test): volume['context'].set_blob(guid5, 'icon', url={'file1': {'order': 1, 'url': '/1'}, 'file2': {'order': 2, 'url': 'http://2'}}) self.assertEqual( - {'guid': guid1, 'icon': 'http://localhost:8000/static/images/missing.png', 'layer': ['public']}, + {'guid': guid1, 'icon': 'http://localhost/static/images/missing.png', 'layer': ['public']}, call(cp, method='GET', document='context', guid=guid1, reply=['guid', 'icon', 'layer'])) self.assertEqual( {'guid': guid2, 'icon': 'http://foo/bar', 'layer': ['public']}, call(cp, method='GET', document='context', guid=guid2, reply=['guid', 'icon', 'layer'])) self.assertEqual( - {'guid': guid3, 'icon': 'http://localhost:8000/foo/bar', 'layer': ['public']}, + {'guid': guid3, 'icon': 'http://localhost/foo/bar', 'layer': ['public']}, call(cp, method='GET', document='context', guid=guid3, reply=['guid', 'icon', 'layer'])) self.assertEqual( - {'guid': guid4, 'data': 'http://localhost:8000/report/%s/data' % guid4, 'layer': ['public']}, + {'guid': guid4, 'data': 'http://localhost/report/%s/data' % guid4, 'layer': ['public']}, call(cp, method='GET', document='report', guid=guid4, reply=['guid', 'data', 'layer'])) self.assertEqual([ - {'guid': guid1, 'icon': 'http://localhost:8000/static/images/missing.png', 'layer': ['public']}, + {'guid': guid1, 'icon': 'http://localhost/static/images/missing.png', 'layer': ['public']}, {'guid': guid2, 'icon': 'http://foo/bar', 'layer': ['public']}, - {'guid': guid3, 'icon': 'http://localhost:8000/foo/bar', 'layer': ['public']}, - {'guid': guid5, 'icon': ['http://localhost:8000/1', 'http://2'], 'layer': ['public']}, + {'guid': guid3, 'icon': 'http://localhost/foo/bar', 'layer': ['public']}, + {'guid': guid5, 'icon': ['http://localhost/1', 'http://2'], 'layer': ['public']}, ], call(cp, method='GET', document='context', reply=['guid', 'icon', 'layer'])['result']) self.assertEqual([ - {'guid': guid4, 'data': 'http://localhost:8000/report/%s/data' % guid4, 'layer': ['public']}, + {'guid': guid4, 'data': 'http://localhost/report/%s/data' % guid4, 'layer': ['public']}, ], call(cp, method='GET', document='report', reply=['guid', 'data', 'layer'])['result']) @@ -347,6 +347,7 @@ def call(cp, principal=None, content=None, **kwargs): request = ad.Request(**kwargs) request.principal = principal request.content = content + request.environ = {'HTTP_HOST': 'localhost'} return cp.call(request, ad.Response()) |