Tests: fixed incorrect pointer assignment.

If we don't update the pointer before copying the request body, then we
get the behavior shown below.  After this patch, "foo\n" is rightly
appended at the end of the response body.

Request:

"GET / HTTP/1.1\r\nHost: _\nContent-Length: 4\n\nfoo\n"

Response body:

"""
Hello world!
foo
est data:
  Method: GET
  Protocol: HTTP/1.1
  Remote addr: 127.0.0.1
  Local addr: 127.0.0.1
  Target: /
  Path: /
  Fields:
    Host: _
    Content-Length: 4
  Body:
"""

Fixes: 1bb22d1e92 ("Unit application library.")
Reviewed-by: Andrew Clayton <a.clayton@nginx.com>
Signed-off-by: Alejandro Colomar <alx@nginx.com>
This commit is contained in:
Alejandro Colomar
2023-05-22 02:37:01 +02:00
parent 71f8c58f7f
commit 47cdfb6f30

View File

@@ -257,8 +257,8 @@ greeting_app_request_handler(nxt_unit_request_info_t *req)
if (r->content_length > 0) {
p = copy(p, BODY, nxt_length(BODY));
res = nxt_unit_request_read(req, buf->free, buf->end - buf->free);
buf->free += res;
res = nxt_unit_request_read(req, p, buf->end - p);
p += res;
}