Created
June 25, 2011 21:06
-
-
Save shimaore/1046898 to your computer and use it in GitHub Desktop.
Fix for node.couchapp.js issue #15
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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