Skip to content

Add is_close_notify helper. - #605

Closed
jsha wants to merge 1 commit into
rustls:mainfrom
jsha:is-close-notify
Closed

jsha wants to merge 1 commit into
rustls:mainfrom
jsha:is-close-notify

Conversation

@jsha

@jsha jsha commented Mar 31, 2021

Copy link
Copy Markdown
Contributor

This helps users distinguish a CloseNotify from other types of I/O
errors.

This helps users distinguish a CloseNotify from other types of I/O
errors.

@djc djc left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the change to stuff a TlsError in the io::Error for this case makes a lot of sense, but I feel like the is_close_notify() function probably belongs in crustls rather than here.

@jsha

jsha commented Mar 31, 2021

Copy link
Copy Markdown
Contributor Author

This is not just useful for crustls, but also for any Rust code that deals with close-delimited streams (i.e. any HTTP response without Content-Length or Transfer-Encoding). It's particularly useful when dealing with StreamOwned, where the returned io::Error could come from the underlying TcpStream or from a CloseNotify.

Comment thread rustls/src/session.rs
}

/// Return true if the provided io::Error is the result of receiving a close_notify
/// alert from the peer. Users should treat this as a clean shutdown of the connection.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems wrong for us to treat close_notify as an error when really it's the least erroneous result we could get; only when we receive a close_notify has everything gone according to how the spec says it should. So, like I said in the related issue, it seems like we should redo the API to make receiving a close_notify an explicit non-error result.

@jsha jsha mentioned this pull request Apr 1, 2021
@briansmith

Copy link
Copy Markdown
Contributor

Given the discussion in the issue, I think we should close this.

@jsha

jsha commented Apr 9, 2021

Copy link
Copy Markdown
Contributor Author

Closing in favor of modifying the Session API to more clearly indicate close_notify as an "EOF with no errors" state: #563

@jsha jsha closed this Apr 9, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants