title: python requests randomly breaks with JSONDecodeError
body: <p>I have been debugging for hours why my code randomly breaks with this error: <code>JSONDecodeError: Expecting value: line 1 column 1 (char 0)</code></p>
  
  <p>This is the code I have: </p>
  
  <pre><code>while True:
      try:
          submissions = requests.get('http://reymisterio.net/data-dump/api.php/submission?filter[]=form,cs,'+client+'&amp;filter[]=date,cs,'+since).json()['submission']['records']
          break
      except requests.exceptions.ConnectionError:
          time.sleep(100)
  </code></pre>
  
  <p>And I've been debugging by printing <code>requests.get(url)</code> and <code>requests.get(url).text</code> and I have encountered the following "special "cases:</p>
  
  <ol>
  <li><p><code>requests.get(url)</code> returns a successful 200 response and <code>requests.get(url).text</code> returns html. I have read online that this should fail when using <code>requests.get(url).json()</code>, because it won't be able to read the html, but somehow it doesn't break. Why is this?</p></li>
  <li><p><code>requests.get(url)</code> returns a successful 200 response and <code>requests.get(url).text</code> is in json format. I don't understand why when it goes to the <code>requests.get(url).json()</code> line it breaks with the JSONDecodeError?</p></li>
  </ol>
  
  <p>The exact value of <code>requests.get(url).text</code> for case 2 is:</p>
  
  <pre><code>{
    "submission": {
      "columns": [
        "pk",
        "form",
        "date",
        "ip"
      ],
      "records": [
        [
          "21197",
          "mistico-form-contacto-form",
          "2018-09-21 09:04:41",
          "186.179.71.106"
        ]
      ]
    }
  }
  </code></pre>