You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@couchdb.apache.org by Zachary Zolton <za...@gmail.com> on 2009/09/25 00:34:34 UTC

Redirect from _list function?

Hello,

Should I be able to do a redirect from a _list function?

I ask because I've tried defining the following _list function:

function(head, req) {
  return {
    'code': 301,
    'headers': { 'Location': 'http://www.google.com/' }
  };
}

And, here's what happens when I try to hit it:

$ curl -i 'http://localhost:5984/db/_design/ddoc/_list/test-redirect/some-view?key=%22foo%22'
HTTP/1.1 200 OK
Vary: Accept
Transfer-Encoding: chunked
Server: CouchDB/0.11.0a9fd42dc1-git (Erlang OTP/R12B)
Etag: "46014W5JDRLKZF5SECP2D44YH"
Date: Thu, 24 Sep 2009 22:23:14 GMT
Content-Type: application/json

curl: (56) Received problem 2 in the chunky parser

Obviously, this does not look like a redirect.  :^(  Do I seem to be
doing anything wrong here?


Thanks!

Zach

Re: Redirect from _list function?

Posted by Paul Davis <pa...@gmail.com>.
On Fri, Sep 25, 2009 at 12:23 AM, Zachary Zolton
<za...@gmail.com> wrote:
>> Theoretically returning a 304 should work fine I think.
>
> I thought 304 was for etag/caching validation...?
>

My bad, I meant 301 or 302.

>> I'd suggest taking a glance at render.js to see
>> if maybe you're getting caught by a corner case.
>
> Hm... I'm gonna have to learn more about list functions work to
> understand what's going on in there!
>
>> Paul
>
> Thanks for the input, Paul!
>
>> On Thu, Sep 24, 2009 at 11:50 PM, Zachary Zolton
>> <za...@gmail.com> wrote:
>>> So, can anyone give a reason why this _list function shouldn't work?
>>>
>>> On Thu, Sep 24, 2009 at 5:34 PM, Zachary Zolton
>>> <za...@gmail.com> wrote:
>>>> Hello,
>>>>
>>>> Should I be able to do a redirect from a _list function?
>>>>
>>>> I ask because I've tried defining the following _list function:
>>>>
>>>> function(head, req) {
>>>>  return {
>>>>    'code': 301,
>>>>    'headers': { 'Location': 'http://www.google.com/' }
>>>>  };
>>>> }
>>>>
>>>> And, here's what happens when I try to hit it:
>>>>
>>>> $ curl -i 'http://localhost:5984/db/_design/ddoc/_list/test-redirect/some-view?key=%22foo%22'
>>>> HTTP/1.1 200 OK
>>>> Vary: Accept
>>>> Transfer-Encoding: chunked
>>>> Server: CouchDB/0.11.0a9fd42dc1-git (Erlang OTP/R12B)
>>>> Etag: "46014W5JDRLKZF5SECP2D44YH"
>>>> Date: Thu, 24 Sep 2009 22:23:14 GMT
>>>> Content-Type: application/json
>>>>
>>>> curl: (56) Received problem 2 in the chunky parser
>>>>
>>>> Obviously, this does not look like a redirect.  :^(  Do I seem to be
>>>> doing anything wrong here?
>>>>
>>>>
>>>> Thanks!
>>>>
>>>> Zach
>>>>
>>>
>>
>

Re: Redirect from _list function?

Posted by Zachary Zolton <za...@gmail.com>.
> Theoretically returning a 304 should work fine I think.

I thought 304 was for etag/caching validation...?

> I'd suggest taking a glance at render.js to see
> if maybe you're getting caught by a corner case.

Hm... I'm gonna have to learn more about list functions work to
understand what's going on in there!

> Paul

Thanks for the input, Paul!

> On Thu, Sep 24, 2009 at 11:50 PM, Zachary Zolton
> <za...@gmail.com> wrote:
>> So, can anyone give a reason why this _list function shouldn't work?
>>
>> On Thu, Sep 24, 2009 at 5:34 PM, Zachary Zolton
>> <za...@gmail.com> wrote:
>>> Hello,
>>>
>>> Should I be able to do a redirect from a _list function?
>>>
>>> I ask because I've tried defining the following _list function:
>>>
>>> function(head, req) {
>>>  return {
>>>    'code': 301,
>>>    'headers': { 'Location': 'http://www.google.com/' }
>>>  };
>>> }
>>>
>>> And, here's what happens when I try to hit it:
>>>
>>> $ curl -i 'http://localhost:5984/db/_design/ddoc/_list/test-redirect/some-view?key=%22foo%22'
>>> HTTP/1.1 200 OK
>>> Vary: Accept
>>> Transfer-Encoding: chunked
>>> Server: CouchDB/0.11.0a9fd42dc1-git (Erlang OTP/R12B)
>>> Etag: "46014W5JDRLKZF5SECP2D44YH"
>>> Date: Thu, 24 Sep 2009 22:23:14 GMT
>>> Content-Type: application/json
>>>
>>> curl: (56) Received problem 2 in the chunky parser
>>>
>>> Obviously, this does not look like a redirect.  :^(  Do I seem to be
>>> doing anything wrong here?
>>>
>>>
>>> Thanks!
>>>
>>> Zach
>>>
>>
>

Re: Redirect from _list function?

Posted by Paul Davis <pa...@gmail.com>.
Bit tired here but two thoughts. Theoretically returning a 304 should
work fine I think. The question is what mutation happens when
processing the _list. I'd suggest taking a glance at render.js to see
if maybe you're getting caught by a corner case.

Paul

On Thu, Sep 24, 2009 at 11:50 PM, Zachary Zolton
<za...@gmail.com> wrote:
> So, can anyone give a reason why this _list function shouldn't work?
>
> On Thu, Sep 24, 2009 at 5:34 PM, Zachary Zolton
> <za...@gmail.com> wrote:
>> Hello,
>>
>> Should I be able to do a redirect from a _list function?
>>
>> I ask because I've tried defining the following _list function:
>>
>> function(head, req) {
>>  return {
>>    'code': 301,
>>    'headers': { 'Location': 'http://www.google.com/' }
>>  };
>> }
>>
>> And, here's what happens when I try to hit it:
>>
>> $ curl -i 'http://localhost:5984/db/_design/ddoc/_list/test-redirect/some-view?key=%22foo%22'
>> HTTP/1.1 200 OK
>> Vary: Accept
>> Transfer-Encoding: chunked
>> Server: CouchDB/0.11.0a9fd42dc1-git (Erlang OTP/R12B)
>> Etag: "46014W5JDRLKZF5SECP2D44YH"
>> Date: Thu, 24 Sep 2009 22:23:14 GMT
>> Content-Type: application/json
>>
>> curl: (56) Received problem 2 in the chunky parser
>>
>> Obviously, this does not look like a redirect.  :^(  Do I seem to be
>> doing anything wrong here?
>>
>>
>> Thanks!
>>
>> Zach
>>
>

Re: Redirect from _list function?

Posted by Zachary Zolton <za...@gmail.com>.
(My sincere apologies—I didn't mean to sound impatient! Rather, I was
just trying to clarify my question, which I can now sum up as: am I
doing something fundamentally wrong or is CouchDB acting funny?)

Now, onto Jan's suggestion, I've tried setting Transfer-Encoding to
both null and 'foo', but the response always seems to have chunked for
the header value. So my initial guess is that I'm unable to override
it for some reason...

I couldn't determine any other values from the spec worth trying:
http://tools.ietf.org/html/rfc2616#section-14.41

Assuming that this is a bug, I've created the following on JIRA:

https://issues.apache.org/jira/browse/COUCHDB-513

On Fri, Sep 25, 2009 at 2:56 AM, Jan Lehnardt <ja...@apache.org> wrote:
> Hi Zach,
>
> On 25 Sep 2009, at 05:50, Zachary Zolton wrote:
>
>> So, can anyone give a reason why this _list function shouldn't work?
>
> (you wrote the initial message not even five hours earlier, be patient ;)
>
> --
>
> The chunky-parser error message occurs when curl expects a chunked
> HTTP response body and then doesn't get one. Your reply sends the
> `Transfer-Encoding: chunked` header, so curl expects to see a body
> chunked according to RFC2616 and it doesn't get one.
>
> Obviously, a redirect shouldn't have a response body or even the
> `Transfer-Encoding` header to begin with. You could try overriding
> the header, but maybe CouchDB inserts it unconditional in which
> case we should fix that, if you find out you can't override the
> `Transfer-Encoding` header, can you file a bug report?
>
> Cheers
> Jan
> --
>
>
>
>
>
>
>> On Thu, Sep 24, 2009 at 5:34 PM, Zachary Zolton
>> <za...@gmail.com> wrote:
>>>
>>> Hello,
>>>
>>> Should I be able to do a redirect from a _list function?
>>>
>>> I ask because I've tried defining the following _list function:
>>>
>>> function(head, req) {
>>>  return {
>>>   'code': 301,
>>>   'headers': { 'Location': 'http://www.google.com/' }
>>>  };
>>> }
>>>
>>> And, here's what happens when I try to hit it:
>>>
>>> $ curl -i
>>> 'http://localhost:5984/db/_design/ddoc/_list/test-redirect/some-view?key=%22foo%22'
>>> HTTP/1.1 200 OK
>>> Vary: Accept
>>> Transfer-Encoding: chunked
>>> Server: CouchDB/0.11.0a9fd42dc1-git (Erlang OTP/R12B)
>>> Etag: "46014W5JDRLKZF5SECP2D44YH"
>>> Date: Thu, 24 Sep 2009 22:23:14 GMT
>>> Content-Type: application/json
>>>
>>> curl: (56) Received problem 2 in the chunky parser
>>>
>>> Obviously, this does not look like a redirect.  :^(  Do I seem to be
>>> doing anything wrong here?
>>>
>>>
>>> Thanks!
>>>
>>> Zach
>>>
>>
>
>

Re: Redirect from _list function?

Posted by Jan Lehnardt <ja...@apache.org>.
Hi Zach,

On 25 Sep 2009, at 05:50, Zachary Zolton wrote:

> So, can anyone give a reason why this _list function shouldn't work?

(you wrote the initial message not even five hours earlier, be  
patient ;)

--

The chunky-parser error message occurs when curl expects a chunked
HTTP response body and then doesn't get one. Your reply sends the
`Transfer-Encoding: chunked` header, so curl expects to see a body
chunked according to RFC2616 and it doesn't get one.

Obviously, a redirect shouldn't have a response body or even the
`Transfer-Encoding` header to begin with. You could try overriding
the header, but maybe CouchDB inserts it unconditional in which
case we should fix that, if you find out you can't override the
`Transfer-Encoding` header, can you file a bug report?

Cheers
Jan
--






> On Thu, Sep 24, 2009 at 5:34 PM, Zachary Zolton
> <za...@gmail.com> wrote:
>> Hello,
>>
>> Should I be able to do a redirect from a _list function?
>>
>> I ask because I've tried defining the following _list function:
>>
>> function(head, req) {
>>  return {
>>    'code': 301,
>>    'headers': { 'Location': 'http://www.google.com/' }
>>  };
>> }
>>
>> And, here's what happens when I try to hit it:
>>
>> $ curl -i 'http://localhost:5984/db/_design/ddoc/_list/test- 
>> redirect/some-view?key=%22foo%22'
>> HTTP/1.1 200 OK
>> Vary: Accept
>> Transfer-Encoding: chunked
>> Server: CouchDB/0.11.0a9fd42dc1-git (Erlang OTP/R12B)
>> Etag: "46014W5JDRLKZF5SECP2D44YH"
>> Date: Thu, 24 Sep 2009 22:23:14 GMT
>> Content-Type: application/json
>>
>> curl: (56) Received problem 2 in the chunky parser
>>
>> Obviously, this does not look like a redirect.  :^(  Do I seem to be
>> doing anything wrong here?
>>
>>
>> Thanks!
>>
>> Zach
>>
>


Re: Redirect from _list function?

Posted by Zachary Zolton <za...@gmail.com>.
So, can anyone give a reason why this _list function shouldn't work?

On Thu, Sep 24, 2009 at 5:34 PM, Zachary Zolton
<za...@gmail.com> wrote:
> Hello,
>
> Should I be able to do a redirect from a _list function?
>
> I ask because I've tried defining the following _list function:
>
> function(head, req) {
>  return {
>    'code': 301,
>    'headers': { 'Location': 'http://www.google.com/' }
>  };
> }
>
> And, here's what happens when I try to hit it:
>
> $ curl -i 'http://localhost:5984/db/_design/ddoc/_list/test-redirect/some-view?key=%22foo%22'
> HTTP/1.1 200 OK
> Vary: Accept
> Transfer-Encoding: chunked
> Server: CouchDB/0.11.0a9fd42dc1-git (Erlang OTP/R12B)
> Etag: "46014W5JDRLKZF5SECP2D44YH"
> Date: Thu, 24 Sep 2009 22:23:14 GMT
> Content-Type: application/json
>
> curl: (56) Received problem 2 in the chunky parser
>
> Obviously, this does not look like a redirect.  :^(  Do I seem to be
> doing anything wrong here?
>
>
> Thanks!
>
> Zach
>

Re: Redirect from _list function?

Posted by Zachary Zolton <za...@gmail.com>.
I've posted a patch from my experiments to the ticket. I'm thinking
this'll require some Erlang-fu...?

Try not to laugh! ;^)

On Mon, Sep 28, 2009 at 1:59 PM, Chris Anderson <jc...@apache.org> wrote:
> On Mon, Sep 28, 2009 at 11:34 AM, Zachary Zolton
> <za...@gmail.com> wrote:
>> Guys,
>>
>> I've started a ticket for this:
>> https://issues.apache.org/jira/browse/COUCHDB-514
>>
>> I don't know what level of effort would be required to fix this, or if
>> this is even compatible with the current view server protocol. I'm
>> motivated to solve this, but I'd need some coaching from someone with
>> more knowledge of CouchDB view server internals.
>>
>
> I'm into getting this to happen too. I barely have time, but I can advise.
>
> It wouldn't hurt to post a patch of what you tried, even if it didn;t
> work, as it will let other know which code you are digging into.
>
> Chris
>
>>
>> Cheers,
>>
>> Zach
>>
>>
>> On Sun, Sep 27, 2009 at 11:35 PM, Chris Anderson <jc...@apache.org> wrote:
>>> On Sun, Sep 27, 2009 at 8:26 PM, Zachary Zolton
>>> <za...@gmail.com> wrote:
>>>> Hmm... I can't do anything that doesn't result in a view server timeout. (^_-)
>>>>
>>>> Shall I open an issue? I can discuss what I tried, as well...
>>>>
>>>
>>> It never hurts to start a ticket. Especially if you have patches.
>>>
>>> Thinking about it more, it seems like the Erlang side is gonna be
>>> looking for that start signal before it will send a row. We'll need to
>>> design a dont-start signal, so that it can get a row without sending
>>> headers.
>>>
>>>> On Sun, Sep 27, 2009 at 12:06 PM, Paul Davis
>>>> <pa...@gmail.com> wrote:
>>>>> On Sun, Sep 27, 2009 at 1:04 PM, Zachary Zolton
>>>>> <za...@gmail.com> wrote:
>>>>>> Hey guys, newb question for you: the make script concatenates all the
>>>>>> /share/server/*.js scripts into main.js, right?
>>>>>>
>>>>>
>>>>> yepper.
>>>>>
>>>>>> I'm still trying to figure this stuff out...
>>>>>>
>>>>>> On Sat, Sep 26, 2009 at 11:35 PM, Zachary Zolton
>>>>>> <za...@gmail.com> wrote:
>>>>>>> I'll start studying the query_server_spec.rb script; I think I might
>>>>>>> be able to handle this in JavaScript...
>>>>>>>
>>>>>>> On Sat, Sep 26, 2009 at 11:22 PM, Chris Anderson <jc...@apache.org> wrote:
>>>>>>>> On Sat, Sep 26, 2009 at 8:57 PM, Paul Davis <pa...@gmail.com> wrote:
>>>>>>>>> its been awhile since i studied the Erlang side of this, but IIRC,
>>>>>>>>> once getRow() returns, the response has started which means that you
>>>>>>>>> can't send a redirect. To get it working proper then would require a
>>>>>>>>> bit of a patch to wait on starting the response until the first output
>>>>>>>>> from the _list function.
>>>>>>>>>
>>>>>>>>
>>>>>>>> Yes I think it would be a simple patch, once you understand the
>>>>>>>> entrails of the _list system. You should read the query_server_spec.rb
>>>>>>>> to see what gets sent by the query server on first getRow() call.
>>>>>>>>
>>>>>>>> It may be that this patch can be accomplished just in the javascript side.
>>>>>>>>
>>>>>>>> Chris
>>>>>>>>
>>>>>>>>> Paul Davis
>>>>>>>>>
>>>>>>>>> On Sat, Sep 26, 2009 at 11:39 PM, Zachary Zolton
>>>>>>>>> <za...@gmail.com> wrote:
>>>>>>>>>> Hey guys,
>>>>>>>>>>
>>>>>>>>>> I need to find a way to do a redirect from a _list function after
>>>>>>>>>> calling the getRow() function. After looking at render.js for a while
>>>>>>>>>> I can't see how to solve this without at least adding to the API.
>>>>>>>>>>
>>>>>>>>>> Basically, I think that calling getRow() shouldn't cause the view
>>>>>>>>>> server to send the headers (or awaiting chunks) unless we've already
>>>>>>>>>> called send() or something like that. That way, we can return from the
>>>>>>>>>> _list function after iterating to the first row that should redirect.
>>>>>>>>>> (I'm not sure if this is a breaking change from the current semantics,
>>>>>>>>>> however...)
>>>>>>>>>>
>>>>>>>>>> Would greatly appreciate a little guidance on how to attack this!
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>> Cheers,
>>>>>>>>>>
>>>>>>>>>> Zach
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>> ---------- Forwarded message ----------
>>>>>>>>>> From: Chris Anderson <jc...@apache.org>
>>>>>>>>>> Date: Fri, Sep 25, 2009 at 2:15 PM
>>>>>>>>>> Subject: Re: Redirect from _list function?
>>>>>>>>>> To: Zachary Zolton <za...@gmail.com>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>> On Fri, Sep 25, 2009 at 11:01 AM, Zachary Zolton
>>>>>>>>>> <za...@gmail.com> wrote:
>>>>>>>>>>> So, now I find that using the send() function to perform the redirect
>>>>>>>>>>> doesn't work after the first time I call getRow(). Upon checking out
>>>>>>>>>>> render.js, I see that the getRow() function calls sendStart()—which I
>>>>>>>>>>> haven't quite yet figured out—but I can tell there's something fishy
>>>>>>>>>>> going on there...
>>>>>>>>>>>
>>>>>>>>>>> Would I be correct to assume that the headers are already set after
>>>>>>>>>>> calling getRow()?
>>>>>>>>>>
>>>>>>>>>> Yes... The headers are sent when the first getRow is called. Fixing
>>>>>>>>>> this is definitely something I'd support.
>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>> On Fri, Sep 25, 2009 at 12:11 PM, Chris Anderson <jc...@apache.org> wrote:
>>>>>>>>>>>> On Fri, Sep 25, 2009 at 8:40 AM, Zachary Zolton
>>>>>>>>>>>> <za...@gmail.com> wrote:
>>>>>>>>>>>>> Okay, I've update this section to differentiate between the 0.9 and
>>>>>>>>>>>>> 0.10 _list API:
>>>>>>>>>>>>>
>>>>>>>>>>>>> http://wiki.apache.org/couchdb/Formatting_with_Show_and_List#Sending_a_Redirect
>>>>>>>>>>>>>
>>>>>>>>>>>>> Now, I'm feeling that the Other Fun Things section could use a bit of
>>>>>>>>>>>>> love. Hmm...  :^)
>>>>>>>>>>>>
>>>>>>>>>>>> Thanks for keeping the wiki in mind!
>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>> On Fri, Sep 25, 2009 at 10:19 AM, Zachary Zolton
>>>>>>>>>>>>> <za...@gmail.com> wrote:
>>>>>>>>>>>>>> Sweet! I'll try to amend the wiki page for the _list API...
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> On Fri, Sep 25, 2009 at 10:17 AM, Jason Davies <ja...@jasondavies.com> wrote:
>>>>>>>>>>>>>>> On 25 Sep 2009, at 16:16, Zachary Zolton wrote:
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>> Thanks for all the help, guys! Shall I delete that JIRA issue?
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>> I already did :-)
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>> --
>>>>>>>>>>>>>>> Jason Davies
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>> www.jasondavies.com
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>> --
>>>>>>>>>>>> Chris Anderson
>>>>>>>>>>>> http://jchrisa.net
>>>>>>>>>>>> http://couch.io
>>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>> --
>>>>>>>>>> Chris Anderson
>>>>>>>>>> http://jchrisa.net
>>>>>>>>>> http://couch.io
>>>>>>>>>>
>>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>> --
>>>>>>>> Chris Anderson
>>>>>>>> http://jchrisa.net
>>>>>>>> http://couch.io
>>>>>>>>
>>>>>>>
>>>>>>
>>>>>
>>>>
>>>
>>>
>>>
>>> --
>>> Chris Anderson
>>> http://jchrisa.net
>>> http://couch.io
>>>
>>
>
>
>
> --
> Chris Anderson
> http://jchrisa.net
> http://couch.io
>

Re: Redirect from _list function?

Posted by Chris Anderson <jc...@apache.org>.
On Mon, Sep 28, 2009 at 11:34 AM, Zachary Zolton
<za...@gmail.com> wrote:
> Guys,
>
> I've started a ticket for this:
> https://issues.apache.org/jira/browse/COUCHDB-514
>
> I don't know what level of effort would be required to fix this, or if
> this is even compatible with the current view server protocol. I'm
> motivated to solve this, but I'd need some coaching from someone with
> more knowledge of CouchDB view server internals.
>

I'm into getting this to happen too. I barely have time, but I can advise.

It wouldn't hurt to post a patch of what you tried, even if it didn;t
work, as it will let other know which code you are digging into.

Chris

>
> Cheers,
>
> Zach
>
>
> On Sun, Sep 27, 2009 at 11:35 PM, Chris Anderson <jc...@apache.org> wrote:
>> On Sun, Sep 27, 2009 at 8:26 PM, Zachary Zolton
>> <za...@gmail.com> wrote:
>>> Hmm... I can't do anything that doesn't result in a view server timeout. (^_-)
>>>
>>> Shall I open an issue? I can discuss what I tried, as well...
>>>
>>
>> It never hurts to start a ticket. Especially if you have patches.
>>
>> Thinking about it more, it seems like the Erlang side is gonna be
>> looking for that start signal before it will send a row. We'll need to
>> design a dont-start signal, so that it can get a row without sending
>> headers.
>>
>>> On Sun, Sep 27, 2009 at 12:06 PM, Paul Davis
>>> <pa...@gmail.com> wrote:
>>>> On Sun, Sep 27, 2009 at 1:04 PM, Zachary Zolton
>>>> <za...@gmail.com> wrote:
>>>>> Hey guys, newb question for you: the make script concatenates all the
>>>>> /share/server/*.js scripts into main.js, right?
>>>>>
>>>>
>>>> yepper.
>>>>
>>>>> I'm still trying to figure this stuff out...
>>>>>
>>>>> On Sat, Sep 26, 2009 at 11:35 PM, Zachary Zolton
>>>>> <za...@gmail.com> wrote:
>>>>>> I'll start studying the query_server_spec.rb script; I think I might
>>>>>> be able to handle this in JavaScript...
>>>>>>
>>>>>> On Sat, Sep 26, 2009 at 11:22 PM, Chris Anderson <jc...@apache.org> wrote:
>>>>>>> On Sat, Sep 26, 2009 at 8:57 PM, Paul Davis <pa...@gmail.com> wrote:
>>>>>>>> its been awhile since i studied the Erlang side of this, but IIRC,
>>>>>>>> once getRow() returns, the response has started which means that you
>>>>>>>> can't send a redirect. To get it working proper then would require a
>>>>>>>> bit of a patch to wait on starting the response until the first output
>>>>>>>> from the _list function.
>>>>>>>>
>>>>>>>
>>>>>>> Yes I think it would be a simple patch, once you understand the
>>>>>>> entrails of the _list system. You should read the query_server_spec.rb
>>>>>>> to see what gets sent by the query server on first getRow() call.
>>>>>>>
>>>>>>> It may be that this patch can be accomplished just in the javascript side.
>>>>>>>
>>>>>>> Chris
>>>>>>>
>>>>>>>> Paul Davis
>>>>>>>>
>>>>>>>> On Sat, Sep 26, 2009 at 11:39 PM, Zachary Zolton
>>>>>>>> <za...@gmail.com> wrote:
>>>>>>>>> Hey guys,
>>>>>>>>>
>>>>>>>>> I need to find a way to do a redirect from a _list function after
>>>>>>>>> calling the getRow() function. After looking at render.js for a while
>>>>>>>>> I can't see how to solve this without at least adding to the API.
>>>>>>>>>
>>>>>>>>> Basically, I think that calling getRow() shouldn't cause the view
>>>>>>>>> server to send the headers (or awaiting chunks) unless we've already
>>>>>>>>> called send() or something like that. That way, we can return from the
>>>>>>>>> _list function after iterating to the first row that should redirect.
>>>>>>>>> (I'm not sure if this is a breaking change from the current semantics,
>>>>>>>>> however...)
>>>>>>>>>
>>>>>>>>> Would greatly appreciate a little guidance on how to attack this!
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> Cheers,
>>>>>>>>>
>>>>>>>>> Zach
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> ---------- Forwarded message ----------
>>>>>>>>> From: Chris Anderson <jc...@apache.org>
>>>>>>>>> Date: Fri, Sep 25, 2009 at 2:15 PM
>>>>>>>>> Subject: Re: Redirect from _list function?
>>>>>>>>> To: Zachary Zolton <za...@gmail.com>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> On Fri, Sep 25, 2009 at 11:01 AM, Zachary Zolton
>>>>>>>>> <za...@gmail.com> wrote:
>>>>>>>>>> So, now I find that using the send() function to perform the redirect
>>>>>>>>>> doesn't work after the first time I call getRow(). Upon checking out
>>>>>>>>>> render.js, I see that the getRow() function calls sendStart()—which I
>>>>>>>>>> haven't quite yet figured out—but I can tell there's something fishy
>>>>>>>>>> going on there...
>>>>>>>>>>
>>>>>>>>>> Would I be correct to assume that the headers are already set after
>>>>>>>>>> calling getRow()?
>>>>>>>>>
>>>>>>>>> Yes... The headers are sent when the first getRow is called. Fixing
>>>>>>>>> this is definitely something I'd support.
>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>> On Fri, Sep 25, 2009 at 12:11 PM, Chris Anderson <jc...@apache.org> wrote:
>>>>>>>>>>> On Fri, Sep 25, 2009 at 8:40 AM, Zachary Zolton
>>>>>>>>>>> <za...@gmail.com> wrote:
>>>>>>>>>>>> Okay, I've update this section to differentiate between the 0.9 and
>>>>>>>>>>>> 0.10 _list API:
>>>>>>>>>>>>
>>>>>>>>>>>> http://wiki.apache.org/couchdb/Formatting_with_Show_and_List#Sending_a_Redirect
>>>>>>>>>>>>
>>>>>>>>>>>> Now, I'm feeling that the Other Fun Things section could use a bit of
>>>>>>>>>>>> love. Hmm...  :^)
>>>>>>>>>>>
>>>>>>>>>>> Thanks for keeping the wiki in mind!
>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>> On Fri, Sep 25, 2009 at 10:19 AM, Zachary Zolton
>>>>>>>>>>>> <za...@gmail.com> wrote:
>>>>>>>>>>>>> Sweet! I'll try to amend the wiki page for the _list API...
>>>>>>>>>>>>>
>>>>>>>>>>>>> On Fri, Sep 25, 2009 at 10:17 AM, Jason Davies <ja...@jasondavies.com> wrote:
>>>>>>>>>>>>>> On 25 Sep 2009, at 16:16, Zachary Zolton wrote:
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>> Thanks for all the help, guys! Shall I delete that JIRA issue?
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> I already did :-)
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> --
>>>>>>>>>>>>>> Jason Davies
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> www.jasondavies.com
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>> --
>>>>>>>>>>> Chris Anderson
>>>>>>>>>>> http://jchrisa.net
>>>>>>>>>>> http://couch.io
>>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> --
>>>>>>>>> Chris Anderson
>>>>>>>>> http://jchrisa.net
>>>>>>>>> http://couch.io
>>>>>>>>>
>>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> --
>>>>>>> Chris Anderson
>>>>>>> http://jchrisa.net
>>>>>>> http://couch.io
>>>>>>>
>>>>>>
>>>>>
>>>>
>>>
>>
>>
>>
>> --
>> Chris Anderson
>> http://jchrisa.net
>> http://couch.io
>>
>



-- 
Chris Anderson
http://jchrisa.net
http://couch.io

Re: Redirect from _list function?

Posted by Zachary Zolton <za...@gmail.com>.
Guys,

I've started a ticket for this:
https://issues.apache.org/jira/browse/COUCHDB-514

I don't know what level of effort would be required to fix this, or if
this is even compatible with the current view server protocol. I'm
motivated to solve this, but I'd need some coaching from someone with
more knowledge of CouchDB view server internals.


Cheers,

Zach


On Sun, Sep 27, 2009 at 11:35 PM, Chris Anderson <jc...@apache.org> wrote:
> On Sun, Sep 27, 2009 at 8:26 PM, Zachary Zolton
> <za...@gmail.com> wrote:
>> Hmm... I can't do anything that doesn't result in a view server timeout. (^_-)
>>
>> Shall I open an issue? I can discuss what I tried, as well...
>>
>
> It never hurts to start a ticket. Especially if you have patches.
>
> Thinking about it more, it seems like the Erlang side is gonna be
> looking for that start signal before it will send a row. We'll need to
> design a dont-start signal, so that it can get a row without sending
> headers.
>
>> On Sun, Sep 27, 2009 at 12:06 PM, Paul Davis
>> <pa...@gmail.com> wrote:
>>> On Sun, Sep 27, 2009 at 1:04 PM, Zachary Zolton
>>> <za...@gmail.com> wrote:
>>>> Hey guys, newb question for you: the make script concatenates all the
>>>> /share/server/*.js scripts into main.js, right?
>>>>
>>>
>>> yepper.
>>>
>>>> I'm still trying to figure this stuff out...
>>>>
>>>> On Sat, Sep 26, 2009 at 11:35 PM, Zachary Zolton
>>>> <za...@gmail.com> wrote:
>>>>> I'll start studying the query_server_spec.rb script; I think I might
>>>>> be able to handle this in JavaScript...
>>>>>
>>>>> On Sat, Sep 26, 2009 at 11:22 PM, Chris Anderson <jc...@apache.org> wrote:
>>>>>> On Sat, Sep 26, 2009 at 8:57 PM, Paul Davis <pa...@gmail.com> wrote:
>>>>>>> its been awhile since i studied the Erlang side of this, but IIRC,
>>>>>>> once getRow() returns, the response has started which means that you
>>>>>>> can't send a redirect. To get it working proper then would require a
>>>>>>> bit of a patch to wait on starting the response until the first output
>>>>>>> from the _list function.
>>>>>>>
>>>>>>
>>>>>> Yes I think it would be a simple patch, once you understand the
>>>>>> entrails of the _list system. You should read the query_server_spec.rb
>>>>>> to see what gets sent by the query server on first getRow() call.
>>>>>>
>>>>>> It may be that this patch can be accomplished just in the javascript side.
>>>>>>
>>>>>> Chris
>>>>>>
>>>>>>> Paul Davis
>>>>>>>
>>>>>>> On Sat, Sep 26, 2009 at 11:39 PM, Zachary Zolton
>>>>>>> <za...@gmail.com> wrote:
>>>>>>>> Hey guys,
>>>>>>>>
>>>>>>>> I need to find a way to do a redirect from a _list function after
>>>>>>>> calling the getRow() function. After looking at render.js for a while
>>>>>>>> I can't see how to solve this without at least adding to the API.
>>>>>>>>
>>>>>>>> Basically, I think that calling getRow() shouldn't cause the view
>>>>>>>> server to send the headers (or awaiting chunks) unless we've already
>>>>>>>> called send() or something like that. That way, we can return from the
>>>>>>>> _list function after iterating to the first row that should redirect.
>>>>>>>> (I'm not sure if this is a breaking change from the current semantics,
>>>>>>>> however...)
>>>>>>>>
>>>>>>>> Would greatly appreciate a little guidance on how to attack this!
>>>>>>>>
>>>>>>>>
>>>>>>>> Cheers,
>>>>>>>>
>>>>>>>> Zach
>>>>>>>>
>>>>>>>>
>>>>>>>> ---------- Forwarded message ----------
>>>>>>>> From: Chris Anderson <jc...@apache.org>
>>>>>>>> Date: Fri, Sep 25, 2009 at 2:15 PM
>>>>>>>> Subject: Re: Redirect from _list function?
>>>>>>>> To: Zachary Zolton <za...@gmail.com>
>>>>>>>>
>>>>>>>>
>>>>>>>> On Fri, Sep 25, 2009 at 11:01 AM, Zachary Zolton
>>>>>>>> <za...@gmail.com> wrote:
>>>>>>>>> So, now I find that using the send() function to perform the redirect
>>>>>>>>> doesn't work after the first time I call getRow(). Upon checking out
>>>>>>>>> render.js, I see that the getRow() function calls sendStart()—which I
>>>>>>>>> haven't quite yet figured out—but I can tell there's something fishy
>>>>>>>>> going on there...
>>>>>>>>>
>>>>>>>>> Would I be correct to assume that the headers are already set after
>>>>>>>>> calling getRow()?
>>>>>>>>
>>>>>>>> Yes... The headers are sent when the first getRow is called. Fixing
>>>>>>>> this is definitely something I'd support.
>>>>>>>>
>>>>>>>>>
>>>>>>>>> On Fri, Sep 25, 2009 at 12:11 PM, Chris Anderson <jc...@apache.org> wrote:
>>>>>>>>>> On Fri, Sep 25, 2009 at 8:40 AM, Zachary Zolton
>>>>>>>>>> <za...@gmail.com> wrote:
>>>>>>>>>>> Okay, I've update this section to differentiate between the 0.9 and
>>>>>>>>>>> 0.10 _list API:
>>>>>>>>>>>
>>>>>>>>>>> http://wiki.apache.org/couchdb/Formatting_with_Show_and_List#Sending_a_Redirect
>>>>>>>>>>>
>>>>>>>>>>> Now, I'm feeling that the Other Fun Things section could use a bit of
>>>>>>>>>>> love. Hmm...  :^)
>>>>>>>>>>
>>>>>>>>>> Thanks for keeping the wiki in mind!
>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>> On Fri, Sep 25, 2009 at 10:19 AM, Zachary Zolton
>>>>>>>>>>> <za...@gmail.com> wrote:
>>>>>>>>>>>> Sweet! I'll try to amend the wiki page for the _list API...
>>>>>>>>>>>>
>>>>>>>>>>>> On Fri, Sep 25, 2009 at 10:17 AM, Jason Davies <ja...@jasondavies.com> wrote:
>>>>>>>>>>>>> On 25 Sep 2009, at 16:16, Zachary Zolton wrote:
>>>>>>>>>>>>>
>>>>>>>>>>>>>> Thanks for all the help, guys! Shall I delete that JIRA issue?
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>> I already did :-)
>>>>>>>>>>>>>
>>>>>>>>>>>>> --
>>>>>>>>>>>>> Jason Davies
>>>>>>>>>>>>>
>>>>>>>>>>>>> www.jasondavies.com
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>> --
>>>>>>>>>> Chris Anderson
>>>>>>>>>> http://jchrisa.net
>>>>>>>>>> http://couch.io
>>>>>>>>>>
>>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>> --
>>>>>>>> Chris Anderson
>>>>>>>> http://jchrisa.net
>>>>>>>> http://couch.io
>>>>>>>>
>>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>> --
>>>>>> Chris Anderson
>>>>>> http://jchrisa.net
>>>>>> http://couch.io
>>>>>>
>>>>>
>>>>
>>>
>>
>
>
>
> --
> Chris Anderson
> http://jchrisa.net
> http://couch.io
>

Re: Redirect from _list function?

Posted by Chris Anderson <jc...@apache.org>.
On Sun, Sep 27, 2009 at 8:26 PM, Zachary Zolton
<za...@gmail.com> wrote:
> Hmm... I can't do anything that doesn't result in a view server timeout. (^_-)
>
> Shall I open an issue? I can discuss what I tried, as well...
>

It never hurts to start a ticket. Especially if you have patches.

Thinking about it more, it seems like the Erlang side is gonna be
looking for that start signal before it will send a row. We'll need to
design a dont-start signal, so that it can get a row without sending
headers.

> On Sun, Sep 27, 2009 at 12:06 PM, Paul Davis
> <pa...@gmail.com> wrote:
>> On Sun, Sep 27, 2009 at 1:04 PM, Zachary Zolton
>> <za...@gmail.com> wrote:
>>> Hey guys, newb question for you: the make script concatenates all the
>>> /share/server/*.js scripts into main.js, right?
>>>
>>
>> yepper.
>>
>>> I'm still trying to figure this stuff out...
>>>
>>> On Sat, Sep 26, 2009 at 11:35 PM, Zachary Zolton
>>> <za...@gmail.com> wrote:
>>>> I'll start studying the query_server_spec.rb script; I think I might
>>>> be able to handle this in JavaScript...
>>>>
>>>> On Sat, Sep 26, 2009 at 11:22 PM, Chris Anderson <jc...@apache.org> wrote:
>>>>> On Sat, Sep 26, 2009 at 8:57 PM, Paul Davis <pa...@gmail.com> wrote:
>>>>>> its been awhile since i studied the Erlang side of this, but IIRC,
>>>>>> once getRow() returns, the response has started which means that you
>>>>>> can't send a redirect. To get it working proper then would require a
>>>>>> bit of a patch to wait on starting the response until the first output
>>>>>> from the _list function.
>>>>>>
>>>>>
>>>>> Yes I think it would be a simple patch, once you understand the
>>>>> entrails of the _list system. You should read the query_server_spec.rb
>>>>> to see what gets sent by the query server on first getRow() call.
>>>>>
>>>>> It may be that this patch can be accomplished just in the javascript side.
>>>>>
>>>>> Chris
>>>>>
>>>>>> Paul Davis
>>>>>>
>>>>>> On Sat, Sep 26, 2009 at 11:39 PM, Zachary Zolton
>>>>>> <za...@gmail.com> wrote:
>>>>>>> Hey guys,
>>>>>>>
>>>>>>> I need to find a way to do a redirect from a _list function after
>>>>>>> calling the getRow() function. After looking at render.js for a while
>>>>>>> I can't see how to solve this without at least adding to the API.
>>>>>>>
>>>>>>> Basically, I think that calling getRow() shouldn't cause the view
>>>>>>> server to send the headers (or awaiting chunks) unless we've already
>>>>>>> called send() or something like that. That way, we can return from the
>>>>>>> _list function after iterating to the first row that should redirect.
>>>>>>> (I'm not sure if this is a breaking change from the current semantics,
>>>>>>> however...)
>>>>>>>
>>>>>>> Would greatly appreciate a little guidance on how to attack this!
>>>>>>>
>>>>>>>
>>>>>>> Cheers,
>>>>>>>
>>>>>>> Zach
>>>>>>>
>>>>>>>
>>>>>>> ---------- Forwarded message ----------
>>>>>>> From: Chris Anderson <jc...@apache.org>
>>>>>>> Date: Fri, Sep 25, 2009 at 2:15 PM
>>>>>>> Subject: Re: Redirect from _list function?
>>>>>>> To: Zachary Zolton <za...@gmail.com>
>>>>>>>
>>>>>>>
>>>>>>> On Fri, Sep 25, 2009 at 11:01 AM, Zachary Zolton
>>>>>>> <za...@gmail.com> wrote:
>>>>>>>> So, now I find that using the send() function to perform the redirect
>>>>>>>> doesn't work after the first time I call getRow(). Upon checking out
>>>>>>>> render.js, I see that the getRow() function calls sendStart()—which I
>>>>>>>> haven't quite yet figured out—but I can tell there's something fishy
>>>>>>>> going on there...
>>>>>>>>
>>>>>>>> Would I be correct to assume that the headers are already set after
>>>>>>>> calling getRow()?
>>>>>>>
>>>>>>> Yes... The headers are sent when the first getRow is called. Fixing
>>>>>>> this is definitely something I'd support.
>>>>>>>
>>>>>>>>
>>>>>>>> On Fri, Sep 25, 2009 at 12:11 PM, Chris Anderson <jc...@apache.org> wrote:
>>>>>>>>> On Fri, Sep 25, 2009 at 8:40 AM, Zachary Zolton
>>>>>>>>> <za...@gmail.com> wrote:
>>>>>>>>>> Okay, I've update this section to differentiate between the 0.9 and
>>>>>>>>>> 0.10 _list API:
>>>>>>>>>>
>>>>>>>>>> http://wiki.apache.org/couchdb/Formatting_with_Show_and_List#Sending_a_Redirect
>>>>>>>>>>
>>>>>>>>>> Now, I'm feeling that the Other Fun Things section could use a bit of
>>>>>>>>>> love. Hmm...  :^)
>>>>>>>>>
>>>>>>>>> Thanks for keeping the wiki in mind!
>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>> On Fri, Sep 25, 2009 at 10:19 AM, Zachary Zolton
>>>>>>>>>> <za...@gmail.com> wrote:
>>>>>>>>>>> Sweet! I'll try to amend the wiki page for the _list API...
>>>>>>>>>>>
>>>>>>>>>>> On Fri, Sep 25, 2009 at 10:17 AM, Jason Davies <ja...@jasondavies.com> wrote:
>>>>>>>>>>>> On 25 Sep 2009, at 16:16, Zachary Zolton wrote:
>>>>>>>>>>>>
>>>>>>>>>>>>> Thanks for all the help, guys! Shall I delete that JIRA issue?
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>> I already did :-)
>>>>>>>>>>>>
>>>>>>>>>>>> --
>>>>>>>>>>>> Jason Davies
>>>>>>>>>>>>
>>>>>>>>>>>> www.jasondavies.com
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> --
>>>>>>>>> Chris Anderson
>>>>>>>>> http://jchrisa.net
>>>>>>>>> http://couch.io
>>>>>>>>>
>>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> --
>>>>>>> Chris Anderson
>>>>>>> http://jchrisa.net
>>>>>>> http://couch.io
>>>>>>>
>>>>>>
>>>>>
>>>>>
>>>>>
>>>>> --
>>>>> Chris Anderson
>>>>> http://jchrisa.net
>>>>> http://couch.io
>>>>>
>>>>
>>>
>>
>



-- 
Chris Anderson
http://jchrisa.net
http://couch.io

Re: Redirect from _list function?

Posted by Zachary Zolton <za...@gmail.com>.
Hmm... I can't do anything that doesn't result in a view server timeout. (^_-)

Shall I open an issue? I can discuss what I tried, as well...

On Sun, Sep 27, 2009 at 12:06 PM, Paul Davis
<pa...@gmail.com> wrote:
> On Sun, Sep 27, 2009 at 1:04 PM, Zachary Zolton
> <za...@gmail.com> wrote:
>> Hey guys, newb question for you: the make script concatenates all the
>> /share/server/*.js scripts into main.js, right?
>>
>
> yepper.
>
>> I'm still trying to figure this stuff out...
>>
>> On Sat, Sep 26, 2009 at 11:35 PM, Zachary Zolton
>> <za...@gmail.com> wrote:
>>> I'll start studying the query_server_spec.rb script; I think I might
>>> be able to handle this in JavaScript...
>>>
>>> On Sat, Sep 26, 2009 at 11:22 PM, Chris Anderson <jc...@apache.org> wrote:
>>>> On Sat, Sep 26, 2009 at 8:57 PM, Paul Davis <pa...@gmail.com> wrote:
>>>>> its been awhile since i studied the Erlang side of this, but IIRC,
>>>>> once getRow() returns, the response has started which means that you
>>>>> can't send a redirect. To get it working proper then would require a
>>>>> bit of a patch to wait on starting the response until the first output
>>>>> from the _list function.
>>>>>
>>>>
>>>> Yes I think it would be a simple patch, once you understand the
>>>> entrails of the _list system. You should read the query_server_spec.rb
>>>> to see what gets sent by the query server on first getRow() call.
>>>>
>>>> It may be that this patch can be accomplished just in the javascript side.
>>>>
>>>> Chris
>>>>
>>>>> Paul Davis
>>>>>
>>>>> On Sat, Sep 26, 2009 at 11:39 PM, Zachary Zolton
>>>>> <za...@gmail.com> wrote:
>>>>>> Hey guys,
>>>>>>
>>>>>> I need to find a way to do a redirect from a _list function after
>>>>>> calling the getRow() function. After looking at render.js for a while
>>>>>> I can't see how to solve this without at least adding to the API.
>>>>>>
>>>>>> Basically, I think that calling getRow() shouldn't cause the view
>>>>>> server to send the headers (or awaiting chunks) unless we've already
>>>>>> called send() or something like that. That way, we can return from the
>>>>>> _list function after iterating to the first row that should redirect.
>>>>>> (I'm not sure if this is a breaking change from the current semantics,
>>>>>> however...)
>>>>>>
>>>>>> Would greatly appreciate a little guidance on how to attack this!
>>>>>>
>>>>>>
>>>>>> Cheers,
>>>>>>
>>>>>> Zach
>>>>>>
>>>>>>
>>>>>> ---------- Forwarded message ----------
>>>>>> From: Chris Anderson <jc...@apache.org>
>>>>>> Date: Fri, Sep 25, 2009 at 2:15 PM
>>>>>> Subject: Re: Redirect from _list function?
>>>>>> To: Zachary Zolton <za...@gmail.com>
>>>>>>
>>>>>>
>>>>>> On Fri, Sep 25, 2009 at 11:01 AM, Zachary Zolton
>>>>>> <za...@gmail.com> wrote:
>>>>>>> So, now I find that using the send() function to perform the redirect
>>>>>>> doesn't work after the first time I call getRow(). Upon checking out
>>>>>>> render.js, I see that the getRow() function calls sendStart()—which I
>>>>>>> haven't quite yet figured out—but I can tell there's something fishy
>>>>>>> going on there...
>>>>>>>
>>>>>>> Would I be correct to assume that the headers are already set after
>>>>>>> calling getRow()?
>>>>>>
>>>>>> Yes... The headers are sent when the first getRow is called. Fixing
>>>>>> this is definitely something I'd support.
>>>>>>
>>>>>>>
>>>>>>> On Fri, Sep 25, 2009 at 12:11 PM, Chris Anderson <jc...@apache.org> wrote:
>>>>>>>> On Fri, Sep 25, 2009 at 8:40 AM, Zachary Zolton
>>>>>>>> <za...@gmail.com> wrote:
>>>>>>>>> Okay, I've update this section to differentiate between the 0.9 and
>>>>>>>>> 0.10 _list API:
>>>>>>>>>
>>>>>>>>> http://wiki.apache.org/couchdb/Formatting_with_Show_and_List#Sending_a_Redirect
>>>>>>>>>
>>>>>>>>> Now, I'm feeling that the Other Fun Things section could use a bit of
>>>>>>>>> love. Hmm...  :^)
>>>>>>>>
>>>>>>>> Thanks for keeping the wiki in mind!
>>>>>>>>
>>>>>>>>>
>>>>>>>>> On Fri, Sep 25, 2009 at 10:19 AM, Zachary Zolton
>>>>>>>>> <za...@gmail.com> wrote:
>>>>>>>>>> Sweet! I'll try to amend the wiki page for the _list API...
>>>>>>>>>>
>>>>>>>>>> On Fri, Sep 25, 2009 at 10:17 AM, Jason Davies <ja...@jasondavies.com> wrote:
>>>>>>>>>>> On 25 Sep 2009, at 16:16, Zachary Zolton wrote:
>>>>>>>>>>>
>>>>>>>>>>>> Thanks for all the help, guys! Shall I delete that JIRA issue?
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>> I already did :-)
>>>>>>>>>>>
>>>>>>>>>>> --
>>>>>>>>>>> Jason Davies
>>>>>>>>>>>
>>>>>>>>>>> www.jasondavies.com
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>> --
>>>>>>>> Chris Anderson
>>>>>>>> http://jchrisa.net
>>>>>>>> http://couch.io
>>>>>>>>
>>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>> --
>>>>>> Chris Anderson
>>>>>> http://jchrisa.net
>>>>>> http://couch.io
>>>>>>
>>>>>
>>>>
>>>>
>>>>
>>>> --
>>>> Chris Anderson
>>>> http://jchrisa.net
>>>> http://couch.io
>>>>
>>>
>>
>

Re: Redirect from _list function?

Posted by Paul Davis <pa...@gmail.com>.
On Sun, Sep 27, 2009 at 1:04 PM, Zachary Zolton
<za...@gmail.com> wrote:
> Hey guys, newb question for you: the make script concatenates all the
> /share/server/*.js scripts into main.js, right?
>

yepper.

> I'm still trying to figure this stuff out...
>
> On Sat, Sep 26, 2009 at 11:35 PM, Zachary Zolton
> <za...@gmail.com> wrote:
>> I'll start studying the query_server_spec.rb script; I think I might
>> be able to handle this in JavaScript...
>>
>> On Sat, Sep 26, 2009 at 11:22 PM, Chris Anderson <jc...@apache.org> wrote:
>>> On Sat, Sep 26, 2009 at 8:57 PM, Paul Davis <pa...@gmail.com> wrote:
>>>> its been awhile since i studied the Erlang side of this, but IIRC,
>>>> once getRow() returns, the response has started which means that you
>>>> can't send a redirect. To get it working proper then would require a
>>>> bit of a patch to wait on starting the response until the first output
>>>> from the _list function.
>>>>
>>>
>>> Yes I think it would be a simple patch, once you understand the
>>> entrails of the _list system. You should read the query_server_spec.rb
>>> to see what gets sent by the query server on first getRow() call.
>>>
>>> It may be that this patch can be accomplished just in the javascript side.
>>>
>>> Chris
>>>
>>>> Paul Davis
>>>>
>>>> On Sat, Sep 26, 2009 at 11:39 PM, Zachary Zolton
>>>> <za...@gmail.com> wrote:
>>>>> Hey guys,
>>>>>
>>>>> I need to find a way to do a redirect from a _list function after
>>>>> calling the getRow() function. After looking at render.js for a while
>>>>> I can't see how to solve this without at least adding to the API.
>>>>>
>>>>> Basically, I think that calling getRow() shouldn't cause the view
>>>>> server to send the headers (or awaiting chunks) unless we've already
>>>>> called send() or something like that. That way, we can return from the
>>>>> _list function after iterating to the first row that should redirect.
>>>>> (I'm not sure if this is a breaking change from the current semantics,
>>>>> however...)
>>>>>
>>>>> Would greatly appreciate a little guidance on how to attack this!
>>>>>
>>>>>
>>>>> Cheers,
>>>>>
>>>>> Zach
>>>>>
>>>>>
>>>>> ---------- Forwarded message ----------
>>>>> From: Chris Anderson <jc...@apache.org>
>>>>> Date: Fri, Sep 25, 2009 at 2:15 PM
>>>>> Subject: Re: Redirect from _list function?
>>>>> To: Zachary Zolton <za...@gmail.com>
>>>>>
>>>>>
>>>>> On Fri, Sep 25, 2009 at 11:01 AM, Zachary Zolton
>>>>> <za...@gmail.com> wrote:
>>>>>> So, now I find that using the send() function to perform the redirect
>>>>>> doesn't work after the first time I call getRow(). Upon checking out
>>>>>> render.js, I see that the getRow() function calls sendStart()—which I
>>>>>> haven't quite yet figured out—but I can tell there's something fishy
>>>>>> going on there...
>>>>>>
>>>>>> Would I be correct to assume that the headers are already set after
>>>>>> calling getRow()?
>>>>>
>>>>> Yes... The headers are sent when the first getRow is called. Fixing
>>>>> this is definitely something I'd support.
>>>>>
>>>>>>
>>>>>> On Fri, Sep 25, 2009 at 12:11 PM, Chris Anderson <jc...@apache.org> wrote:
>>>>>>> On Fri, Sep 25, 2009 at 8:40 AM, Zachary Zolton
>>>>>>> <za...@gmail.com> wrote:
>>>>>>>> Okay, I've update this section to differentiate between the 0.9 and
>>>>>>>> 0.10 _list API:
>>>>>>>>
>>>>>>>> http://wiki.apache.org/couchdb/Formatting_with_Show_and_List#Sending_a_Redirect
>>>>>>>>
>>>>>>>> Now, I'm feeling that the Other Fun Things section could use a bit of
>>>>>>>> love. Hmm...  :^)
>>>>>>>
>>>>>>> Thanks for keeping the wiki in mind!
>>>>>>>
>>>>>>>>
>>>>>>>> On Fri, Sep 25, 2009 at 10:19 AM, Zachary Zolton
>>>>>>>> <za...@gmail.com> wrote:
>>>>>>>>> Sweet! I'll try to amend the wiki page for the _list API...
>>>>>>>>>
>>>>>>>>> On Fri, Sep 25, 2009 at 10:17 AM, Jason Davies <ja...@jasondavies.com> wrote:
>>>>>>>>>> On 25 Sep 2009, at 16:16, Zachary Zolton wrote:
>>>>>>>>>>
>>>>>>>>>>> Thanks for all the help, guys! Shall I delete that JIRA issue?
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>> I already did :-)
>>>>>>>>>>
>>>>>>>>>> --
>>>>>>>>>> Jason Davies
>>>>>>>>>>
>>>>>>>>>> www.jasondavies.com
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>
>>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> --
>>>>>>> Chris Anderson
>>>>>>> http://jchrisa.net
>>>>>>> http://couch.io
>>>>>>>
>>>>>>
>>>>>
>>>>>
>>>>>
>>>>> --
>>>>> Chris Anderson
>>>>> http://jchrisa.net
>>>>> http://couch.io
>>>>>
>>>>
>>>
>>>
>>>
>>> --
>>> Chris Anderson
>>> http://jchrisa.net
>>> http://couch.io
>>>
>>
>

Re: Redirect from _list function?

Posted by Zachary Zolton <za...@gmail.com>.
Hey guys, newb question for you: the make script concatenates all the
/share/server/*.js scripts into main.js, right?

I'm still trying to figure this stuff out...

On Sat, Sep 26, 2009 at 11:35 PM, Zachary Zolton
<za...@gmail.com> wrote:
> I'll start studying the query_server_spec.rb script; I think I might
> be able to handle this in JavaScript...
>
> On Sat, Sep 26, 2009 at 11:22 PM, Chris Anderson <jc...@apache.org> wrote:
>> On Sat, Sep 26, 2009 at 8:57 PM, Paul Davis <pa...@gmail.com> wrote:
>>> its been awhile since i studied the Erlang side of this, but IIRC,
>>> once getRow() returns, the response has started which means that you
>>> can't send a redirect. To get it working proper then would require a
>>> bit of a patch to wait on starting the response until the first output
>>> from the _list function.
>>>
>>
>> Yes I think it would be a simple patch, once you understand the
>> entrails of the _list system. You should read the query_server_spec.rb
>> to see what gets sent by the query server on first getRow() call.
>>
>> It may be that this patch can be accomplished just in the javascript side.
>>
>> Chris
>>
>>> Paul Davis
>>>
>>> On Sat, Sep 26, 2009 at 11:39 PM, Zachary Zolton
>>> <za...@gmail.com> wrote:
>>>> Hey guys,
>>>>
>>>> I need to find a way to do a redirect from a _list function after
>>>> calling the getRow() function. After looking at render.js for a while
>>>> I can't see how to solve this without at least adding to the API.
>>>>
>>>> Basically, I think that calling getRow() shouldn't cause the view
>>>> server to send the headers (or awaiting chunks) unless we've already
>>>> called send() or something like that. That way, we can return from the
>>>> _list function after iterating to the first row that should redirect.
>>>> (I'm not sure if this is a breaking change from the current semantics,
>>>> however...)
>>>>
>>>> Would greatly appreciate a little guidance on how to attack this!
>>>>
>>>>
>>>> Cheers,
>>>>
>>>> Zach
>>>>
>>>>
>>>> ---------- Forwarded message ----------
>>>> From: Chris Anderson <jc...@apache.org>
>>>> Date: Fri, Sep 25, 2009 at 2:15 PM
>>>> Subject: Re: Redirect from _list function?
>>>> To: Zachary Zolton <za...@gmail.com>
>>>>
>>>>
>>>> On Fri, Sep 25, 2009 at 11:01 AM, Zachary Zolton
>>>> <za...@gmail.com> wrote:
>>>>> So, now I find that using the send() function to perform the redirect
>>>>> doesn't work after the first time I call getRow(). Upon checking out
>>>>> render.js, I see that the getRow() function calls sendStart()—which I
>>>>> haven't quite yet figured out—but I can tell there's something fishy
>>>>> going on there...
>>>>>
>>>>> Would I be correct to assume that the headers are already set after
>>>>> calling getRow()?
>>>>
>>>> Yes... The headers are sent when the first getRow is called. Fixing
>>>> this is definitely something I'd support.
>>>>
>>>>>
>>>>> On Fri, Sep 25, 2009 at 12:11 PM, Chris Anderson <jc...@apache.org> wrote:
>>>>>> On Fri, Sep 25, 2009 at 8:40 AM, Zachary Zolton
>>>>>> <za...@gmail.com> wrote:
>>>>>>> Okay, I've update this section to differentiate between the 0.9 and
>>>>>>> 0.10 _list API:
>>>>>>>
>>>>>>> http://wiki.apache.org/couchdb/Formatting_with_Show_and_List#Sending_a_Redirect
>>>>>>>
>>>>>>> Now, I'm feeling that the Other Fun Things section could use a bit of
>>>>>>> love. Hmm...  :^)
>>>>>>
>>>>>> Thanks for keeping the wiki in mind!
>>>>>>
>>>>>>>
>>>>>>> On Fri, Sep 25, 2009 at 10:19 AM, Zachary Zolton
>>>>>>> <za...@gmail.com> wrote:
>>>>>>>> Sweet! I'll try to amend the wiki page for the _list API...
>>>>>>>>
>>>>>>>> On Fri, Sep 25, 2009 at 10:17 AM, Jason Davies <ja...@jasondavies.com> wrote:
>>>>>>>>> On 25 Sep 2009, at 16:16, Zachary Zolton wrote:
>>>>>>>>>
>>>>>>>>>> Thanks for all the help, guys! Shall I delete that JIRA issue?
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> I already did :-)
>>>>>>>>>
>>>>>>>>> --
>>>>>>>>> Jason Davies
>>>>>>>>>
>>>>>>>>> www.jasondavies.com
>>>>>>>>>
>>>>>>>>>
>>>>>>>>
>>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>> --
>>>>>> Chris Anderson
>>>>>> http://jchrisa.net
>>>>>> http://couch.io
>>>>>>
>>>>>
>>>>
>>>>
>>>>
>>>> --
>>>> Chris Anderson
>>>> http://jchrisa.net
>>>> http://couch.io
>>>>
>>>
>>
>>
>>
>> --
>> Chris Anderson
>> http://jchrisa.net
>> http://couch.io
>>
>

Re: Redirect from _list function?

Posted by Zachary Zolton <za...@gmail.com>.
I'll start studying the query_server_spec.rb script; I think I might
be able to handle this in JavaScript...

On Sat, Sep 26, 2009 at 11:22 PM, Chris Anderson <jc...@apache.org> wrote:
> On Sat, Sep 26, 2009 at 8:57 PM, Paul Davis <pa...@gmail.com> wrote:
>> its been awhile since i studied the Erlang side of this, but IIRC,
>> once getRow() returns, the response has started which means that you
>> can't send a redirect. To get it working proper then would require a
>> bit of a patch to wait on starting the response until the first output
>> from the _list function.
>>
>
> Yes I think it would be a simple patch, once you understand the
> entrails of the _list system. You should read the query_server_spec.rb
> to see what gets sent by the query server on first getRow() call.
>
> It may be that this patch can be accomplished just in the javascript side.
>
> Chris
>
>> Paul Davis
>>
>> On Sat, Sep 26, 2009 at 11:39 PM, Zachary Zolton
>> <za...@gmail.com> wrote:
>>> Hey guys,
>>>
>>> I need to find a way to do a redirect from a _list function after
>>> calling the getRow() function. After looking at render.js for a while
>>> I can't see how to solve this without at least adding to the API.
>>>
>>> Basically, I think that calling getRow() shouldn't cause the view
>>> server to send the headers (or awaiting chunks) unless we've already
>>> called send() or something like that. That way, we can return from the
>>> _list function after iterating to the first row that should redirect.
>>> (I'm not sure if this is a breaking change from the current semantics,
>>> however...)
>>>
>>> Would greatly appreciate a little guidance on how to attack this!
>>>
>>>
>>> Cheers,
>>>
>>> Zach
>>>
>>>
>>> ---------- Forwarded message ----------
>>> From: Chris Anderson <jc...@apache.org>
>>> Date: Fri, Sep 25, 2009 at 2:15 PM
>>> Subject: Re: Redirect from _list function?
>>> To: Zachary Zolton <za...@gmail.com>
>>>
>>>
>>> On Fri, Sep 25, 2009 at 11:01 AM, Zachary Zolton
>>> <za...@gmail.com> wrote:
>>>> So, now I find that using the send() function to perform the redirect
>>>> doesn't work after the first time I call getRow(). Upon checking out
>>>> render.js, I see that the getRow() function calls sendStart()—which I
>>>> haven't quite yet figured out—but I can tell there's something fishy
>>>> going on there...
>>>>
>>>> Would I be correct to assume that the headers are already set after
>>>> calling getRow()?
>>>
>>> Yes... The headers are sent when the first getRow is called. Fixing
>>> this is definitely something I'd support.
>>>
>>>>
>>>> On Fri, Sep 25, 2009 at 12:11 PM, Chris Anderson <jc...@apache.org> wrote:
>>>>> On Fri, Sep 25, 2009 at 8:40 AM, Zachary Zolton
>>>>> <za...@gmail.com> wrote:
>>>>>> Okay, I've update this section to differentiate between the 0.9 and
>>>>>> 0.10 _list API:
>>>>>>
>>>>>> http://wiki.apache.org/couchdb/Formatting_with_Show_and_List#Sending_a_Redirect
>>>>>>
>>>>>> Now, I'm feeling that the Other Fun Things section could use a bit of
>>>>>> love. Hmm...  :^)
>>>>>
>>>>> Thanks for keeping the wiki in mind!
>>>>>
>>>>>>
>>>>>> On Fri, Sep 25, 2009 at 10:19 AM, Zachary Zolton
>>>>>> <za...@gmail.com> wrote:
>>>>>>> Sweet! I'll try to amend the wiki page for the _list API...
>>>>>>>
>>>>>>> On Fri, Sep 25, 2009 at 10:17 AM, Jason Davies <ja...@jasondavies.com> wrote:
>>>>>>>> On 25 Sep 2009, at 16:16, Zachary Zolton wrote:
>>>>>>>>
>>>>>>>>> Thanks for all the help, guys! Shall I delete that JIRA issue?
>>>>>>>>
>>>>>>>>
>>>>>>>> I already did :-)
>>>>>>>>
>>>>>>>> --
>>>>>>>> Jason Davies
>>>>>>>>
>>>>>>>> www.jasondavies.com
>>>>>>>>
>>>>>>>>
>>>>>>>
>>>>>>
>>>>>
>>>>>
>>>>>
>>>>> --
>>>>> Chris Anderson
>>>>> http://jchrisa.net
>>>>> http://couch.io
>>>>>
>>>>
>>>
>>>
>>>
>>> --
>>> Chris Anderson
>>> http://jchrisa.net
>>> http://couch.io
>>>
>>
>
>
>
> --
> Chris Anderson
> http://jchrisa.net
> http://couch.io
>

Re: Redirect from _list function?

Posted by Chris Anderson <jc...@apache.org>.
On Sat, Sep 26, 2009 at 8:57 PM, Paul Davis <pa...@gmail.com> wrote:
> its been awhile since i studied the Erlang side of this, but IIRC,
> once getRow() returns, the response has started which means that you
> can't send a redirect. To get it working proper then would require a
> bit of a patch to wait on starting the response until the first output
> from the _list function.
>

Yes I think it would be a simple patch, once you understand the
entrails of the _list system. You should read the query_server_spec.rb
to see what gets sent by the query server on first getRow() call.

It may be that this patch can be accomplished just in the javascript side.

Chris

> Paul Davis
>
> On Sat, Sep 26, 2009 at 11:39 PM, Zachary Zolton
> <za...@gmail.com> wrote:
>> Hey guys,
>>
>> I need to find a way to do a redirect from a _list function after
>> calling the getRow() function. After looking at render.js for a while
>> I can't see how to solve this without at least adding to the API.
>>
>> Basically, I think that calling getRow() shouldn't cause the view
>> server to send the headers (or awaiting chunks) unless we've already
>> called send() or something like that. That way, we can return from the
>> _list function after iterating to the first row that should redirect.
>> (I'm not sure if this is a breaking change from the current semantics,
>> however...)
>>
>> Would greatly appreciate a little guidance on how to attack this!
>>
>>
>> Cheers,
>>
>> Zach
>>
>>
>> ---------- Forwarded message ----------
>> From: Chris Anderson <jc...@apache.org>
>> Date: Fri, Sep 25, 2009 at 2:15 PM
>> Subject: Re: Redirect from _list function?
>> To: Zachary Zolton <za...@gmail.com>
>>
>>
>> On Fri, Sep 25, 2009 at 11:01 AM, Zachary Zolton
>> <za...@gmail.com> wrote:
>>> So, now I find that using the send() function to perform the redirect
>>> doesn't work after the first time I call getRow(). Upon checking out
>>> render.js, I see that the getRow() function calls sendStart()—which I
>>> haven't quite yet figured out—but I can tell there's something fishy
>>> going on there...
>>>
>>> Would I be correct to assume that the headers are already set after
>>> calling getRow()?
>>
>> Yes... The headers are sent when the first getRow is called. Fixing
>> this is definitely something I'd support.
>>
>>>
>>> On Fri, Sep 25, 2009 at 12:11 PM, Chris Anderson <jc...@apache.org> wrote:
>>>> On Fri, Sep 25, 2009 at 8:40 AM, Zachary Zolton
>>>> <za...@gmail.com> wrote:
>>>>> Okay, I've update this section to differentiate between the 0.9 and
>>>>> 0.10 _list API:
>>>>>
>>>>> http://wiki.apache.org/couchdb/Formatting_with_Show_and_List#Sending_a_Redirect
>>>>>
>>>>> Now, I'm feeling that the Other Fun Things section could use a bit of
>>>>> love. Hmm...  :^)
>>>>
>>>> Thanks for keeping the wiki in mind!
>>>>
>>>>>
>>>>> On Fri, Sep 25, 2009 at 10:19 AM, Zachary Zolton
>>>>> <za...@gmail.com> wrote:
>>>>>> Sweet! I'll try to amend the wiki page for the _list API...
>>>>>>
>>>>>> On Fri, Sep 25, 2009 at 10:17 AM, Jason Davies <ja...@jasondavies.com> wrote:
>>>>>>> On 25 Sep 2009, at 16:16, Zachary Zolton wrote:
>>>>>>>
>>>>>>>> Thanks for all the help, guys! Shall I delete that JIRA issue?
>>>>>>>
>>>>>>>
>>>>>>> I already did :-)
>>>>>>>
>>>>>>> --
>>>>>>> Jason Davies
>>>>>>>
>>>>>>> www.jasondavies.com
>>>>>>>
>>>>>>>
>>>>>>
>>>>>
>>>>
>>>>
>>>>
>>>> --
>>>> Chris Anderson
>>>> http://jchrisa.net
>>>> http://couch.io
>>>>
>>>
>>
>>
>>
>> --
>> Chris Anderson
>> http://jchrisa.net
>> http://couch.io
>>
>



-- 
Chris Anderson
http://jchrisa.net
http://couch.io

Re: Redirect from _list function?

Posted by Paul Davis <pa...@gmail.com>.
its been awhile since i studied the Erlang side of this, but IIRC,
once getRow() returns, the response has started which means that you
can't send a redirect. To get it working proper then would require a
bit of a patch to wait on starting the response until the first output
from the _list function.

Paul Davis

On Sat, Sep 26, 2009 at 11:39 PM, Zachary Zolton
<za...@gmail.com> wrote:
> Hey guys,
>
> I need to find a way to do a redirect from a _list function after
> calling the getRow() function. After looking at render.js for a while
> I can't see how to solve this without at least adding to the API.
>
> Basically, I think that calling getRow() shouldn't cause the view
> server to send the headers (or awaiting chunks) unless we've already
> called send() or something like that. That way, we can return from the
> _list function after iterating to the first row that should redirect.
> (I'm not sure if this is a breaking change from the current semantics,
> however...)
>
> Would greatly appreciate a little guidance on how to attack this!
>
>
> Cheers,
>
> Zach
>
>
> ---------- Forwarded message ----------
> From: Chris Anderson <jc...@apache.org>
> Date: Fri, Sep 25, 2009 at 2:15 PM
> Subject: Re: Redirect from _list function?
> To: Zachary Zolton <za...@gmail.com>
>
>
> On Fri, Sep 25, 2009 at 11:01 AM, Zachary Zolton
> <za...@gmail.com> wrote:
>> So, now I find that using the send() function to perform the redirect
>> doesn't work after the first time I call getRow(). Upon checking out
>> render.js, I see that the getRow() function calls sendStart()—which I
>> haven't quite yet figured out—but I can tell there's something fishy
>> going on there...
>>
>> Would I be correct to assume that the headers are already set after
>> calling getRow()?
>
> Yes... The headers are sent when the first getRow is called. Fixing
> this is definitely something I'd support.
>
>>
>> On Fri, Sep 25, 2009 at 12:11 PM, Chris Anderson <jc...@apache.org> wrote:
>>> On Fri, Sep 25, 2009 at 8:40 AM, Zachary Zolton
>>> <za...@gmail.com> wrote:
>>>> Okay, I've update this section to differentiate between the 0.9 and
>>>> 0.10 _list API:
>>>>
>>>> http://wiki.apache.org/couchdb/Formatting_with_Show_and_List#Sending_a_Redirect
>>>>
>>>> Now, I'm feeling that the Other Fun Things section could use a bit of
>>>> love. Hmm...  :^)
>>>
>>> Thanks for keeping the wiki in mind!
>>>
>>>>
>>>> On Fri, Sep 25, 2009 at 10:19 AM, Zachary Zolton
>>>> <za...@gmail.com> wrote:
>>>>> Sweet! I'll try to amend the wiki page for the _list API...
>>>>>
>>>>> On Fri, Sep 25, 2009 at 10:17 AM, Jason Davies <ja...@jasondavies.com> wrote:
>>>>>> On 25 Sep 2009, at 16:16, Zachary Zolton wrote:
>>>>>>
>>>>>>> Thanks for all the help, guys! Shall I delete that JIRA issue?
>>>>>>
>>>>>>
>>>>>> I already did :-)
>>>>>>
>>>>>> --
>>>>>> Jason Davies
>>>>>>
>>>>>> www.jasondavies.com
>>>>>>
>>>>>>
>>>>>
>>>>
>>>
>>>
>>>
>>> --
>>> Chris Anderson
>>> http://jchrisa.net
>>> http://couch.io
>>>
>>
>
>
>
> --
> Chris Anderson
> http://jchrisa.net
> http://couch.io
>

Fwd: Redirect from _list function?

Posted by Zachary Zolton <za...@gmail.com>.
Hey guys,

I need to find a way to do a redirect from a _list function after
calling the getRow() function. After looking at render.js for a while
I can't see how to solve this without at least adding to the API.

Basically, I think that calling getRow() shouldn't cause the view
server to send the headers (or awaiting chunks) unless we've already
called send() or something like that. That way, we can return from the
_list function after iterating to the first row that should redirect.
(I'm not sure if this is a breaking change from the current semantics,
however...)

Would greatly appreciate a little guidance on how to attack this!


Cheers,

Zach


---------- Forwarded message ----------
From: Chris Anderson <jc...@apache.org>
Date: Fri, Sep 25, 2009 at 2:15 PM
Subject: Re: Redirect from _list function?
To: Zachary Zolton <za...@gmail.com>


On Fri, Sep 25, 2009 at 11:01 AM, Zachary Zolton
<za...@gmail.com> wrote:
> So, now I find that using the send() function to perform the redirect
> doesn't work after the first time I call getRow(). Upon checking out
> render.js, I see that the getRow() function calls sendStart()—which I
> haven't quite yet figured out—but I can tell there's something fishy
> going on there...
>
> Would I be correct to assume that the headers are already set after
> calling getRow()?

Yes... The headers are sent when the first getRow is called. Fixing
this is definitely something I'd support.

>
> On Fri, Sep 25, 2009 at 12:11 PM, Chris Anderson <jc...@apache.org> wrote:
>> On Fri, Sep 25, 2009 at 8:40 AM, Zachary Zolton
>> <za...@gmail.com> wrote:
>>> Okay, I've update this section to differentiate between the 0.9 and
>>> 0.10 _list API:
>>>
>>> http://wiki.apache.org/couchdb/Formatting_with_Show_and_List#Sending_a_Redirect
>>>
>>> Now, I'm feeling that the Other Fun Things section could use a bit of
>>> love. Hmm...  :^)
>>
>> Thanks for keeping the wiki in mind!
>>
>>>
>>> On Fri, Sep 25, 2009 at 10:19 AM, Zachary Zolton
>>> <za...@gmail.com> wrote:
>>>> Sweet! I'll try to amend the wiki page for the _list API...
>>>>
>>>> On Fri, Sep 25, 2009 at 10:17 AM, Jason Davies <ja...@jasondavies.com> wrote:
>>>>> On 25 Sep 2009, at 16:16, Zachary Zolton wrote:
>>>>>
>>>>>> Thanks for all the help, guys! Shall I delete that JIRA issue?
>>>>>
>>>>>
>>>>> I already did :-)
>>>>>
>>>>> --
>>>>> Jason Davies
>>>>>
>>>>> www.jasondavies.com
>>>>>
>>>>>
>>>>
>>>
>>
>>
>>
>> --
>> Chris Anderson
>> http://jchrisa.net
>> http://couch.io
>>
>



--
Chris Anderson
http://jchrisa.net
http://couch.io

Re: Redirect from _list function?

Posted by Zachary Zolton <za...@gmail.com>.
Okay, I've update this section to differentiate between the 0.9 and
0.10 _list API:

http://wiki.apache.org/couchdb/Formatting_with_Show_and_List#Sending_a_Redirect

Now, I'm feeling that the Other Fun Things section could use a bit of
love. Hmm...  :^)

On Fri, Sep 25, 2009 at 10:19 AM, Zachary Zolton
<za...@gmail.com> wrote:
> Sweet! I'll try to amend the wiki page for the _list API...
>
> On Fri, Sep 25, 2009 at 10:17 AM, Jason Davies <ja...@jasondavies.com> wrote:
>> On 25 Sep 2009, at 16:16, Zachary Zolton wrote:
>>
>>> Thanks for all the help, guys! Shall I delete that JIRA issue?
>>
>>
>> I already did :-)
>>
>> --
>> Jason Davies
>>
>> www.jasondavies.com
>>
>>
>

Re: Redirect from _list function?

Posted by Zachary Zolton <za...@gmail.com>.
Sweet! I'll try to amend the wiki page for the _list API...

On Fri, Sep 25, 2009 at 10:17 AM, Jason Davies <ja...@jasondavies.com> wrote:
> On 25 Sep 2009, at 16:16, Zachary Zolton wrote:
>
>> Thanks for all the help, guys! Shall I delete that JIRA issue?
>
>
> I already did :-)
>
> --
> Jason Davies
>
> www.jasondavies.com
>
>

Re: Redirect from _list function?

Posted by Jason Davies <ja...@jasondavies.com>.
On 25 Sep 2009, at 16:16, Zachary Zolton wrote:

> Thanks for all the help, guys! Shall I delete that JIRA issue?


I already did :-)

--
Jason Davies

www.jasondavies.com


Re: Redirect from _list function?

Posted by Zachary Zolton <za...@gmail.com>.
Sure enough, it worked!

~ $ curl -i localhost:5984/db/_design/ddoc/_list/test-redirect/viewname?key=%22foo%22
HTTP/1.1 301 Moved Permanently
Vary: Accept
Transfer-Encoding: chunked
Server: CouchDB/0.11.0a9fd42dc1-git (Erlang OTP/R12B)
Location: http://www.google.com/
Etag: "BD2ANSRT6L22UMHH33LRICKXI"
Date: Fri, 25 Sep 2009 15:15:13 GMT
Content-Type: application/json



Thanks for all the help, guys! Shall I delete that JIRA issue?

On Fri, Sep 25, 2009 at 10:12 AM, Jason Davies <ja...@jasondavies.com> wrote:
> Hi Zach,
>
> Try this instead:
>
> function(head, req) {
>  start({code:301, headers:  { 'Location': 'http://www.google.com/' }});
> }
>
> Thanks,
> --
> Jason Davies
>
> www.jasondavies.com
>
> On 24 Sep 2009, at 23:34, Zachary Zolton wrote:
>
>> Hello,
>>
>> Should I be able to do a redirect from a _list function?
>>
>> I ask because I've tried defining the following _list function:
>>
>> function(head, req) {
>>  return {
>>   'code': 301,
>>   'headers': { 'Location': 'http://www.google.com/' }
>>  };
>> }
>>
>> And, here's what happens when I try to hit it:
>>
>> $ curl -i
>> 'http://localhost:5984/db/_design/ddoc/_list/test-redirect/some-view?key=%22foo%22'
>> HTTP/1.1 200 OK
>> Vary: Accept
>> Transfer-Encoding: chunked
>> Server: CouchDB/0.11.0a9fd42dc1-git (Erlang OTP/R12B)
>> Etag: "46014W5JDRLKZF5SECP2D44YH"
>> Date: Thu, 24 Sep 2009 22:23:14 GMT
>> Content-Type: application/json
>>
>> curl: (56) Received problem 2 in the chunky parser
>>
>> Obviously, this does not look like a redirect.  :^(  Do I seem to be
>> doing anything wrong here?
>>
>>
>> Thanks!
>>
>> Zach
>
>

Re: Redirect from _list function?

Posted by Jason Davies <ja...@jasondavies.com>.
Hi Zach,

Try this instead:

function(head, req) {
   start({code:301, headers:  { 'Location': 'http:// 
www.google.com/' }});
}

Thanks,
--
Jason Davies

www.jasondavies.com

On 24 Sep 2009, at 23:34, Zachary Zolton wrote:

> Hello,
>
> Should I be able to do a redirect from a _list function?
>
> I ask because I've tried defining the following _list function:
>
> function(head, req) {
>  return {
>    'code': 301,
>    'headers': { 'Location': 'http://www.google.com/' }
>  };
> }
>
> And, here's what happens when I try to hit it:
>
> $ curl -i 'http://localhost:5984/db/_design/ddoc/_list/test-redirect/ 
> some-view?key=%22foo%22'
> HTTP/1.1 200 OK
> Vary: Accept
> Transfer-Encoding: chunked
> Server: CouchDB/0.11.0a9fd42dc1-git (Erlang OTP/R12B)
> Etag: "46014W5JDRLKZF5SECP2D44YH"
> Date: Thu, 24 Sep 2009 22:23:14 GMT
> Content-Type: application/json
>
> curl: (56) Received problem 2 in the chunky parser
>
> Obviously, this does not look like a redirect.  :^(  Do I seem to be
> doing anything wrong here?
>
>
> Thanks!
>
> Zach