1
From: Clint Byrum <clint@ubuntu.com>
2
Description: Makes txaws use alternate port in S3 URL
3
Bug: http://pad.lv/824403
4
Origin: https://code.launchpad.net/~clint-fewbar/txaws/fix-s3-port/+merge/71289
7
=== modified file 'txaws/s3/client.py'
8
--- a/txaws/s3/client.py 2011-04-14 19:50:30 +0000
9
+++ b/txaws/s3/client.py 2011-08-29 19:06:23 +0000
14
- return "%s://%s%s" % (
15
- self.endpoint.scheme, self.get_host(), self.get_path())
16
+ if self.endpoint.port is not None:
17
+ return "%s://%s:%d%s" % (
18
+ self.endpoint.scheme, self.get_host(), self.endpoint.port, self.get_path())
20
+ return "%s://%s%s" % (
21
+ self.endpoint.scheme, self.get_host(), self.get_path())
24
class S3Client(BaseClient):
26
=== modified file 'txaws/s3/tests/test_client.py'
27
--- a/txaws/s3/tests/test_client.py 2011-04-14 19:50:30 +0000
28
+++ b/txaws/s3/tests/test_client.py 2011-08-29 19:06:23 +0000
30
url_context.get_url(),
31
"http://localhost/mydocs/notes.txt")
33
+ def test_custom_port_endpoint(self):
34
+ test_uri='http://0.0.0.0:12345/'
35
+ endpoint = AWSServiceEndpoint(uri=test_uri)
36
+ self.assertEquals(endpoint.port, 12345)
37
+ self.assertEquals(endpoint.scheme, 'http')
38
+ context = client.URLContext(service_endpoint=endpoint,
41
+ self.assertEquals(context.get_host(), '0.0.0.0')
42
+ self.assertEquals(context.get_url(), test_uri + 'foo/bar')
44
+ def test_custom_port_endpoint_https(self):
45
+ test_uri='https://0.0.0.0:12345/'
46
+ endpoint = AWSServiceEndpoint(uri=test_uri)
47
+ self.assertEquals(endpoint.port, 12345)
48
+ self.assertEquals(endpoint.scheme, 'https')
49
+ context = client.URLContext(service_endpoint=endpoint,
52
+ self.assertEquals(context.get_host(), '0.0.0.0')
53
+ self.assertEquals(context.get_url(), test_uri + 'foo/bar')
56
URLContextTestCase.skip = s3clientSkip