1
0
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:
Tomas Hellström
2020-11-21 14:45:45 +01:00
committed by GitHub
parent b6099cd978
commit 155aa6dac5
20 changed files with 333 additions and 63 deletions

View File

@ -34,7 +34,7 @@ pub fn (mut s SSLConn) shutdown() ? {
if s.ssl != 0 {
mut res := 0
for {
res = int(C.SSL_shutdown(s.ssl))
res = C.SSL_shutdown(s.ssl)
if res < 0 {
err_res := openssl.ssl_error(res, s.ssl) or {
break // We break to free rest of resources
@ -56,9 +56,15 @@ pub fn (mut s SSLConn) shutdown() ? {
}
continue
} else {
C.SSL_free(s.ssl)
if s.sslctx != 0 {
C.SSL_CTX_free(s.sslctx)
}
return error('unexepedted ssl error $err_res')
}
C.SSL_free(s.ssl)
if s.ssl != 0 {
C.SSL_free(s.ssl)
}
if s.sslctx != 0 {
C.SSL_CTX_free(s.sslctx)
}
@ -144,7 +150,7 @@ pub fn (mut s SSLConn) socket_read_into_ptr(buf_ptr byteptr, len int) ?int {
} else if err_res == .ssl_error_zero_return {
return 0
}
return error('Could not read using SSL. ($err_res),err')
return error('Could not read using SSL. ($err_res)')
}
break
}
@ -192,30 +198,6 @@ pub fn (mut s SSLConn) write(bytes []Byte) ? {
}
}
// // ssl_error returns non error ssl code or error if unrecoverable and we should panic
// fn (mut s SSLConn) ssl_error(ret int) ?SSLError {
// res := C.SSL_get_error(s.ssl, ret)
// match SSLError(res) {
// .ssl_error_syscall { return error_with_code('unrecoverable syscall ($res)', res) }
// .ssl_error_ssl { return error_with_code('unrecoverable ssl protocol error ($res)',
// res) }
// else { return res }
// }
// }
// enum SSLError {
// ssl_error_none = C.SSL_ERROR_NONE
// ssl_error_ssl = C.SSL_ERROR_SSL
// ssl_error_want_read = C.SSL_ERROR_WANT_READ
// ssl_error_want_write = C.SSL_ERROR_WANT_WRITE
// ssl_error_want_x509_lookup = C.SSL_ERROR_WANT_X509_LOOKUP
// ssl_error_syscall = C.SSL_ERROR_SYSCALL
// ssl_error_zero_return = C.SSL_ERROR_ZERO_RETURN
// ssl_error_want_connect = C.SSL_ERROR_WANT_CONNECT
// ssl_error_want_accept = C.SSL_ERROR_WANT_ACCEPT
// ssl_error_want_async = C.SSL_ERROR_WANT_ASYNC
// ssl_error_want_async_job = C.SSL_ERROR_WANT_ASYNC_JOB
// ssl_error_want_client_hello_cb = C.SSL_ERROR_WANT_CLIENT_HELLO_CB
// }
/*
This is basically a copy of Emily socket implementation of select.
This have to be consolidated into common net lib features