# Question on Evan Miller's tutorial - Body filter?

**URL:** <https://www.ruby-forum.com/t/question-on-evan-millers-tutorial-body-filter/204365>\
**Category:** NGINX\
**Created:** [March 10, 2011, 4:08pm UTC](https://www.ruby-forum.com/t/question-on-evan-millers-tutorial-body-filter/204365 "2011-03-10T16:08:09Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![dubstep](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/cdc98d/32.png) [@dubstep](https://www.ruby-forum.com/u/dubstep)\
**Post date:** [March 10, 2011, 4:08pm UTC](https://www.ruby-forum.com/t/question-on-evan-millers-tutorial-body-filter/204365/1 "2011-03-10T16:08:09Z")

</div>

Hello,  
I’m going through Evan M.'s tutorial on Nginx module. In part “4.2.  
Anatomy of a Body Filter”, there’s a piece of code like this:  
"And hook the buffer into a new chain link:

```
ngx_chain_t added_link;

added_link.buf = b;
added_link.next = NULL;

```

Finally, hook the new chain link to the final chain link we found  
before:

```
chain_link->next = added_link;

```

And reset the “last\_buf” variables to reflect reality:

```
chain_link->buf->last_buf = 0;
added_link->buf->last_buf = 1;"

```

At the last line, added\_link is being used as a structure pointer but at  
the beginning it’s defined as a structure. Am i missing something?  
Compiler gives error for this incompetible usage.

Thanks

Posted at Nginx Forum:

> **[Question on Evan Miller's tutorial - Body filter?](https://forum.nginx.org/read.php?2,181975,181975#msg-181975)**
>
> Hello, I'm going through Evan Miller's tutorial on Nginx module. In part "4.2. Anatomy of a Body Filter", there's a piece of code like this: "And hook the buffer into a new chain link: ngx\_chain\_t added\_link; added\_link.buf = b;

---

<div class="post-metadata">

**Author:** ![ctasdemir](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/ed8c4c/32.png) [@ctasdemir](https://www.ruby-forum.com/u/ctasdemir)\
**Post date:** [March 14, 2011, 8:59am UTC](https://www.ruby-forum.com/t/question-on-evan-millers-tutorial-body-filter/204365/2 "2011-03-14T08:59:39Z")

</div>

On Thu, Mar 10, 2011 at 11:06 PM, ctasdemir [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

> At the last line, added\_link is being used as a structure pointer but at  
> the beginning it’s defined as a structure. Am i missing something?  
> Compiler gives error for this incompetible usage.

If it is a silly C grammatical error, just go ahead and fix it.

BTW,

1. we usually use ngx\_chain\_t pointers rather than plain structures on  
the stack 😉
2. do not assume nobody writes body filter modules; that is silly.

Cheers,  
-agentzh

---

<div class="post-metadata">

**Author:** ![ctasdemir](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/ed8c4c/32.png) [@ctasdemir](https://www.ruby-forum.com/u/ctasdemir)\
**Post date:** [March 14, 2011, 8:48am UTC](https://www.ruby-forum.com/t/question-on-evan-millers-tutorial-body-filter/204365/3 "2011-03-14T08:48:59Z")

</div>

Didn’t anybody write body filter module?

Posted at Nginx Forum:

> **[Re: Question on Evan Miller's tutorial - Body filter?](https://forum.nginx.org/read.php?2,181975,182737#msg-182737)**
>
> Hello, I'm going through Evan Miller's tutorial on Nginx module. In part "4.2. Anatomy of a Body Filter", there's a piece of code like this: "And hook the buffer into a new chain link: ngx\_chain\_t added\_link; added\_link.buf = b;

---

<div class="post-metadata">

**Author:** ![ctasdemir](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/ed8c4c/32.png) [@ctasdemir](https://www.ruby-forum.com/u/ctasdemir)\
**Post date:** [March 14, 2011, 10:43am UTC](https://www.ruby-forum.com/t/question-on-evan-millers-tutorial-body-filter/204365/4 "2011-03-14T10:43:45Z")

</div>

Thanks for the answer. I’m trying the understand internals of nginx. I  
changed it to pointer but still i can’t manage to write end of buffer.  
Ok, i’ll keep trying 🙂

Coskun,

Posted at Nginx Forum:

> **[Re: Question on Evan Miller's tutorial - Body filter?](https://forum.nginx.org/read.php?2,181975,182749#msg-182749)**
>
> Hello, I'm going through Evan Miller's tutorial on Nginx module. In part "4.2. Anatomy of a Body Filter", there's a piece of code like this: "And hook the buffer into a new chain link: ngx\_chain\_t added\_link; added\_link.buf = b;
