Martin Panter added the comment: It looks like this is a fault in the server. It does not appear to support Connection: close over HTTP 1.1, which is what Python’s “urllib.request” module uses. I think you will either have to get the server fixed, or work around the problem by using the low level “http.client” module, where you can avoid sending a “Connection: close” header field.
However see also Issue 12849, where various other people (including myself at one stage) have found this “Connection: close” flag triggers various server problems. HTTP responses from the server with and without the “close” flag: ## HTTP 1.1 without Connection: close → good chunked response ## POST /dataminer/rest/public/api/markets/dayahead/lmp/daily HTTP/1.1 Host: dataminer.pjm.com Content-Type: application/json Content-Length: 80 {"startDate": "2015-07-01", "endDate": "2015-07-01", "pnodelist": [135389795]} HTTP/1.1 200 OK Server: Apache-Coyote/1.1 X-UA-Compatible: IE=edge Cache-Control: no-cache Expires: -1 X-Powered-By: ASP.NET X-AspNet-Version: 4.0.30319 X-Request-UUID: 09513fea-ac35-41ea-bf1b-b69357f42594 Transfer-Encoding: chunked Server: Microsoft-IIS/7.5 Date: Wed, 09 Sep 2015 04:12:34 GMT Pragma: no-cache Content-Type: application/json Transfer-Encoding: chunked Set-Cookie: dataminer=1923355820.36895.0000; path=/ 1a44 [ { "publishDate": "2015-07-01T04:00:00Z", [. . .] ## HTTP 1.1 with Connection: close → invalid chunked response ## POST /dataminer/rest/public/api/markets/dayahead/lmp/daily HTTP/1.1 Host: dataminer.pjm.com Connection: close Content-Type: application/json Content-Length: 80 {"startDate": "2015-07-01", "endDate": "2015-07-01", "pnodelist": [135389795]} HTTP/1.1 200 OK Server: Apache-Coyote/1.1 X-UA-Compatible: IE=edge Cache-Control: no-cache Connection: close Expires: -1 X-Powered-By: ASP.NET X-AspNet-Version: 4.0.30319 X-Request-UUID: 0b43546c-d484-47a1-aff3-384f62a94a5a Transfer-Encoding: chunked Server: Microsoft-IIS/7.5 Date: Wed, 09 Sep 2015 04:13:00 GMT Pragma: no-cache Content-Type: application/json Connection: close [ { "publishDate": "2015-07-01T04:00:00Z", [. . .] ---------- nosy: +martin.panter resolution: -> third party status: open -> closed superseder: -> Cannot override 'connection: close' in urllib2 headers type: crash -> behavior _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue25037> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com