Files
hyper/src/header/common/access_control/request_method.rs
Pyfisch 8d0e5bc302 refactor(headers): export all headers and utils directly under header
Currently headers are exported at many places. For example you can access
`Transfer-Encoding` header at `header`, `header::common` and
`header::common::transfer_encoding`. Per discussion on IRC with
@seanmonstar and @reem, all contents of headers will be exposed at `header`
directly. Parsing utilities will be exposed at `header::parsing`. Header
macros can now be used from other crates.

This breaks much code using headers. It should use everything it needs
directly from `header::`, encodings are exposed at `header::Encoding::`,
connection options are exposed at `header::ConnectionOption`.
2015-01-20 13:04:42 +01:00

33 lines
1.0 KiB
Rust

use std::fmt;
use header;
use method::Method;
/// The `Access-Control-Request-Method` request header,
/// part of [CORS](http://www.w3.org/TR/cors/).
///
/// > The `Access-Control-Request-Method` header indicates which method will be
/// > used in the actual request as part of the preflight request.
///
/// Spec: www.w3.org/TR/cors/#access-control-request-method-request-header
#[derive(Clone, PartialEq, Show)]
pub struct AccessControlRequestMethod(pub Method);
impl header::Header for AccessControlRequestMethod {
#[inline]
fn header_name(_: Option<AccessControlRequestMethod>) -> &'static str {
"Access-Control-Request-Method"
}
fn parse_header(raw: &[Vec<u8>]) -> Option<AccessControlRequestMethod> {
header::parsing::from_one_raw_str(raw).map(AccessControlRequestMethod)
}
}
impl header::HeaderFormat for AccessControlRequestMethod {
fn fmt_header(&self, f: &mut fmt::Formatter) -> fmt::Result {
let AccessControlRequestMethod(ref method) = *self;
write!(f, "{}", method)
}
}