cloudflare/pingora

busy loop when deal with chunked body

Closed this issue · 2 comments

Describe the bug

client send partial chunk head then close the socket,
forward work thread enter the busy loop

Pingora info

Please include the following information about your environment:

Pingora version: master
Rust version: cargo 1.82.0
Operating system version: mac

Steps to reproduce

use std::io::{Write, Read};
use std::net::TcpStream;
use std::str;
use std::thread::sleep;
use std::time::Duration;

fn main() {

let server_address = "localhost:8888"; 
let mut stream = TcpStream::connect(server_address).expect("Could not connect to server");

// 构建 HTTP chunked 请求
let request_line = "POST /path HTTP/1.1\r\n"; // 修改为你的请求路径
let headers = "Host: test.com\r\nTransfer-Encoding: chunked\r\n\r\n"; // 注意 Transfer-Encoding

// 发送请求头
stream.write_all(request_line.as_bytes()).expect("Failed to write request line");
stream.write_all(headers.as_bytes()).expect("Failed to write headers");

// 发送第一个 chunk
let chunk1 = "4\r"; // 表示接下来的数据长度为 4 字节
stream.write_all(chunk1.as_bytes()).expect("Failed to write chunk size");

}

the code in pingora-core/src/protocols/http/v1/body.rs line:303
if existing_buf_end == 0 has not in effect with line:293 when new_bytes is 0
so the connection prematurely closed event been ingored

Thank you for reporting this issue to us. We've merged a fix in a3230bb.