-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Closed
Labels
A-headersArea: headers.Area: headers.C-bugCategory: bug. Something is wrong. This is bad!Category: bug. Something is wrong. This is bad!E-easyEffort: easy. A task that would be a great starting point for a new contributor.Effort: easy. A task that would be a great starting point for a new contributor.
Description
I'm not sure what happened here:
extern crate hyper;
use hyper::header::Headers;
use hyper::header::{ContentLength, ContentType};
use hyper::http::RawStatus;
use hyper::method::Method;
use hyper::mime::{Attr as MimeAttr, Value};
fn main() {
let mut x = Headers::new();
x.set_raw("Content-Type", vec!["text/plain;charset=shift-jis".bytes().collect()]);
println!("old: {:?}", x); // charset is shift-jis
if let Some(old_ct) = x.get_mut::<ContentType>() {
println!("old old_ct: {:?}", old_ct); // still shift-jis
let mut new_ct = old_ct.clone();
for param in (new_ct.0).2.iter_mut() {
if param.0 == MimeAttr::Charset {
println!("old param {:?}", param); // shift-jis
*param = (MimeAttr::Charset, Value::Ext("hi".into()));
println!("new param {:?}", param); // hi
}
}
*old_ct = new_ct;
println!("new old_ct: {:?}", old_ct); // hi
}
// at this stage I'd expect the header to have changed. But it hasn't.
println!("new get: {:?}", x.get::<ContentType>()); // hi
println!("new get raw: {:?}", x.get_raw("content-type")); // shift-jis again??
println!("new: {:?}", x); // shift-jis again??
}Metadata
Metadata
Assignees
Labels
A-headersArea: headers.Area: headers.C-bugCategory: bug. Something is wrong. This is bad!Category: bug. Something is wrong. This is bad!E-easyEffort: easy. A task that would be a great starting point for a new contributor.Effort: easy. A task that would be a great starting point for a new contributor.