# Add\_header for 206?

**URL:** <https://www.ruby-forum.com/t/add-header-for-206/214250>\
**Category:** NGINX\
**Created:** [November 25, 2011, 11:36pm UTC](https://www.ruby-forum.com/t/add-header-for-206/214250 "2011-11-25T23:36:45Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![luislavena](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/0ea827/32.png) [@luislavena](https://www.ruby-forum.com/u/luislavena)\
**Post date:** [November 25, 2011, 11:36pm UTC](https://www.ruby-forum.com/t/add-header-for-206/214250/1 "2011-11-25T23:36:45Z")

</div>

Hi!

Quote from wiki:

Add\_header  
“Adds headers to the HTTP response when the response code is equal to  
200, 204, 301, 302 or 304.”

Any reason we missing 206?

---

<div class="post-metadata">

**Author:** ![rkoskela](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/ce73a5/32.png) [@rkoskela](https://www.ruby-forum.com/u/rkoskela)\
**Post date:** [November 27, 2011, 12:53am UTC](https://www.ruby-forum.com/t/add-header-for-206/214250/2 "2011-11-27T00:53:39Z")

</div>

Hello!

On Fri, Nov 25, 2011 at 10:36:21PM +0000, Richard K. wrote:

> Quote from wiki:
> 
> Add\_header  
> “Adds headers to the HTTP response when the response code is equal to 200, 204,  
> 301, 302 or 304.”
> 
> Any reason we missing 206?

I tend to think it was just forgotten, probably because nginx’s  
own range filter (which will generate 206 from 200) only appears  
later in headers filter chain. Therefore nginx’s own 206 will  
have headers added via add\_header, while proxied 206 responses  
won’t.

Trivial patch:

diff --git a/src/http/modules/ngx\_http\_headers\_filter\_module.c  
b/src/http/modules/ngx\_http\_headers\_filter\_module.c  
— a/src/http/modules/ngx\_http\_headers\_filter\_module.c  
+++ b/src/http/modules/ngx\_http\_headers\_filter\_module.c  
@@ -145,6 +145,7 @@ ngx\_http\_headers\_filter(ngx\_http\_request  
|| r != r-\>main  
|| (r-\>headers\_out.status != NGX\_HTTP\_OK  
&& r-\>headers\_out.status != NGX\_HTTP\_NO\_CONTENT

- 

```
       && r->headers_out.status != NGX_HTTP_PARTIAL_CONTENT
       && r->headers_out.status != NGX_HTTP_MOVED_PERMANENTLY
       && r->headers_out.status != NGX_HTTP_MOVED_TEMPORARILY
       && r->headers_out.status != NGX_HTTP_NOT_MODIFIED))

```

Maxim D.
