Skip to content

Commit

Permalink
feat(headers): Add Access-Control-Expose-Headers
Browse files Browse the repository at this point in the history
Fix #673
  • Loading branch information
untitaker committed Nov 2, 2015
1 parent becced4 commit f783e99
Show file tree
Hide file tree
Showing 2 changed files with 62 additions and 0 deletions.
60 changes: 60 additions & 0 deletions src/header/common/access_control_expose_headers.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
use unicase::UniCase;

header! {
/// `Access-Control-Expose-Headers` header, part of
/// [CORS](http://www.w3.org/TR/cors/#access-control-expose-headers-response-header)
///
/// The Access-Control-Expose-Headers header indicates which headers are safe to expose to the
/// API of a CORS API specification.
///
/// # ABNF
/// ```plain
/// Access-Control-Expose-Headers = "Access-Control-Expose-Headers" ":" #field-name
/// ```
///
/// # Example values
/// * `ETag, Content-Length`
///
/// # Examples
/// ```
/// # extern crate hyper;
/// # extern crate unicase;
/// # fn main() {
/// // extern crate unicase;
///
/// use hyper::header::{Headers, AccessControlExposeHeaders};
/// use unicase::UniCase;
///
/// let mut headers = Headers::new();
/// headers.set(
/// AccessControlExposeHeaders(vec![
/// UniCase("etag".to_owned()),
/// UniCase("content-length".to_owned())
/// ])
/// );
/// # }
/// ```
/// ```
/// # extern crate hyper;
/// # extern crate unicase;
/// # fn main() {
/// // extern crate unicase;
///
/// use hyper::header::{Headers, AccessControlExposeHeaders};
/// use unicase::UniCase;
///
/// let mut headers = Headers::new();
/// headers.set(
/// AccessControlExposeHeaders(vec![
/// UniCase("etag".to_owned()),
/// UniCase("content-length".to_owned())
/// ])
/// );
/// # }
/// ```
(AccessControlExposeHeaders, "Access-Control-Expose-Headers") => (UniCase<String>)*

test_access_control_expose_headers {
test_header!(test1, vec![b"etag, content-length"]);
}
}
2 changes: 2 additions & 0 deletions src/header/common/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ pub use self::accept::Accept;
pub use self::access_control_allow_headers::AccessControlAllowHeaders;
pub use self::access_control_allow_methods::AccessControlAllowMethods;
pub use self::access_control_allow_origin::AccessControlAllowOrigin;
pub use self::access_control_expose_headers::AccessControlExposeHeaders;
pub use self::access_control_max_age::AccessControlMaxAge;
pub use self::access_control_request_headers::AccessControlRequestHeaders;
pub use self::access_control_request_method::AccessControlRequestMethod;
Expand Down Expand Up @@ -355,6 +356,7 @@ mod accept;
mod access_control_allow_headers;
mod access_control_allow_methods;
mod access_control_allow_origin;
mod access_control_expose_headers;
mod access_control_max_age;
mod access_control_request_headers;
mod access_control_request_method;
Expand Down

0 comments on commit f783e99

Please sign in to comment.