Welcome! Log In Create A New Profile

Advanced

Help with reading response from upstream u->buffer

Ashish S
April 25, 2012 08:24PM
Hi there,

In my module which uses upstream to talk to a backend, i do the
following in the response processing method (u->process_header)

{
ngx_http_upstream_t * u = r->upstream;
size_t myResponseLength = (u->buffer.last - u->buffer.pos);
size_t origUpstreamResponseLength = (u->buffer.last - u->buffer.start);
std::string myResponseString ((u_char *) u->buffer.pos, myResponseLength);

ngx_log_error(NGX_LOG_ERR, r->connection->log, 0, "u->length is %d
and Original Upstream response length is %d and myResponseLength is
%d", u->length, origUpstreamResponseLength, myResponseLength);

....
}

My actual response length from upstream is ~16kb, while i get
u->length printed as 0, Original upstream response length and
myResponseLength printed as 1448 bytes. I also see in nginx debug
logs, "Transfer-Encoding: chunked". Is the difference in length
printed, because of this encoding? Is there a way to disable chunked
transfer, so that i can get the entire response in one go (into my
string), as shown in code? If not, what is the right method to read
the entire response from upstream buffer into a temporary string (so
that i can do further parsing)?

Thanks,
Ashish

_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx
Subject Author Posted

Help with reading response from upstream u->buffer

Ashish S April 25, 2012 08:24PM

Re: Help with reading response from upstream u->buffer

Ashish S April 25, 2012 09:02PM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 310
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready