Use BufferedRead when reading#56
Conversation
|
I can now see that the small reads are actually not happening, so maybe the motivation to include this is not as strong as I first thought. |
| // The matches/if let dance is to fix lifetime of the borrowed inner connection. | ||
| #[cfg(feature = "embedded-tls")] | ||
| if matches!(self.buffered.bypass(), Ok(HttpConnection::Tls(_))) { | ||
| if let HttpConnection::Tls(ref mut tls) = self.buffered.bypass().unwrap() { |
There was a problem hiding this comment.
bypass is a neat idea!
So do I understand correctly that if let Ok(HttpConnection::Tls(ref mut tls)) = self.buffered.bypass() { without the outer matches! would not work˙, even if you wrap the whole block in a new scope?
There was a problem hiding this comment.
Year, I have tried multiple versions, which all fail to compile. The problem is that self.buffered is still borrowed in the else branch, and I cannot figure out how to avoid that. Any good proposals?
There was a problem hiding this comment.
Is it possible to change .bypass() to return Result<&mut T, &mut Self>?
There was a problem hiding this comment.
If you think that would make it work, then yes:)
There was a problem hiding this comment.
I guess I can try locally first :)
There was a problem hiding this comment.
Well, no, it can't because we still need to handle the HttpConnection::Plain branch :(
|
Yeah the network stack won't receive bytes one by one but this is certainly a cleaner implementation than what we had before. Minus the |
Currently when e.g. reading a chunked response body, we request a
read()with a single byte buffer. This PR uses theBufferedReadas an intermediate to greatly avoid small connection reads when tls is not in use.cc @bugadani