Details
-
Bug
-
Status: Closed
-
Major
-
Resolution: Won't Fix
-
1.2
-
None
-
Windows XP sp3
Description
send headers on a Show Function causes badarg error
Request
http://dev.server.com:5984/db/_design/app/_show/env_settings/app1-dev?callback=$r
Response
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"}
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,
[{[
]}],
[]},
{couch_httpd_external,
'parse_external_response/1-fun-0',1,
[
,
]},
{lists,map,2,
[
{lists,map,2,
[{file,"lists.erl"}
,
{line,1173}]},
{couch_httpd_external,
'parse_external_response/1-fun-1',2,
[
,
]},
{lists,foldl,3,
[
,
{line,1197}]},
{couch_httpd_external,
send_external_response,2,
[
,
]},
{couch_httpd_db,do_db_req,2,
[
,
]}]
h2. more info h3. The show function
function(doc, req){
var u
, urls = doc.uses
, out =
[ req.query.callback || "callback"
, "({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)
}
Tried also
out = out.join("");
return {
headers:
, body: out
}
and
got same result works only when the entire headers part is commented out. h3. Sample document:
{
"_id": "app1-dev",
"_rev": "10-269755da4f2c8ed771d9b301ec7d6163",
"env": "dev",
"app": "app1",
"uses":
}
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*
opm.dev.couch.com = /db/_design/app/_rewrite
*rewrite section*
, rewrites :
[
,
{from:"/*" , to:'*'}]
h3. expected output (beautified)
$r(
{ app : "app1"
, env : "dev"
, ver : 10
, uses:
}
)