forked from HaxeFoundation/haxe
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[python] Fixed python.net.SslSocket when python-version >= 3.4 (HaxeF…
…oundation#8401) The issue where SslSocket throws an exception is due to hostName being null in wrap_socket. This fix delays wrap_socket until after connect is called, so we can pass a host in.
- Loading branch information
Showing
5 changed files
with
106 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,12 @@ | ||
compile-each.hxml | ||
|
||
--each | ||
|
||
--main unit.TestMain | ||
-python bin/unit.py | ||
-python bin/unit.py | ||
|
||
--next | ||
|
||
-D python-version=3.4 | ||
--main unit.TestMain | ||
-python bin/unit34.py |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
package unit.issues; | ||
|
||
import sys.net.Host; | ||
|
||
class Issue8401 extends unit.Test { | ||
function testNew() { | ||
var sock = new python.net.SslSocket(); | ||
// With Issue8401, construction fails immediately; if we get this far, it's a pass | ||
utest.Assert.pass(); | ||
} | ||
|
||
@:access(python.net.SslSocket.__s) | ||
@:access(python.net.SslSocket.wrapSocketWithSslContext) | ||
function testTimeout() { | ||
var sock = new python.net.SslSocket(); | ||
// gettimeout is not currently defined in the python socket extern, but it's | ||
// present in the python socket type. | ||
eq(null, (cast sock.__s).gettimeout()); | ||
sock.setTimeout(500); | ||
eq(500, (cast sock.__s).gettimeout()); | ||
// This will change __s. Make sure we set the timeout properly. | ||
sock.wrapSocketWithSslContext("127.0.0.1"); | ||
eq(500, (cast sock.__s).gettimeout()); | ||
} | ||
|
||
#if (python_verion >= 3.7) | ||
@:access(python.net.SslSocket.__s) | ||
@:access(python.net.SslSocket.wrapSocketWithSslContext) | ||
function testBlocking() { | ||
var sock = new python.net.SslSocket(); | ||
// getblocking is not currently defined in the python socket extern, but it's | ||
// present in the python socket type. | ||
t((cast sock.__s).getblocking()); | ||
sock.setBlocking(false); | ||
f((cast sock.__s).getblocking()); | ||
// This will change __s. Make sure we set the timeout properly. | ||
sock.wrapSocketWithSslContext("127.0.0.1"); | ||
f((cast sock.__s).getblocking()); | ||
} | ||
#end | ||
|
||
@:access(python.net.SslSocket.__s) | ||
@:access(python.net.SslSocket.wrapSocketWithSslContext) | ||
function testFastSend() { | ||
var sock = new python.net.SslSocket(); | ||
// getsockopt is not currently defined in the python socket extern, but it's | ||
// present in the python socket type. | ||
eq(0, (cast sock.__s).getsockopt(python.lib.Socket.SOL_TCP, python.lib.Socket.TCP_NODELAY)); | ||
sock.setFastSend(true); | ||
eq(1, (cast sock.__s).getsockopt(python.lib.Socket.SOL_TCP, python.lib.Socket.TCP_NODELAY)); | ||
// This will change __s. Make sure we set the timeout properly. | ||
sock.wrapSocketWithSslContext("127.0.0.1"); | ||
eq(1, (cast sock.__s).getsockopt(python.lib.Socket.SOL_TCP, python.lib.Socket.TCP_NODELAY)); | ||
} | ||
} |