Welcome! Log In Create A New Profile


How to set a request body

Mirko Dziadzka
August 31, 2010 06:02AM

I'm still trying to create a POST sub-request. I'm stuck in creating the
correct body of the request. Here is my current (non working) code:

// submit data in a POST request
res = ngx_http_subrequest(r, uri, NULL , &sr, psr, flags);

sr->method = NGX_HTTP_POST;
sr->method_name.data = (u_char *)"POST ";
sr->method_name.len = 4;

// set request body
sr->request_body = ngx_pcalloc(r->pool,sizeof(ngx_http_request_body_t));
sr->request_body->buf = ngx_pcalloc(r->pool, sizeof(ngx_buf_t));

// args is an ngx_str_t with the body
sr->request_body->buf->start = args->data;
sr->request_body->buf->end = args->data + args->len;
sr->request_body->buf->pos = sr->request_body->buf->start;
sr->request_body->buf->last = sr->request_body->buf->end;
sr->request_body_in_single_buf = 1;

// set header, content-type and content-length

The request is send to a local uri which is then forwarded via
proxy_pass to another server.

On the network, I see only the header:

POST /decide.cgi HTTP/1.0
Connection: close
Content-Type: application/x-www-form-urlencoded
Content-Length: 1217

Can someone please point me to working example code or tell me what I'm
missing here?

nginx-devel mailing list
Subject Author Views Posted

How to set a request body

Mirko Dziadzka 2779 August 31, 2010 06:02AM

Sorry, you do not have permission to post/reply in this forum.

Online Users

Guests: 93
Record Number of Users: 6 on February 13, 2018
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready