lanto03 / couchdb-python

Automatically exported from code.google.com/p/couchdb-python
Other
0 stars 0 forks source link

HEAD request gets cached #120

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?

1. Check if doc id is already in db;
2. Subsequently fetch this document.

# just creating example document.

>>> from couchdb import Server
>>> db1 = Server().create('mycooldb')
>>> db1['doc1'] = {'a': 1}
>>> db1['doc1']
<Document 'doc1'@'1-23202479633c2b380f79507a776743d5' {'a': 1}>

# and now reproducing the problem:

>>> db2 = Server()['mycooldb']
>>> len(db2)
1

>>> 'doc1' in db2     # HEAD request gets cached (without payload). Response 
200.
True

>>> doc1 = db2['doc1']     # trying to get content out of the previously cached 
HEAD request
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "build/bdist.macosx-10.5-i386/egg/couchdb/client.py", line 313, in __getitem__
  File "build/bdist.macosx-10.5-i386/egg/couchdb/http.py", line 366, in get_json
AttributeError: 'NoneType' object has no attribute 'read'

>>> db2['doc1']     # once again
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "build/bdist.macosx-10.5-i386/egg/couchdb/client.py", line 313, in __getitem__
  File "build/bdist.macosx-10.5-i386/egg/couchdb/http.py", line 366, in get_json
AttributeError: 'NoneType' object has no attribute 'read'

What version of the product are you using? On what operating system?

couchdb 0.10+, couchdb-python 0.7-dev, Mac OS X, Ubuntu 9.10

Please provide any additional information below.

See attached patch to get the point.

Original issue reported on code.google.com by alifa...@gmail.com on 31 Mar 2010 at 12:19

Attachments:

GoogleCodeExporter commented 8 years ago
Ah, that would be bad. I wondered briefly whether it wouldn't be better to 
cache HEAD
and GET separately, but I think it's probably a good solution not to cache HEAD
requests (little content, and you want to use them to check for staleness, 
anyway).

Can you state your name + email address, so we can give proper credit on the 
patch?

Original comment by djc.ochtman on 31 Mar 2010 at 12:26

GoogleCodeExporter commented 8 years ago
Fixed in re679e9e75631.

Original comment by djc.ochtman on 31 Mar 2010 at 1:18