identifying last request on a tcp connection.

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

identifying last request on a tcp connection.

wld75
I've been trying to identify the last HTTP request from a buffer of 10
requests sent on a TCP connection in nginx. I've tried to use the header_in
field in the ngx_http_request_t by checking if the pos field for the
header_in is equal to the last field. This condition holds true twice, once
on the first request and then on the last request. My program intends to
break out once the last request is identified and hence, has been breaking
after encountering the first request because of this check.

Can someone help me identify the problem with my approach and point to the
right solution? Thanks!

Posted at Nginx Forum: https://forum.nginx.org/read.php?2,281287,281287#msg-281287

_______________________________________________
nginx mailing list
[hidden email]
http://mailman.nginx.org/mailman/listinfo/nginx
Reply | Threaded
Open this post in threaded view
|

Re: identifying last request on a tcp connection.

Maxim Dounin
Hello!

On Wed, Sep 19, 2018 at 02:19:53AM -0400, winger7 wrote:

> I've been trying to identify the last HTTP request from a buffer of 10
> requests sent on a TCP connection in nginx. I've tried to use the header_in
> field in the ngx_http_request_t by checking if the pos field for the
> header_in is equal to the last field. This condition holds true twice, once
> on the first request and then on the last request. My program intends to
> break out once the last request is identified and hence, has been breaking
> after encountering the first request because of this check.
>
> Can someone help me identify the problem with my approach and point to the
> right solution? Thanks!

Looking into r->header_in is not a right thing to do.  It is an
internal field used by nginx request parsing.  Its content may be
different depending on various factors, including buffer sizes
configured, TCP connection timing details, and so on.  Not to
mention that contents of r->header_in will be mostly meaningless
when using HTTP/2.

If you want to identify 10th request on a connection, consider
using the r->connection->requests field instead.  It is also
available in nginx configuration as the $connection_requests
variable, see http://nginx.org/r/$connection_requests.

--
Maxim Dounin
http://mdounin.ru/
_______________________________________________
nginx mailing list
[hidden email]
http://mailman.nginx.org/mailman/listinfo/nginx