Refactor proxy and socket a bit

This commit is contained in:
2023-01-23 11:04:53 +01:00
parent d461ba6f29
commit 8b63d2cf32
2 changed files with 28 additions and 20 deletions

View File

@ -567,7 +567,7 @@ int proxy_init(proxy_ctx_t **proxy_ptr, http_req *req, http_res *res, http_statu
int proxy_send(proxy_ctx_t *proxy, sock *client, unsigned long len_to_send, int flags) {
char buffer[CHUNK_SIZE], buf[256], *ptr;
long ret = 0, len, snd_len;
long ret = 0, snd_len;
do {
snd_len = 0;
@ -593,10 +593,9 @@ int proxy_send(proxy_ctx_t *proxy, sock *client, unsigned long len_to_send, int
}
ptr = buffer;
long buf_len = ret;
len = sprintf(buf, "%lX\r\n", buf_len);
ret = 1;
if (flags & PROXY_CHUNKED) ret = sock_send_x(client, buf, len, 0);
if (flags & PROXY_CHUNKED) ret = sock_send_x(client, buf, sprintf(buf, "%lX\r\n", buf_len), 0);
if (ret <= 0) goto err;
ret = sock_send_x(client, ptr, buf_len, 0);