use hyper_0_10::header::{ContentType, Headers};
use mime_0_2::Mime;
pub fn generate_boundary() -> Vec<u8> {
let mut boundary = mime_multipart::generate_boundary();
for b in boundary.iter_mut() {
if *b == b'/' {
*b = b'.';
}
}
boundary
}
pub fn create_multipart_headers(
content_type: Option<&hyper::header::HeaderValue>,
) -> Result<Headers, String> {
let content_type = content_type
.ok_or_else(|| "Missing Content-Type header".to_string())?
.to_str()
.map_err(|e| format!("Couldn't read Content-Type header value: {}", e))?
.parse::<Mime>()
.map_err(|_e| "Couldn't parse Content-Type header value".to_string())?;
let mut multipart_headers = Headers::new();
multipart_headers.set(ContentType(content_type));
Ok(multipart_headers)
}