understanding ngx_str_t structure

astre nginx-forum at forum.nginx.org
Fri Sep 27 09:44:09 UTC 2019


Hi,

I trying to print the requested URL path. For that I came across the "uri"
member which is of type ngx_str_t) under ngx_http_request_t structure. When
I print the "uri" using ngx_log_debug1 (ngx_log_debug1(NGX_LOG_DEBUG_HTTP,
log, 0, "%s", r->uri.data)) I see some extra data printed. 

For eg. when http://localhost/test is requested, "/test HTTP/1.1 Host" is
printed. 

In my understanding "uri.data" should have contained only "/test". The
"uri.len" correctly shows the length as 5. The "data" member is unsigned
char *data so while extracting the actual string do we need to consider the
length in ngx_str_t ?

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



More information about the nginx mailing list