Skip to content

Commit cd9a7de

Browse files
committed
Discard http headers from stream
1 parent 440766a commit cd9a7de

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

src/decode.rs

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use std::{
2-
io::Write,
2+
io::{BufRead, BufReader, Write},
33
mem,
44
net::{Ipv4Addr, TcpStream},
55
sync::{Arc, Mutex},
@@ -372,6 +372,20 @@ pub fn make_decoder(
372372

373373
stream_in.send(PlayerMsg::Connected).ok();
374374

375+
let mut data_stream = BufReader::new(data_stream);
376+
377+
// Read until we encounter the end of headers (a blank line: "\r\n\r\n")
378+
{
379+
let mut line = String::new();
380+
loop {
381+
line.clear();
382+
let bytes_read = data_stream.read_line(&mut line)?;
383+
if bytes_read == 0 || line == "\r\n" {
384+
break;
385+
}
386+
}
387+
}
388+
375389
let mss = MediaSourceStream::new(
376390
Box::new(ReadOnlySource::new(SlimBuffer::with_capacity(
377391
threshold as usize * 1024,

0 commit comments

Comments
 (0)