Trait pact_models::http_parts::HttpPart [−][src]
pub trait HttpPart {}Show methods
fn headers(&self) -> &Option<HashMap<String, Vec<String>>>; fn headers_mut(&mut self) -> &mut HashMap<String, Vec<String>>; fn body(&self) -> &OptionalBody; fn matching_rules(&self) -> &MatchingRules; fn generators(&self) -> &Generators; fn lookup_content_type(&self) -> Option<String>; fn detect_content_type(&self) -> Option<ContentType> { ... } fn content_type(&self) -> Option<ContentType> { ... } fn has_header(&self, header_name: &str) -> bool { ... } fn lookup_header_value(&self, header_name: &str) -> Option<String> { ... } fn has_text_body(&self) -> bool { ... } fn add_header(&mut self, key: &str, val: Vec<&str>) { ... } fn build_generators(
&self,
category: &GeneratorCategory
) -> HashMap<String, Generator> { ... }
Expand description
Trait to specify an HTTP part of an interaction. It encapsulates the shared parts of a request and response.
Required methods
Returns the headers of the HTTP part.
Returns the headers of the HTTP part in a mutable form.
fn body(&self) -> &OptionalBody
fn body(&self) -> &OptionalBody
Returns the body of the HTTP part.
fn matching_rules(&self) -> &MatchingRules
fn matching_rules(&self) -> &MatchingRules
Returns the matching rules of the HTTP part.
fn generators(&self) -> &Generators
fn generators(&self) -> &Generators
Returns the generators of the HTTP part.
fn lookup_content_type(&self) -> Option<String>
fn lookup_content_type(&self) -> Option<String>
Lookup up the content type for the part
Provided methods
fn detect_content_type(&self) -> Option<ContentType>
fn detect_content_type(&self) -> Option<ContentType>
Tries to detect the content type of the body by matching some regular expressions against the first 32 characters.
fn content_type(&self) -> Option<ContentType>
fn content_type(&self) -> Option<ContentType>
Determine the content type of the HTTP part. If a Content-Type
header is present, the
value of that header will be returned. Otherwise, the body will be inspected.
fn has_header(&self, header_name: &str) -> bool
fn has_header(&self, header_name: &str) -> bool
Checks if the HTTP Part has the given header
fn lookup_header_value(&self, header_name: &str) -> Option<String>
fn lookup_header_value(&self, header_name: &str) -> Option<String>
Checks if the HTTP Part has the given header
fn has_text_body(&self) -> bool
fn has_text_body(&self) -> bool
If the body is a textual type (non-binary)
fn add_header(&mut self, key: &str, val: Vec<&str>)
fn add_header(&mut self, key: &str, val: Vec<&str>)
Convenience method to add a header
fn build_generators(
&self,
category: &GeneratorCategory
) -> HashMap<String, Generator>
fn build_generators(
&self,
category: &GeneratorCategory
) -> HashMap<String, Generator>
Builds a map of generators from the generators and matching rules