google / gdata-python-client

444 stars 228 forks source link

Google Feed sometimes provides 0 length, empty response with http status 200, resulting in traceback #40

Open akrherz opened 8 years ago

akrherz commented 8 years ago

I am using the current master and python2.7. I seem to occasionally hit a repeatable bug with Google's Feed providing a 0 content length, empty response, but with a 200 http status code. For example, this feed is currently doing it.

This results in python traceback

Traceback (most recent call last):
  File "playground.py", line 12, in <module>
    print sprclient.GetWorksheets('1UeEJ0rTQaP0H2nidUDaNVu9D5Mw26BuaHInkAJnF6ms')
  File "/home/akrherz/projects/gdata-python-client/src/gdata/spreadsheets/client.py", line 108, in get_worksheets
    **kwargs)
  File "/home/akrherz/projects/gdata-python-client/src/gdata/client.py", line 640, in get_feed
    **kwargs)
  File "/home/akrherz/projects/gdata-python-client/src/gdata/client.py", line 278, in request
    version=get_xml_version(self.api_version))
  File "/home/akrherz/projects/gdata-python-client/src/atom/core.py", line 520, in parse
    tree = ElementTree.fromstring(xml_string)
  File "<string>", line 125, in XML
cElementTree.ParseError: no element found: line 1, column 0

I attempted to print out the response headers (with some redaction) and here they are:

 [('alternate-protocol', '443:quic,p=1'), 
('content-length', '0'), 
('x-xss-protection', '1; mode=block'), 
('x-robots-tag', 'noindex, nofollow, nosnippet'), 
('x-content-type-options', 'nosniff'), 
('set-cookie', 'NID=76=1....;Domain=.google.com;Path=/;Expires=Thu, 25-Aug-2016 05:17:40 GMT;HttpOnly, NID=76=V...w;Domain=.google.com;Path=/;Expires=Thu, 25-Aug-2016 05:17:40 GMT;HttpOnly'),
('expires', 'Wed, 24 Feb 2016 05:17:40 GMT'),
('server', 'GSE'),
('cache-control', 'private, max-age=0'),
('date', 'Wed, 24 Feb 2016 05:17:40 GMT'),
('p3p', 'CP="This is not a P3P policy! See https://support.google.com/accounts/answer/151657?hl=en for more info.", CP="This is not a P3P policy! See https://support.google.com/accounts/answer/151657?hl=en for more info."'), 
('alt-svc', 'quic=":443"; ma=2592000; v="30,29,28,27,26,25"'),
('content-type', 'application/binary'),
('x-frame-options', 'SAMEORIGIN')]

I can request other feeds just fine and I can request this feed in my web browser just fine as well. So I am a bit puzzled. Thanks