doctrine / couchdb-client

CouchDB Client library
MIT License
122 stars 68 forks source link

Persistent File Pointer Preventing Subsequent Requests #61

Open keelerm84 opened 8 years ago

keelerm84 commented 8 years ago

I'm probably overlooking something obvious, so if that's the case, please forgive me.

I am basically following the examples provided in the README to query for a document and if it doesn't exist, I'm trying to create it.

The odd thing is, if I don't query for the document first, I am able to successfully create the document. But if I query first, I get a 404 response from the library.

The reason for this is that in the HTTP/StreamClient (and Socket too I believe), once you make a successful request, $this->httpFilePointer is saved and re-used. The problem is that querying for a document by ID appends that to the path, so subsequent calls (like postDocument) try to post to /database_name/id_i_queried_for instead of just /database_name

Am I overlooking something or misusing the library in some way? Thank you for any insight.

wegewerk-mdt commented 8 years ago

I experienced this Bug too. See CouchDBClient.php createDesignDocument (line 509).