Skip to content

Commit

Permalink
Change Header::append value to IntoHeaderValue
Browse files Browse the repository at this point in the history
  • Loading branch information
caspervonb committed Aug 4, 2023
1 parent ff7e1dd commit c83badc
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 7 deletions.
4 changes: 2 additions & 2 deletions async-nats/src/connection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ use tokio::io::{AsyncReadExt, AsyncWrite};
use bytes::{Buf, BytesMut};
use tokio::io;

use crate::header::{HeaderMap, HeaderName};
use crate::header::{HeaderMap, HeaderName, IntoHeaderValue};
use crate::status::StatusCode;
use crate::{ClientOp, ServerError, ServerOp};

Expand Down Expand Up @@ -304,7 +304,7 @@ impl Connection {
}
value.truncate(value.trim_end().len());

headers.append(name, value);
headers.append(name, value.into_header_value());
}

return Ok(Some(ServerOp::Message {
Expand Down
8 changes: 3 additions & 5 deletions async-nats/src/header.rs
Original file line number Diff line number Diff line change
Expand Up @@ -139,17 +139,15 @@ impl HeaderMap {
/// let mut headers = HeaderMap::new();
/// headers.append("Key", "Value");
/// headers.append("Key", "Another");
pub fn append<K: IntoHeaderName, V: ToString>(&mut self, name: K, value: V) {
pub fn append<K: IntoHeaderName, V: IntoHeaderValue>(&mut self, name: K, value: V) {
let key = name.into_header_name();
let v = self.inner.get_mut(&key);
match v {
Some(v) => {
v.push(HeaderValue {
inner: value.to_string(),
});
v.push(value.into_header_value());
}
None => {
self.insert(key, value.to_string().into_header_value());
self.insert(key, value.into_header_value());
}
}
}
Expand Down

0 comments on commit c83badc

Please sign in to comment.