mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
fmt: smarter if condition wrapping (#8201)
This commit is contained in:
@ -118,9 +118,9 @@ fn (mut ws Client) read_handshake_str() ?string {
|
||||
}
|
||||
msg[total_bytes_read] = buffer[0]
|
||||
total_bytes_read++
|
||||
if total_bytes_read > 5 && msg[total_bytes_read - 1] == `\n` && msg[total_bytes_read -
|
||||
2] == `\r` && msg[total_bytes_read - 3] == `\n` && msg[total_bytes_read - 4] == `\r`
|
||||
{
|
||||
if total_bytes_read > 5 && msg[total_bytes_read - 1] == `\n`
|
||||
&& msg[total_bytes_read - 2] == `\r` && msg[total_bytes_read - 3] == `\n`
|
||||
&& msg[total_bytes_read - 4] == `\r` {
|
||||
break
|
||||
}
|
||||
}
|
||||
|
@ -42,9 +42,8 @@ pub fn (mut ws Client) validate_frame(frame &Frame) ? {
|
||||
ws.close(1002, 'rsv cannot be other than 0, not negotiated')
|
||||
return error('rsv cannot be other than 0, not negotiated')
|
||||
}
|
||||
if (int(frame.opcode) >= 3 && int(frame.opcode) <= 7) ||
|
||||
(int(frame.opcode) >= 11 && int(frame.opcode) <= 15)
|
||||
{
|
||||
if (int(frame.opcode) >= 3 && int(frame.opcode) <= 7)
|
||||
|| (int(frame.opcode) >= 11 && int(frame.opcode) <= 15) {
|
||||
ws.close(1002, 'use of reserved opcode') ?
|
||||
return error('use of reserved opcode')
|
||||
}
|
||||
|
@ -232,7 +232,11 @@ pub fn (mut ws Client) write_ptr(bytes byteptr, payload_len int, code OPCode) ?
|
||||
// todo: send error here later
|
||||
return error('trying to write on a closed socket!')
|
||||
}
|
||||
mut header_len := 2 + if payload_len > 125 { 2 } else { 0 } + if payload_len > 0xffff { 6 } else { 0 }
|
||||
mut header_len := 2 + if payload_len > 125 { 2 } else { 0 } + if payload_len > 0xffff {
|
||||
6
|
||||
} else {
|
||||
0
|
||||
}
|
||||
if !ws.is_server {
|
||||
header_len += 4
|
||||
}
|
||||
|
Reference in New Issue
Block a user