mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
x.websocket: fix autobahn tests for wss and wss close behavor (#6901)
This commit is contained in:
@@ -11,6 +11,9 @@ interface WebsocketIO {
|
||||
// socket_read reads into the provided buffer with its length
|
||||
fn (mut ws Client) socket_read(mut buffer []byte) ?int {
|
||||
lock {
|
||||
if ws.state in [.closed, .closing] || ws.conn.sock.handle <= 1 {
|
||||
return error('socket_read: trying to read a closed socket')
|
||||
}
|
||||
if ws.is_ssl {
|
||||
r := ws.ssl_conn.read_into(mut buffer)?
|
||||
return r
|
||||
@@ -30,6 +33,10 @@ fn (mut ws Client) socket_read(mut buffer []byte) ?int {
|
||||
|
||||
fn (mut ws Client) socket_read_ptr(buf_ptr byteptr, len int) ?int {
|
||||
lock {
|
||||
if ws.state in [.closed, .closing] || ws.conn.sock.handle <= 1 {
|
||||
return error('socket_read_ptr: trying to read a closed socket')
|
||||
}
|
||||
|
||||
if ws.is_ssl {
|
||||
r := ws.ssl_conn.socket_read_into_ptr(buf_ptr, len)?
|
||||
return r
|
||||
@@ -51,8 +58,8 @@ fn (mut ws Client) socket_read_ptr(buf_ptr byteptr, len int) ?int {
|
||||
fn (mut ws Client) socket_write(bytes []byte) ? {
|
||||
lock {
|
||||
if ws.state == .closed || ws.conn.sock.handle <= 1 {
|
||||
ws.debug_log('write: Socket allready closed')
|
||||
return error('Socket allready closed')
|
||||
ws.debug_log('socket_write: Socket allready closed')
|
||||
return error('socket_write: trying to write on a closed socket')
|
||||
}
|
||||
if ws.is_ssl {
|
||||
ws.ssl_conn.write(bytes)?
|
||||
|
||||
Reference in New Issue
Block a user