-
Notifications
You must be signed in to change notification settings - Fork 5
Connection related issue in HTTP client #48
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -52,3 +52,68 @@ def test_write_closing(self): | |
| self.assertEqual(connection.is_closed(), True) | ||
|
|
||
| transport.write(b"") | ||
|
|
||
| def test_is_closing_no_connection(self): | ||
| transport = netius.Transport(None, None, open=False) | ||
|
|
||
| self.assertEqual(transport._connection, None) | ||
| self.assertEqual(transport.is_closing(), True) | ||
|
|
||
| def test_is_closing_open_connection(self): | ||
| connection = netius.Connection() | ||
| transport = netius.Transport(None, connection) | ||
|
|
||
| self.assertEqual(transport.is_closing(), False) | ||
| self.assertEqual(connection.is_closed(), False) | ||
|
|
||
| def test_is_closing_closed_connection(self): | ||
| connection = netius.Connection() | ||
| transport = netius.Transport(None, connection) | ||
|
|
||
| connection.status = netius.CLOSED | ||
|
|
||
| self.assertEqual(transport.is_closing(), True) | ||
| self.assertEqual(connection.is_closed(), True) | ||
|
|
||
| def test_is_closing_protocol_closing(self): | ||
| connection = netius.Connection() | ||
| transport = netius.Transport(None, connection) | ||
|
|
||
| protocol = netius.Protocol() | ||
| protocol._open = True | ||
| transport._protocol = protocol | ||
|
|
||
| self.assertEqual(transport.is_closing(), False) | ||
| self.assertEqual(protocol.is_closing(), False) | ||
|
|
||
| protocol._closing = True | ||
|
|
||
| self.assertEqual(transport.is_closing(), False) | ||
| self.assertEqual(protocol.is_closing(), True) | ||
|
Comment on lines
+78
to
+92
|
||
|
|
||
| def test_is_closing_protocol_not_closing(self): | ||
| connection = netius.Connection() | ||
| transport = netius.Transport(None, connection) | ||
|
|
||
| protocol = netius.Protocol() | ||
| protocol._open = True | ||
| transport._protocol = protocol | ||
|
|
||
| self.assertEqual(transport.is_closing(), False) | ||
| self.assertEqual(protocol.is_open(), True) | ||
| self.assertEqual(protocol.is_closing(), False) | ||
|
|
||
| def test_is_closing_no_protocol(self): | ||
| connection = netius.Connection() | ||
| transport = netius.Transport(None, connection) | ||
|
|
||
| self.assertEqual(transport._protocol, None) | ||
| self.assertEqual(transport.is_closing(), False) | ||
|
|
||
| def test_is_closing_protocol_no_is_closing(self): | ||
| connection = netius.Connection() | ||
| transport = netius.Transport(None, connection) | ||
|
|
||
| transport._protocol = object() | ||
|
|
||
| self.assertEqual(transport.is_closing(), False) | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The comment says this branch "closes the protocol", but the code only returns early. Either update the comment to match the behavior, or actually close the protocol here (and consider whether any pending callback/request state should be finalized when
parsedis None).