On Mon, Nov 29, 2010 at 1:49 PM, Aurélien Bénel <[email protected]> wrote: > Hi there, > > I'm trying to send a redirect from a list with the following code: > > function (head, req) { > var row = getRow(); > if (row) { > var url = "/"; // Will be computed from row > return {"code": 302, "headers":{ "Location": url}}; > } else { > return({"code": 404, "body": "Not here"}); > } > } > > I got an error 500 in both case, but the process output seems fine to me: > > 1> [debug] [<0.1243.0>] OS Process #Port<0.1834> Output :: > ["end",[{"code":302,"headers":{"Location":"/"}}]] > 1> [error] [<0.936.0>] Badarg error in HTTP request > > 1> [debug] [<0.1243.0>] OS Process #Port<0.1834> Output :: > ["end",[{"code":404,"body":"Not here"}]] > 1> [error] [<0.1224.0>] Badarg error in HTTP request > > I got a look at > <http://wiki.apache.org/couchdb/Formatting_with_Show_and_List#Sending_a_Redirect>, > however it's not very clear to me if "start" has replaced "return" in 0.10 > and was replaced again by "return" in 0.11... Or maybe it's just a random > use... > Anyway, I tried with "start" and I was not luckier. > > Anyone who tried to send a redirect? > > > Regards, > > Aurélien > >
Unfortunately, the current list behaviour doesn't allow you to modify response headers after calling getRow(). This is probably what's causing the 500, but I don't have a test handy. Paul Davis
