Skip to content

Instantly share code, notes, and snippets.

@shimaore
Created June 25, 2011 21:06
Show Gist options
  • Save shimaore/1046898 to your computer and use it in GitHub Desktop.
Save shimaore/1046898 to your computer and use it in GitHub Desktop.
Fix for node.couchapp.js issue #15
diff --git a/main.js b/main.js
index fa8466f..221ed8b 100644
--- a/main.js
+++ b/main.js
@@ -8,8 +8,6 @@ var path = require('path')
, spawn = require('child_process').spawn
;
-var h = {'content-type':'application/json', 'accept-type':'application/json'}
-
function loadAttachments (doc, root, prefix) {
doc.__attachments = doc.__attachments || []
try {
@@ -63,12 +61,14 @@ function createApp (doc, url, cb) {
delete doc.__attachments;
var body = JSON.stringify(doc)
console.log('PUT '+url.replace(/^(https?:\/\/[^@:]+):[^@]+@/, '$1:******@'))
+ var h = {'content-type':'application/json', 'accept-type':'application/json'}
request({uri:url, method:'PUT', body:body, headers:h}, function (err, resp, body) {
if (err) throw err;
if (resp.statusCode !== 201) throw new Error("Could not push document\n"+body)
app.doc._rev = JSON.parse(body).rev
console.log('Finished push. '+app.doc._rev)
playSound();
+ var h = {'content-type':'application/json', 'accept-type':'application/json'}
request({uri:url, headers:h}, function (err, resp, body) {
body = JSON.parse(body);
app.doc._attachments = body._attachments;
@@ -210,6 +210,7 @@ function createApp (doc, url, cb) {
if (url.slice(url.length - _id.length) !== _id) url += '/' + _id;
+ var h = {'content-type':'application/json', 'accept-type':'application/json'}
request({uri:url, headers:h}, function (err, resp, body) {
if (err) throw err;
if (resp.statusCode == 404) app.current = {};
~
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment