Skip to content

Commit

The runner's broker test reads the relayed answer's body as chunks: the proxy passes the body on as it reads it, so "got " and "hello" can arrive as two chunks, and looking for "got hello" in the raw bytes failed CI #166 on a correct answer.

syntaqxcommitted Parent75c6704Browse files
1 file+4−10/1 viewed
+4−1
10261026 let answer = read_all(&mut tls);
10271027 assert!(answer.starts_with("HTTP/1.1 201 Created\r\n"), "{answer}");
10281028 assert!(answer.contains("x-from: upstream\r\n") && answer.contains("transfer-encoding: chunked"), "{answer}");
1029− assert!(answer.contains("got hello"), "{answer}");
1029+ // The body may come in more than one chunk, so it is read as chunks.
1030+ let mut chunks = BufReader::new(answer.as_bytes());
1031+ let head = read_head(&mut chunks).unwrap().unwrap();
1032+ assert_eq!(read_body(&mut chunks, &head).unwrap(), b"got hello", "{answer}");
10301033
10311034 let (headers, body) = heard.recv().unwrap();
10321035 assert_eq!(body, b"hello");