Ubuntu Pastebin

Paste from ubuntu at Wed, 25 Feb 2015 15:08:23 +0000

Download as text
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
=== modified file 'cloudinit/url_helper.py'
--- cloudinit/url_helper.py	2015-01-21 22:56:53 +0000
+++ cloudinit/url_helper.py	2015-02-25 14:56:24 +0000
@@ -116,10 +116,13 @@
 class UrlResponse(object):
     def __init__(self, response):
         self._response = response
+        self._contents = None
 
     @property
     def contents(self):
-        return self._response.text
+	if self._contents is not None:
+            self._contents = self._response.raw.read()
+        return self._contents
 
     @property
     def url(self):
@@ -143,7 +146,7 @@
         return self._response.status_code
 
     def __str__(self):
-        return self._response.text
+        return str(self.contents())
 
 
 class UrlError(IOError):
@@ -190,6 +193,7 @@
         req_args['timeout'] = max(float(timeout), 0)
     if data:
         req_args['method'] = 'POST'
+    req_args['stream'] = True
     # It doesn't seem like config
     # was added in older library versions (or newer ones either), thus we
     # need to manually do the retries if it wasn't...
@@ -233,6 +237,7 @@
             LOG.debug("[%s/%s] open '%s' with %s configuration", i,
                       manual_tries, url, filtered_req_args)
 
+            print("req_args: %s" % req_args)
             r = requests.request(**req_args)
             if check_status:
                 r.raise_for_status()
Download as text