internetarchive/warc — pull request #16 by gthole (2013-09-25 15:40:45+00:00)
Title: Allow Digit Characters in Header Names

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:

```python
>>> 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 "", line 1, in
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