From dev-return-22926-apmail-couchdb-dev-archive=couchdb.apache.org@couchdb.apache.org Mon Aug 27 13:34:10 2012 Return-Path: X-Original-To: apmail-couchdb-dev-archive@www.apache.org Delivered-To: apmail-couchdb-dev-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id DAC9CD401 for ; Mon, 27 Aug 2012 13:34:10 +0000 (UTC) Received: (qmail 40188 invoked by uid 500); 27 Aug 2012 13:34:07 -0000 Delivered-To: apmail-couchdb-dev-archive@couchdb.apache.org Received: (qmail 40142 invoked by uid 500); 27 Aug 2012 13:34:07 -0000 Mailing-List: contact dev-help@couchdb.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@couchdb.apache.org Delivered-To: mailing list dev@couchdb.apache.org Received: (qmail 40087 invoked by uid 99); 27 Aug 2012 13:34:07 -0000 Received: from arcas.apache.org (HELO arcas.apache.org) (140.211.11.28) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 27 Aug 2012 13:34:07 +0000 Date: Tue, 28 Aug 2012 00:34:07 +1100 (NCT) From: "Osher E (JIRA)" To: dev@couchdb.apache.org Message-ID: <2098268062.1176.1346074447715.JavaMail.jiratomcat@arcas> In-Reply-To: <1925584261.1153.1346074088044.JavaMail.jiratomcat@arcas> Subject: [jira] [Updated] (COUCHDB-1528) send headers on a Show Function causes badarg error MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 [ https://issues.apache.org/jira/browse/COUCHDB-1528?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Osher E updated COUCHDB-1528: ----------------------------- Description: h2. send headers on a Show Function causes badarg error h3. Request {code} http://dev.server.com:5984/db/_design/app/_show/env_settings/app1-dev?callback=$r {code} h3. Response {code} 500 Internal Server Error Cache-Control:must-revalidate Content-Length:44 Content-Type:text/plain; charset=utf-8 Date:Mon, 27 Aug 2012 13:22:14 GMT Server:CouchDB/1.2.0 (Erlang OTP/R15B) {"error":"unknown_error","reason":"badarg"} {code} h3. Log entries: {code] [Mon, 27 Aug 2012 12:58:50 GMT] [error] [<0.6956.3>] Badarg error in HTTP request [Mon, 27 Aug 2012 12:58:50 GMT] [info] [<0.6956.3>] Stacktrace: [{erlang,binary_to_list, [{[{<<"Content-Type">>, <<"text/javascript">>}]}], []}, {couch_httpd_external, '-parse_external_response/1-fun-0-',1, [{file, "d:/relax/couchdb/src/couchdb/couch_httpd_external.erl"}, {line,157}]}, {lists,map,2, [{file,"lists.erl"},{line,1173}]}, {lists,map,2, [{file,"lists.erl"},{line,1173}]}, {couch_httpd_external, '-parse_external_response/1-fun-1-',2, [{file, "d:/relax/couchdb/src/couchdb/couch_httpd_external.erl"}, {line,156}]}, {lists,foldl,3, [{file,"lists.erl"},{line,1197}]}, {couch_httpd_external, send_external_response,2, [{file, "d:/relax/couchdb/src/couchdb/couch_httpd_external.erl"}, {line,129}]}, {couch_httpd_db,do_db_req,2, [{file, "d:/relax/couchdb/src/couchdb/couch_httpd_db.erl"}, {line,230}]}] {code} h2. more info h3. The show function {code} function(doc, req){ var u , urls = doc.uses , out = [ req.query.callback || "OPM.start" , "({app:\"", doc.app || "" , "\",env:\"" , doc.env , "\",ver:" , doc._rev.substr(0,doc._rev.indexOf("-")) , ",uses:{" ]; for (u in urls) out.push(u,":\"",urls[u],"\"",","); out[out.length-1] = "}});"; start({headers: {"Content-Type": "text/javascript"}}); out.forEach(send) } {code} Tried also {code} out = out.join(""); return { headers: { "Content-Type" : "text/javascript" , "Content-Length": out.length } , body: out } {code} and {code} { "Content-Type" : "text/javascript; charset=utf-8" , "Content-Length": out.length } {code} got same result works only when the entire headers part is commented out. h3. Sample document: {code} { "_id": "app1-dev", "_rev": "10-269755da4f2c8ed771d9b301ec7d6163", "env": "dev", "app": "app1", "uses": { "front": "http://dev.server.com/front/", "auth": "http://qas.server.com/auth/", "back": "http://dev.server.com/back/" } } {code} h3. configuration produced with WindowsXP, couch 1.2.0, OTP R15. I first noted the problem accessing through vhost + _rewrite. However, the problem is reproduced also without. *vhosts setting* {code} opm.dev.couch.com = /db/_design/app/_rewrite {code} *rewrite section* {code} , rewrites : [ {from:"/of/*", to:'_show/env_settings/*'} , {from:"/*" , to:'*'} ] {code} h3. expected output (beautified) {code} $r( { app : "app1" , env : "dev" , ver : 10 , uses: { front: "http://dev.server.com/front/" , auth: "http://qas.server.com/auth/" , back: "http://dev.server.com/back/" } } ) {code} was: h2. send headers on a Show Function causes badarg error h3. Request {code} http://dev.osg-worlds.com:5984/db/_design/app/_show/env_settings/app1-dev?callback=$r {code} h3. Response {code} 500 Internal Server Error Cache-Control:must-revalidate Content-Length:44 Content-Type:text/plain; charset=utf-8 Date:Mon, 27 Aug 2012 13:22:14 GMT Server:CouchDB/1.2.0 (Erlang OTP/R15B) {"error":"unknown_error","reason":"badarg"} {code} h3. Log entries: {code] [Mon, 27 Aug 2012 12:58:50 GMT] [error] [<0.6956.3>] Badarg error in HTTP request [Mon, 27 Aug 2012 12:58:50 GMT] [info] [<0.6956.3>] Stacktrace: [{erlang,binary_to_list, [{[{<<"Content-Type">>, <<"text/javascript">>}]}], []}, {couch_httpd_external, '-parse_external_response/1-fun-0-',1, [{file, "d:/relax/couchdb/src/couchdb/couch_httpd_external.erl"}, {line,157}]}, {lists,map,2, [{file,"lists.erl"},{line,1173}]}, {lists,map,2, [{file,"lists.erl"},{line,1173}]}, {couch_httpd_external, '-parse_external_response/1-fun-1-',2, [{file, "d:/relax/couchdb/src/couchdb/couch_httpd_external.erl"}, {line,156}]}, {lists,foldl,3, [{file,"lists.erl"},{line,1197}]}, {couch_httpd_external, send_external_response,2, [{file, "d:/relax/couchdb/src/couchdb/couch_httpd_external.erl"}, {line,129}]}, {couch_httpd_db,do_db_req,2, [{file, "d:/relax/couchdb/src/couchdb/couch_httpd_db.erl"}, {line,230}]}] {code} h2. more info h3. The show function {code} function(doc, req){ var u , urls = doc.uses , out = [ req.query.callback || "OPM.start" , "({app:\"", doc.app || "" , "\",env:\"" , doc.env , "\",ver:" , doc._rev.substr(0,doc._rev.indexOf("-")) , ",uses:{" ]; for (u in urls) out.push(u,":\"",urls[u],"\"",","); out[out.length-1] = "}});"; start({headers: {"Content-Type": "text/javascript"}}); out.forEach(send) } {code} Tried also {code} out = out.join(""); return { headers: { "Content-Type" : "text/javascript" , "Content-Length": out.length } , body: out } {code} and {code} { "Content-Type" : "text/javascript; charset=utf-8" , "Content-Length": out.length } {code} got same result works only when the entire headers part is commented out. h3. Sample document: {code} { "_id": "app1-dev", "_rev": "10-269755da4f2c8ed771d9b301ec7d6163", "env": "dev", "app": "app1", "uses": { "front": "http://dev.server.com/front/", "auth": "http://qas.server.com/auth/", "back": "http://dev.server.com/back/" } } {code} h3. configuration produced with WindowsXP, couch 1.2.0, OTP R15. I first noted the problem accessing through vhost + _rewrite. However, the problem is reproduced also without. *vhosts setting* {code} opm.dev.couch.com = /db/_design/app/_rewrite {code} *rewrite section* {code} , rewrites : [ {from:"/of/*", to:'_show/env_settings/*'} , {from:"/*" , to:'*'} ] {code} h3. expected output (beautified) {code} $r( { app : "app1" , env : "dev" , ver : 10 , uses: { front: "http://dev.server.com/front/" , auth: "http://qas.server.com/auth/" , back: "http://dev.server.com/back/" } } ) {code} > send headers on a Show Function causes badarg error > --------------------------------------------------- > > Key: COUCHDB-1528 > URL: https://issues.apache.org/jira/browse/COUCHDB-1528 > Project: CouchDB > Issue Type: Bug > Components: Database Core, HTTP Interface > Affects Versions: 1.2 > Environment: Windows XP sp3 > Reporter: Osher E > > h2. send headers on a Show Function causes badarg error > h3. Request > {code} > http://dev.server.com:5984/db/_design/app/_show/env_settings/app1-dev?callback=$r > {code} > h3. Response > {code} > 500 Internal Server Error > Cache-Control:must-revalidate > Content-Length:44 > Content-Type:text/plain; charset=utf-8 > Date:Mon, 27 Aug 2012 13:22:14 GMT > Server:CouchDB/1.2.0 (Erlang OTP/R15B) > {"error":"unknown_error","reason":"badarg"} > {code} > h3. Log entries: > {code] > [Mon, 27 Aug 2012 12:58:50 GMT] [error] [<0.6956.3>] Badarg error in HTTP request > [Mon, 27 Aug 2012 12:58:50 GMT] [info] [<0.6956.3>] Stacktrace: [{erlang,binary_to_list, > [{[{<<"Content-Type">>, > <<"text/javascript">>}]}], > []}, > {couch_httpd_external, > '-parse_external_response/1-fun-0-',1, > [{file, > "d:/relax/couchdb/src/couchdb/couch_httpd_external.erl"}, > {line,157}]}, > {lists,map,2, > [{file,"lists.erl"},{line,1173}]}, > {lists,map,2, > [{file,"lists.erl"},{line,1173}]}, > {couch_httpd_external, > '-parse_external_response/1-fun-1-',2, > [{file, > "d:/relax/couchdb/src/couchdb/couch_httpd_external.erl"}, > {line,156}]}, > {lists,foldl,3, > [{file,"lists.erl"},{line,1197}]}, > {couch_httpd_external, > send_external_response,2, > [{file, > "d:/relax/couchdb/src/couchdb/couch_httpd_external.erl"}, > {line,129}]}, > {couch_httpd_db,do_db_req,2, > [{file, > "d:/relax/couchdb/src/couchdb/couch_httpd_db.erl"}, > {line,230}]}] > {code} > h2. more info > h3. The show function > {code} > function(doc, req){ > var u > , urls = doc.uses > , out = > [ req.query.callback || "OPM.start" > , "({app:\"", doc.app || "" > , "\",env:\"" , doc.env > , "\",ver:" , doc._rev.substr(0,doc._rev.indexOf("-")) > , ",uses:{" > ]; > for (u in urls) > out.push(u,":\"",urls[u],"\"",","); > out[out.length-1] = "}});"; > start({headers: {"Content-Type": "text/javascript"}}); > out.forEach(send) > } > {code} > Tried also > {code} > out = out.join(""); > return { > headers: > { "Content-Type" : "text/javascript" > , "Content-Length": out.length > } > , body: out > } > {code} > and > {code} > { "Content-Type" : "text/javascript; charset=utf-8" > , "Content-Length": out.length > } > {code} > got same result > works only when the entire headers part is commented out. > h3. Sample document: > {code} > { > "_id": "app1-dev", > "_rev": "10-269755da4f2c8ed771d9b301ec7d6163", > "env": "dev", > "app": "app1", > "uses": { > "front": "http://dev.server.com/front/", > "auth": "http://qas.server.com/auth/", > "back": "http://dev.server.com/back/" > } > } > {code} > h3. configuration > produced with WindowsXP, couch 1.2.0, OTP R15. > I first noted the problem accessing through vhost + _rewrite. However, the problem is reproduced also without. > *vhosts setting* > {code} > opm.dev.couch.com = /db/_design/app/_rewrite > {code} > *rewrite section* > {code} > , rewrites : > [ {from:"/of/*", to:'_show/env_settings/*'} > , {from:"/*" , to:'*'} > ] > {code} > h3. expected output (beautified) > {code} > $r( > { app : "app1" > , env : "dev" > , ver : 10 > , uses: > { front: "http://dev.server.com/front/" > , auth: "http://qas.server.com/auth/" > , back: "http://dev.server.com/back/" > } > } > ) > {code} -- This message is automatically generated by JIRA. If you think it was sent incorrectly, please contact your JIRA administrators For more information on JIRA, see: http://www.atlassian.com/software/jira