diff options
author | Zhidao HONG <z.hong@f5.com> | 2024-06-11 10:32:34 +0800 |
---|---|---|
committer | Zhidao HONG <z.hong@f5.com> | 2024-06-20 10:39:17 +0800 |
commit | f80a36a60d61ecd5621d33af37aed35fd074f982 (patch) | |
tree | ff6a2841419928d7bcaab3819511f9959980e9b6 /src/nxt_h1proto.c | |
parent | 999d274837273e354efc05075c0b012b81902ef1 (diff) | |
download | unit-f80a36a60d61ecd5621d33af37aed35fd074f982.tar.gz unit-f80a36a60d61ecd5621d33af37aed35fd074f982.tar.bz2 |
http: Refactored nxt_h1p_request_body_read()
It's prepared for the subsequent patch.
Reviewed-by: Andrew Clayton <a.clayton@nginx.com>
Diffstat (limited to '')
-rw-r--r-- | src/nxt_h1proto.c | 32 |
1 files changed, 15 insertions, 17 deletions
diff --git a/src/nxt_h1proto.c b/src/nxt_h1proto.c index 54fe7776..fd184eb5 100644 --- a/src/nxt_h1proto.c +++ b/src/nxt_h1proto.c @@ -856,7 +856,6 @@ nxt_h1p_request_body_read(nxt_task_t *task, nxt_http_request_t *r) { size_t size, body_length, body_buffer_size, body_rest; ssize_t res; - nxt_str_t *tmp_path, tmp_name; nxt_buf_t *in, *b; nxt_conn_t *c; nxt_h1proto_t *h1p; @@ -894,6 +893,8 @@ nxt_h1p_request_body_read(nxt_task_t *task, nxt_http_request_t *r) body_length); if (body_length > body_buffer_size) { + nxt_str_t *tmp_path, tmp_name; + tmp_path = &r->conf->socket_conf->body_temp_path; tmp_name.length = tmp_path->length + tmp_name_pattern.length; @@ -901,23 +902,11 @@ nxt_h1p_request_body_read(nxt_task_t *task, nxt_http_request_t *r) b = nxt_buf_file_alloc(r->mem_pool, body_buffer_size + sizeof(nxt_file_t) + tmp_name.length + 1, 0); + if (nxt_slow_path(b == NULL)) { + status = NXT_HTTP_INTERNAL_SERVER_ERROR; + goto error; + } - } else { - /* This initialization required for CentOS 6, gcc 4.4.7. */ - tmp_path = NULL; - tmp_name.length = 0; - - b = nxt_buf_mem_alloc(r->mem_pool, body_buffer_size, 0); - } - - if (nxt_slow_path(b == NULL)) { - status = NXT_HTTP_INTERNAL_SERVER_ERROR; - goto error; - } - - r->body = b; - - if (body_length > body_buffer_size) { tmp_name.start = nxt_pointer_to(b->mem.start, sizeof(nxt_file_t)); memcpy(tmp_name.start, tmp_path->start, tmp_path->length); @@ -946,8 +935,17 @@ nxt_h1p_request_body_read(nxt_task_t *task, nxt_http_request_t *r) &tmp_name, b->file->fd); unlink((char *) tmp_name.start); + + } else { + b = nxt_buf_mem_alloc(r->mem_pool, body_buffer_size, 0); + if (nxt_slow_path(b == NULL)) { + status = NXT_HTTP_INTERNAL_SERVER_ERROR; + goto error; + } } + r->body = b; + body_rest = body_length; in = h1p->conn->read; |