summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorAlejandro Colomar <alx@nginx.com>2023-05-22 02:37:01 +0200
committerAlejandro Colomar <alx@nginx.com>2023-05-25 11:27:35 +0200
commit47cdfb6f30f7d56bffb806cc860e20806ea62f50 (patch)
treec76dc3197e9e388b246c98cb6b164c443108506f
parent71f8c58f7f4fc7f65d4ef5b6f8d30686ad9fd765 (diff)
downloadunit-47cdfb6f30f7d56bffb806cc860e20806ea62f50.tar.gz
unit-47cdfb6f30f7d56bffb806cc860e20806ea62f50.tar.bz2
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: 1bb22d1e922c ("Unit application library.") Reviewed-by: Andrew Clayton <a.clayton@nginx.com> Signed-off-by: Alejandro Colomar <alx@nginx.com>
-rw-r--r--src/test/nxt_unit_app_test.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/test/nxt_unit_app_test.c b/src/test/nxt_unit_app_test.c
index d83bd83a..5dcebe18 100644
--- a/src/test/nxt_unit_app_test.c
+++ b/src/test/nxt_unit_app_test.c
@@ -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;
}