Skip to content

Conversation

@gthole
Copy link

@gthole gthole commented Sep 25, 2013

Response header names can contain digit characters:
http://en.wikipedia.org/wiki/P3P

Reading a record with a "P3P" header will throw an IOError for a "Bad header", even though the header is legitimate.

Example when creating a record from the W3 Consortium homepage:

>>> import warc
>>> import requests

>>> response = requests.get('http://www.w3.org/)
>>> record = warc.WARCRecord(payload=response.content, headers=dict(response.headers))
>>> f = warc.open('example.warc.gz', 'w')
>>> f.write_record(record)
>>> f.close()

>>> f = warc.open('example.warc.gz')
>>> f.read_record()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/gthole/virtualenv/lib/python2.7/site-packages/warc/warc.py", line 276, in read_record
    return self.reader.read_record()
  File "/Users/gthole/virtualenv/lib/python2.7/site-packages/warc/warc.py", line 373, in read_record
    header = self.read_header(fileobj)
  File "/Users/gthole/virtualenv/lib/python2.7/site-packages/warc/warc.py", line 343, in read_header
    raise IOError("Bad header line: %r" % line)
IOError: Bad header line: 'P3P: policyref="http://www.w3.org/2001/05/P3P/p3p.xml"\r\n'

A modififcation to the unit tests is included to confirm.

Thanks!
Greg

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants