Struct haproxy_api::HttpMessage
source · pub struct HttpMessage<'lua> { /* private fields */ }Expand description
This class contains all functions to manipulate an HTTP message. For now, this class is only available from a filter context.
Implementations§
source§impl<'lua> HttpMessage<'lua>
impl<'lua> HttpMessage<'lua>
sourcepub fn add_header(&self, name: &str, value: impl AsRef<[u8]>) -> Result<()>
pub fn add_header(&self, name: &str, value: impl AsRef<[u8]>) -> Result<()>
Appends an HTTP header field in the HTTP message whose name is specified in name and value is defined in value.
sourcepub fn append(&self, data: impl AsRef<[u8]>) -> Result<isize>
pub fn append(&self, data: impl AsRef<[u8]>) -> Result<isize>
Copies the string at the end of incoming data of the HTTP message. The function returns the copied length on success or -1 if data cannot be copied.
sourcepub fn body(
&self,
offset: Option<isize>,
length: Option<isize>
) -> Result<Option<LuaString<'_>>>
pub fn body( &self, offset: Option<isize>, length: Option<isize> ) -> Result<Option<LuaString<'_>>>
Returns length bytes of incoming data from the HTTP message, starting at the offset.
The data are not removed from the buffer.
sourcepub fn channel(&self) -> Result<Channel<'_>>
pub fn channel(&self) -> Result<Channel<'_>>
Returns a corresponding channel attached to the HTTP message.
sourcepub fn del_header(&self, name: &str) -> Result<()>
pub fn del_header(&self, name: &str) -> Result<()>
Removes all HTTP header fields in the HTTP message whose name is specified in name.
sourcepub fn get_headers(&self) -> Result<Headers<'_>>
pub fn get_headers(&self) -> Result<Headers<'_>>
Returns a table containing all the headers of the HTTP message.
sourcepub fn get_stline(&self) -> Result<Table<'_>>
pub fn get_stline(&self) -> Result<Table<'_>>
Returns a table containing the start-line of the HTTP message.
sourcepub fn forward(&self, length: usize) -> Result<usize>
pub fn forward(&self, length: usize) -> Result<usize>
Forwards length bytes of data from the HTTP message.
Returns the amount of data forwarded.
Because it is called in the filter context, it never yield. Only available incoming data may be forwarded, event if the requested length exceeds the available amount of incoming data.
sourcepub fn input(&self) -> Result<usize>
pub fn input(&self) -> Result<usize>
Returns the length of incoming data in the HTTP message from the calling filter point of view.
sourcepub fn insert(
&self,
data: impl AsRef<[u8]>,
offset: Option<isize>
) -> Result<isize>
pub fn insert( &self, data: impl AsRef<[u8]>, offset: Option<isize> ) -> Result<isize>
Copies the data at the offset in incoming data of the HTTP message.
Returns the copied length on success or -1 if data cannot be copied.
By default, if no offset is provided, the string is copied in front of incoming data.
A positive offset is relative to the beginning of incoming data of the channel buffer while negative offset is relative to their end.
sourcepub fn may_recv(&self) -> Result<bool>
pub fn may_recv(&self) -> Result<bool>
Returns true if the HTTP message may still receive data.
sourcepub fn prepend(&self, data: impl AsRef<[u8]>) -> Result<isize>
pub fn prepend(&self, data: impl AsRef<[u8]>) -> Result<isize>
Copies the data in front of incoming data of the HTTP message.
Returns the copied length on success or -1 if data cannot be copied.
sourcepub fn remove(
&self,
offset: Option<isize>,
length: Option<usize>
) -> Result<isize>
pub fn remove( &self, offset: Option<isize>, length: Option<usize> ) -> Result<isize>
Removes length bytes of incoming data of the HTTP message, starting at offset.
Returns number of bytes removed on success.
sourcepub fn rep_header(&self, name: &str, regex: &str, replace: &str) -> Result<()>
pub fn rep_header(&self, name: &str, regex: &str, replace: &str) -> Result<()>
Matches the regular expression in all occurrences of header field name according to regex,
and replaces them with the replace.
The replacement value can contain back references like 1, 2, … This function acts on whole header lines, regardless of the number of values they may contain.
sourcepub fn rep_value(&self, name: &str, regex: &str, replace: &str) -> Result<()>
pub fn rep_value(&self, name: &str, regex: &str, replace: &str) -> Result<()>
Matches the regular expression on every comma-delimited value of header field name according to regex,
and replaces them with the replace.
The replacement value can contain back references like 1, 2, …
sourcepub fn send(&self, data: impl AsRef<[u8]>) -> Result<isize>
pub fn send(&self, data: impl AsRef<[u8]>) -> Result<isize>
Requires immediate send of the data.
It means the data is copied at the beginning of incoming data of the HTTP message and immediately forwarded.
Because it is called in the filter context, it never yield.
sourcepub fn set(
&self,
data: impl AsRef<[u8]>,
offset: Option<isize>,
length: Option<usize>
) -> Result<isize>
pub fn set( &self, data: impl AsRef<[u8]>, offset: Option<isize>, length: Option<usize> ) -> Result<isize>
Replaces length bytes of incoming data of the HTTP message, starting at offset, by the string data.
Returns the copied length on success or -1 if data cannot be copied.
sourcepub fn set_eom(&self, eom: bool) -> Result<()>
pub fn set_eom(&self, eom: bool) -> Result<()>
Sets or removes the flag that indicates end of message.
sourcepub fn set_header(&self, name: &str, value: impl AsRef<[u8]>) -> Result<()>
pub fn set_header(&self, name: &str, value: impl AsRef<[u8]>) -> Result<()>
Replaces all occurrence of all header matching the name, by only one containing the value.
sourcepub fn set_method(&self, method: &str) -> Result<()>
pub fn set_method(&self, method: &str) -> Result<()>
Rewrites the request method.
sourcepub fn set_query(&self, query: &str) -> Result<()>
pub fn set_query(&self, query: &str) -> Result<()>
Rewrites the request’s query string which appears after the first question mark “?”.
Trait Implementations§
source§impl<'lua> Clone for HttpMessage<'lua>
impl<'lua> Clone for HttpMessage<'lua>
source§fn clone(&self) -> HttpMessage<'lua>
fn clone(&self) -> HttpMessage<'lua>
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more