Merge pull request #162 from izderadicka/add_content_type_to_stream
Add content type to streams
This commit is contained in:
commit
c86e663f24
6 changed files with 61 additions and 7 deletions
|
|
@ -167,6 +167,13 @@ impl HttpApi {
|
|||
let mut output_headers = HeaderMap::new();
|
||||
output_headers.insert("Accept-Ranges", HeaderValue::from_static("bytes"));
|
||||
|
||||
if let Ok(mime) = state.torrent_file_mime_type(idx, file_id) {
|
||||
output_headers.insert(
|
||||
http::header::CONTENT_TYPE,
|
||||
HeaderValue::from_str(mime).context("bug - invalid MIME")?,
|
||||
);
|
||||
}
|
||||
|
||||
let range_header = headers.get(http::header::RANGE);
|
||||
trace!(torrent_id=idx, file_id=file_id, range=?range_header, "request for HTTP stream");
|
||||
|
||||
|
|
@ -199,12 +206,12 @@ impl HttpApi {
|
|||
))
|
||||
.context("bug")?,
|
||||
);
|
||||
} else {
|
||||
output_headers.insert(
|
||||
http::header::CONTENT_LENGTH,
|
||||
HeaderValue::from_str(&format!("{}", stream.len())).context("bug")?,
|
||||
);
|
||||
}
|
||||
} else {
|
||||
output_headers.insert(
|
||||
http::header::CONTENT_LENGTH,
|
||||
HeaderValue::from_str(&format!("{}", stream.len())).context("bug")?,
|
||||
);
|
||||
}
|
||||
|
||||
let s = tokio_util::io::ReaderStream::new(stream);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue