Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change Header::append value to IntoHeaderValue #1076

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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