1
0
Fork 0
mirror of https://github.com/actix/actix-web.git synced 2024-06-02 13:29:24 +00:00
actix-web/src/http/header/accept_charset.rs

62 lines
2 KiB
Rust
Raw Normal View History

use super::{Charset, QualityItem, ACCEPT_CHARSET};
2019-02-07 21:24:24 +00:00
2021-06-25 11:25:50 +00:00
crate::http::header::common_header! {
2019-02-07 21:24:24 +00:00
/// `Accept-Charset` header, defined in
/// [RFC 7231 §5.3.3](https://datatracker.ietf.org/doc/html/rfc7231#section-5.3.3)
2019-02-07 21:24:24 +00:00
///
/// The `Accept-Charset` header field can be sent by a user agent to
/// indicate what charsets are acceptable in textual response content.
/// This field allows user agents capable of understanding more
/// comprehensive or special-purpose charsets to signal that capability
/// to an origin server that is capable of representing information in
/// those charsets.
///
/// # ABNF
2021-12-02 15:25:39 +00:00
/// ```plain
2019-02-07 21:24:24 +00:00
/// Accept-Charset = 1#( ( charset / "*" ) [ weight ] )
/// ```
///
/// # Example Values
2019-02-07 21:24:24 +00:00
/// * `iso-8859-5, unicode-1-1;q=0.8`
///
/// # Examples
2021-01-15 02:11:10 +00:00
/// ```
/// use actix_web::HttpResponse;
/// use actix_web::http::header::{AcceptCharset, Charset, qitem};
2019-02-07 21:24:24 +00:00
///
/// let mut builder = HttpResponse::Ok();
2021-01-15 02:11:10 +00:00
/// builder.insert_header(
2019-02-07 21:24:24 +00:00
/// AcceptCharset(vec![qitem(Charset::Us_Ascii)])
/// );
/// ```
2021-01-15 02:11:10 +00:00
///
/// ```
/// use actix_web::HttpResponse;
/// use actix_web::http::header::{AcceptCharset, Charset, q, QualityItem};
2019-02-07 21:24:24 +00:00
///
/// let mut builder = HttpResponse::Ok();
2021-01-15 02:11:10 +00:00
/// builder.insert_header(
2019-02-07 21:24:24 +00:00
/// AcceptCharset(vec![
/// QualityItem::new(Charset::Us_Ascii, q(900)),
/// QualityItem::new(Charset::Iso_8859_10, q(200)),
/// ])
/// );
/// ```
2021-01-15 02:11:10 +00:00
///
/// ```
/// use actix_web::HttpResponse;
/// use actix_web::http::header::{AcceptCharset, Charset, qitem};
2019-02-07 21:24:24 +00:00
///
/// let mut builder = HttpResponse::Ok();
2021-01-15 02:11:10 +00:00
/// builder.insert_header(
2019-02-07 21:24:24 +00:00
/// AcceptCharset(vec![qitem(Charset::Ext("utf-8".to_owned()))])
/// );
/// ```
(AcceptCharset, ACCEPT_CHARSET) => (QualityItem<Charset>)+
test_parse_and_format {
2020-02-24 22:46:03 +00:00
// Test case from RFC
2021-06-25 11:25:50 +00:00
crate::http::header::common_header_test!(test1, vec![b"iso-8859-5, unicode-1-1;q=0.8"]);
2019-02-07 21:24:24 +00:00
}
}