# (52) Empty reply from server

**URL:** <https://www.ruby-forum.com/t/52-empty-reply-from-server/244459>\
**Category:** NGINX\
**Created:** [April 14, 2016, 12:04pm UTC](https://www.ruby-forum.com/t/52-empty-reply-from-server/244459 "2016-04-14T12:04:56Z")\
**Posts on this page:** 6\
**Page:** 2

<div class="post-metadata">

**Author:** ![Pankaj\_Chaudhary](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/f04885/32.png) [@Pankaj\_Chaudhary](https://www.ruby-forum.com/u/Pankaj_Chaudhary)\
**Post date:** [May 5, 2016, 6:58am UTC](https://www.ruby-forum.com/t/52-empty-reply-from-server/244459/21 "2016-05-05T06:58:04Z")

</div>

Hi,

thank you!  
My module is basically for resource protection.  
I have already running my module on other servers also.  
My module follow below steps.  
-Generate cookie and write in response header  
-read from header when cookie is needed

IIS have API setheader() to set header and getheader() to get header.  
Apache have apr\_table\_get() to get value from header and apr\_table\_set()  
to  
set the value in header.

Do we have similar APIs in nginx?

How i can achieve same kind of behavior in nginx?

Regards,  
Pankaj

On Wed, May 4, 2016 at 7:16 PM, Valentin V. Bartenev [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

---

<div class="post-metadata">

**Author:** ![Pankaj\_Chaudhary](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/f04885/32.png) [@Pankaj\_Chaudhary](https://www.ruby-forum.com/u/Pankaj_Chaudhary)\
**Post date:** [May 2, 2016, 9:12am UTC](https://www.ruby-forum.com/t/52-empty-reply-from-server/244459/22 "2016-05-02T09:12:29Z")

</div>

* * *

nginx mailing list  
removed\_email\_address@domain.invalid  
[http://mailman.nginx.org/mailman/listinfo/nginx](http://mailman.nginx.org/mailman/listinfo/nginx)

---

<div class="post-metadata">

**Author:** ![Pankaj\_Chaudhary](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/f04885/32.png) [@Pankaj\_Chaudhary](https://www.ruby-forum.com/u/Pankaj_Chaudhary)\
**Post date:** [May 5, 2016, 4:03pm UTC](https://www.ruby-forum.com/t/52-empty-reply-from-server/244459/23 "2016-05-05T16:03:04Z")

</div>

On Thursday 05 May 2016 10:27:46 Pankaj Chaudhary wrote:

> Apache have apr\_table\_get() to get value from header and apr\_table\_set() to  
> set the value in header.
> 
> Do we have similar APIs in nginx?
> 
> How i can achieve same kind of behavior in nginx?

[..]

If you want to set a response header, then should look to the  
source of ngx\_http\_headers\_module, which is responsible for  
adding headers to output.

For reading cookies you can look to the $http\_cookie variable  
implementation.

Please, use “grep” for search and read the code.

You can implement your module a way easier if you just provide  
a directive, that can use the variable to read some value, and  
adds a variable to set the value.

Then it can be used like this:

protection\_value $cookie\_key;

add\_header Set-Cookie “key=$protection\_value”;

You can also check the ngx\_http\_secure\_link\_module:

> **[Module ngx\_http\_secure\_link\_module](http://nginx.org/en/docs/http/ngx_http_secure_link_module.html)**

wbr, Valentin V. Bartenev

---

<div class="post-metadata">

**Author:** ![Pankaj\_Chaudhary](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/f04885/32.png) [@Pankaj\_Chaudhary](https://www.ruby-forum.com/u/Pankaj_Chaudhary)\
**Post date:** [May 9, 2016, 11:05am UTC](https://www.ruby-forum.com/t/52-empty-reply-from-server/244459/24 "2016-05-09T11:05:00Z")

</div>

Hi,

Its means nginx do not have any API as other server having to set  
header  
and get header ? very strange …

I need to write my own module to read and write cookies values?  
My module is in written in C programming language.

On Thu, May 5, 2016 at 7:32 PM, Valentin V. Bartenev [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

---

<div class="post-metadata">

**Author:** ![Pankaj\_Chaudhary](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/f04885/32.png) [@Pankaj\_Chaudhary](https://www.ruby-forum.com/u/Pankaj_Chaudhary)\
**Post date:** [May 11, 2016, 8:49am UTC](https://www.ruby-forum.com/t/52-empty-reply-from-server/244459/25 "2016-05-11T08:49:37Z")

</div>

> You can read the headers\_in data structure, and write the headers\_out  
> data structure, as the examples show.

I was able to write in headers\_out data structure as i have shown my  
code  
already but i was not able to read from headers\_in structure that is  
problem i am facing.  
I am looking solution for this only.  
I have followed the given example mentioned in below link.

> **[F5 NGINX: Built for cloud-native apps. Ready for AI traffic.](https://www.f5.com/products/nginx)**
>
> Deliver modern applications with NGINX. Explore high-performance load balancing, API gateways, and web server solutions trusted by top global enterprises.

i am not able to understand why this is happening.  
but if i can see headers\_in structure have the value which i am trying  
to  
read.

---

<div class="post-metadata">

**Author:** ![Pankaj\_Chaudhary](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/f04885/32.png) [@Pankaj\_Chaudhary](https://www.ruby-forum.com/u/Pankaj_Chaudhary)\
**Post date:** [May 10, 2016, 10:47pm UTC](https://www.ruby-forum.com/t/52-empty-reply-from-server/244459/26 "2016-05-10T22:47:22Z")

</div>

On Mon, May 09, 2016 at 02:34:13PM +0530, Pankaj Chaudhary wrote:

Hi there,

> Its means nginx do not have any API as other server having to set header  
> and get header ? very strange …

You are correct.

You’ve already shown code where you read headers sent by the client,  
and write headers sent to the client.

It is very strange.

> I need to write my own module to read and write cookies values?  
> My module is in written in C programming language.

If you want to write a module in C, then your code will be in C.

You can read the headers\_in data structure, and write the headers\_out  
data structure, as the examples show.

Good luck with it,

## f

Francis D. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

[Previous page](https://www.ruby-forum.com/t/52-empty-reply-from-server/244459.md?page=1)
