Trait pact_models::http_parts::HttpPart

source ·
pub trait HttpPart {
Show 16 methods // Required methods fn headers(&self) -> &Option<HashMap<String, Vec<String>>>; fn headers_mut(&mut self) -> &mut HashMap<String, Vec<String>>; fn body(&self) -> &OptionalBody; fn body_mut(&mut self) -> &mut OptionalBody; fn matching_rules(&self) -> &MatchingRules; fn matching_rules_mut(&mut self) -> &mut MatchingRules; fn generators(&self) -> &Generators; fn generators_mut(&mut self) -> &mut Generators; fn lookup_content_type(&self) -> Option<String>; // Provided methods 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<DocPath, Generator> { ... }
}
Expand description

Trait to specify an HTTP part of an interaction. It encapsulates the shared parts of a request and response.

Required Methods§

source

fn headers(&self) -> &Option<HashMap<String, Vec<String>>>

Returns the headers of the HTTP part.

source

fn headers_mut(&mut self) -> &mut HashMap<String, Vec<String>>

Returns the headers of the HTTP part in a mutable form.

source

fn body(&self) -> &OptionalBody

Returns the body of the HTTP part.

source

fn body_mut(&mut self) -> &mut OptionalBody

Returns a mutable pointer to the body of the HTTP part.

source

fn matching_rules(&self) -> &MatchingRules

Returns the matching rules of the HTTP part.

source

fn matching_rules_mut(&mut self) -> &mut MatchingRules

Returns the matching rules of the HTTP part.

source

fn generators(&self) -> &Generators

Returns the generators of the HTTP part.

source

fn generators_mut(&mut self) -> &mut Generators

Returns the generators of the HTTP part.

source

fn lookup_content_type(&self) -> Option<String>

Lookup up the content type for the part

Provided Methods§

source

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.

source

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.

source

fn has_header(&self, header_name: &str) -> bool

Checks if the HTTP Part has the given header

source

fn lookup_header_value(&self, header_name: &str) -> Option<String>

Checks if the HTTP Part has the given header

source

fn has_text_body(&self) -> bool

If the body is a textual type (non-binary)

source

fn add_header(&mut self, key: &str, val: Vec<&str>)

Convenience method to add a header

source

fn build_generators( &self, category: &GeneratorCategory ) -> HashMap<DocPath, Generator>

Builds a map of generators from the generators and matching rules

Implementors§