Skip to content

Commit

Permalink
http: Refactored nxt_h1p_request_body_read()
Browse files Browse the repository at this point in the history
It's prepared for the subsequent patch.
  • Loading branch information
hongzhidao committed Jun 13, 2024
1 parent 3ec5174 commit 6ae156d
Showing 1 changed file with 16 additions and 16 deletions.
32 changes: 16 additions & 16 deletions src/nxt_h1proto.c
Original file line number Diff line number Diff line change
Expand Up @@ -901,23 +901,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);
Expand Down Expand Up @@ -946,8 +934,20 @@ 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 {
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;

body_rest = body_length;

in = h1p->conn->read;
Expand Down

0 comments on commit 6ae156d

Please sign in to comment.