title: Error while decoding raw in Python
body: <p>I am trying to write PyUnit test, where i am passing the URL to the test and the test needs to fetch the data and decode. The data is coming as raw payload. We are using REST. Here is the test code i have written :</p>
  
  <pre><code>#import urllib
  import urllib.request
  import json
  
  proxy_support = urllib.request.ProxyHandler({"http":"http://local:8080"})
  opener = urllib.request.build_opener(proxy_support)
  urllib.request.install_opener(opener)
  
  request = urllib.request.Request("http://test.com/1")
  response = urllib.request.urlopen(request)
  encoding = response.info().get_param('charset', 'utf8')
  data = json.loads(response.read().decode(encoding))
  print (data)
  </code></pre>
  
  <p>The problem is that i am getting the following error :</p>
  
  <pre><code>data = json.loads(response.read().decode(encoding))
  </code></pre>
  
  <blockquote>
    <p>File "C:\Python34\lib\json__init__.py", line 318, in loads<br/>
            return _default_decoder.decode(s)<br/>
        File "C:\Python34\lib\json\decoder.py", line 343, in decode<br/>
            obj, end = self.raw_decode(s, idx=_w(s, 0).end())<br/>
        File "C:\Python34\lib\json\decoder.py", line 361, in raw_decode<br/>
            raise ValueError(errmsg("Expecting value", s, err.value)) from None <br/>
        ValueError: Expecting value: line 1 column 1 (char 0)<br/></p>
  </blockquote>
  
  <p>Could someone help ? Thanks in advance.</p>
  
  <p>Regards
  Amit</p>