Update mime

This commit is contained in:
philippeitis
2022-10-18 16:25:08 -07:00
parent fb884e193a
commit 616b324a77
4 changed files with 7 additions and 14 deletions

View File

@@ -16,7 +16,7 @@ doctest = false
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
mime = "^ 0.2.0"
mime = "^ 0.3"
serde = { version = "^ 1.0", features = ["derive"] }
serde_with = "2.0.1"
serde_json = "^ 1.0"

View File

@@ -17,7 +17,7 @@ use hyper::header::{HeaderMap, AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, USER
use hyper::Method;
use hyper::StatusCode;
use mime::{Attr, Mime, SubLevel, TopLevel, Value};
use mime::Mime;
use serde_json as json;
@@ -358,7 +358,7 @@ impl<'a> MultiPartReader<'a> {
let mut headers = HeaderMap::new();
headers.insert(
CONTENT_TYPE,
hyper::header::HeaderValue::from_str(&format!("{}", mime_type)).unwrap(),
hyper::header::HeaderValue::from_str(&mime_type.to_string()).unwrap(),
);
headers.insert(CONTENT_LENGTH, size.into());
self.raw_parts.push((headers, reader));
@@ -368,14 +368,8 @@ impl<'a> MultiPartReader<'a> {
/// Returns the mime-type representing our multi-part message.
/// Use it with the ContentType header.
pub fn mime_type(&self) -> Mime {
Mime(
TopLevel::Multipart,
SubLevel::Ext("related".to_string()),
vec![(
Attr::Ext("boundary".to_string()),
Value::Ext(BOUNDARY.to_string()),
)],
)
Mime::from_str(&format!("multipart/related;boundary={}", BOUNDARY))
.expect("valid mimetype")
}
/// Returns true if we are totally used

View File

@@ -26,11 +26,10 @@ path = "src/main.rs"
% endif
[dependencies]
## TODO: temporary, remove when yup-oauth2 is optional
anyhow = "^ 1.0"
hyper-rustls = "0.23.0"
## Must match the one hyper uses, otherwise there are duplicate similarly named `Mime` structs
mime = "^ 0.2.0"
mime = "^ 0.3.0"
serde = { version = "^ 1.0", features = ["derive"] }
serde_json = "^ 1.0"
itertools = "^ 0.10"

View File

@@ -689,7 +689,7 @@ else {
let url = url::Url::parse_with_params(&url, params).unwrap();
% if request_value:
let mut json_mime_type: mime::Mime = "application/json".parse().unwrap();
let mut json_mime_type = mime::APPLICATION_JSON;
let mut request_value_reader =
{
let mut value = json::value::to_value(&self.${property(REQUEST_VALUE_PROPERTY_NAME)}).expect("serde to work");