# Read request\_body of a POST request

**URL:** <https://www.ruby-forum.com/t/read-request-body-of-a-post-request/201778>\
**Category:** NGINX\
**Created:** [January 14, 2011, 11:54am UTC](https://www.ruby-forum.com/t/read-request-body-of-a-post-request/201778 "2011-01-14T11:54:10Z")\
**Posts on this page:** 3\
**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:** [January 14, 2011, 11:54am UTC](https://www.ruby-forum.com/t/read-request-body-of-a-post-request/201778/1 "2011-01-14T11:54:10Z")

</div>

Hello,  
I’m working on a modul, that should get a POST request with XML-RPC data  
and then send a response.  
I have problem with getting the request\_body. It’s no problem to read  
headers and find Content-Type: text/xml. But when I want to read the  
request\_body there is no one. I use the same code as the function for  
reading request\_body in ngx\_http\_variable.  
My modul is a handler (something like circe\_gif module). When my module  
is filter and the request is passed to the proxy module I can read the  
request body in my filter module.  
Is it possible to read headers and the request\_body and then generate a  
response by handlers?

Thank you,  
Michal

Posted at Nginx Forum:

> **[Read request\_body of a POST request](https://forum.nginx.org/read.php?2,166169,166169#msg-166169)**
>
> Hello, I'm working on a modul, that should get a POST request with XML-RPC data and then send a response. I have problem with getting the request\_body. It's no problem to read headers and find Content-Type: text/xml. But when I want to read the...

---

<div class="post-metadata">

**Author:** ![michalkraus](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/aeb1de/32.png) [@michalkraus](https://www.ruby-forum.com/u/michalkraus)\
**Post date:** [January 14, 2011, 1:03pm UTC](https://www.ruby-forum.com/t/read-request-body-of-a-post-request/201778/2 "2011-01-14T13:03:50Z")

</div>

Hello!

On Fri, Jan 14, 2011 at 05:52:57AM -0500, michalkraus wrote:

> Is it possible to read headers and the request\_body and then generate a  
> response by handlers?

Yes. You have to use ngx\_http\_read\_client\_request\_body() function  
and generate response in post\_handler callback (the one you’ve  
passed to function).

See e.g. proxy or dav modules for examples.

Maxim D.

---

<div class="post-metadata">

**Author:** ![michalkraus](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/aeb1de/32.png) [@michalkraus](https://www.ruby-forum.com/u/michalkraus)\
**Post date:** [January 14, 2011, 2:33pm UTC](https://www.ruby-forum.com/t/read-request-body-of-a-post-request/201778/3 "2011-01-14T14:33:37Z")

</div>

After using ngx\_http\_read\_client\_request\_body() function, my handler  
works correctly.

Thanks, Michal

Posted at Nginx Forum:

> **[Re: Read request\_body of a POST request](https://forum.nginx.org/read.php?2,166169,166224#msg-166224)**
>
> Hello, I'm working on a modul, that should get a POST request with XML-RPC data and then send a response. I have problem with getting the request\_body. It's no problem to read headers and find Content-Type: text/xml. But when I want to read the...
