couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Anh <7za...@gmail.com>
Subject Re: List functions and headers using send, getRow
Date Wed, 21 Apr 2010 16:10:03 GMT
Ah- thanks for the tip!

On Apr 21, 2010, at 6:53 AM, Steve Foulkes <sfoulkes@fnal.gov> wrote:

> Hi,
>
> You can use the start() function like this:
>   start({"headers": {"Content-Type": "text/html"}});
>
> Unfortunately, the only place I could find this documented was in  
> the couch unit tests :-(
>
> Steve
>
> Anh wrote:
>> Hi,
>>
>> I'm a little confused on how to set the content-type header for list
>> functions which return HTML.
>> I'm using the send() and getRow() functions:
>>
>> function(head, req) {
>>    send('<html><body><ul>');
>>    var row;
>>    while (row = getRow()) {
>>        send('<li>' + row.id + '</li>');
>>    }
>>    send('</ul></body></html>');
>> }
>>
>> which works fine, but I'm not setting any content-type headers.
>>
>> The examples I see in the docs use return, which returns the entire
>> body as well:
>>
>> return {
>>   "headers" : {"Content-Type" : "application/xml"},
>>   "body" : new XML('<xml><node foo="bar"/></xml>')
>> }
>>
>>
>> Do I have to build the whole body as a string first, and then  
>> return it?
>>
>> If so, that would seems to lose a benefit of list functions, that you
>> can process and send each row at a time, versus eating memory.
>>
>>
>> Thanks, any help would be appreciated.
>>
>>
>

Mime
View raw message