Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
A
Actor Framework
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Metrics
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
cpp-libs
Actor Framework
Commits
dc74da1a
Commit
dc74da1a
authored
Aug 22, 2023
by
Samir Halilcevic
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Integrate review feedback
parent
54e924ae
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
6 additions
and
17 deletions
+6
-17
libcaf_net/caf/detail/rfc6455.cpp
libcaf_net/caf/detail/rfc6455.cpp
+1
-1
libcaf_net/caf/net/web_socket/framing.cpp
libcaf_net/caf/net/web_socket/framing.cpp
+4
-10
libcaf_net/tests/legacy/net/web_socket/server.cpp
libcaf_net/tests/legacy/net/web_socket/server.cpp
+1
-6
No files found.
libcaf_net/caf/detail/rfc6455.cpp
View file @
dc74da1a
...
...
@@ -19,7 +19,7 @@ void rfc6455::mask_data(uint32_t key, byte_span data, size_t skip) {
std
::
byte
arr
[
4
];
memcpy
(
arr
,
&
no_key
,
4
);
data
=
data
.
subspan
(
skip
);
size_t
i
=
skip
%
4
;
auto
i
=
skip
%
4
;
for
(
auto
&
x
:
data
)
{
x
=
x
^
arr
[
i
];
i
=
(
i
+
1
)
%
4
;
...
...
libcaf_net/caf/net/web_socket/framing.cpp
View file @
dc74da1a
...
...
@@ -83,7 +83,6 @@ void framing::abort(const error& reason) {
ptrdiff_t
framing
::
consume
(
byte_span
buffer
,
byte_span
delta
)
{
// Make sure we're overriding any 'exactly' setting.
down_
->
configure_read
(
receive_policy
::
up_to
(
2048
));
// Parse header.
detail
::
rfc6455
::
header
hdr
;
auto
hdr_bytes
=
detail
::
rfc6455
::
decode_header
(
buffer
,
hdr
);
...
...
@@ -132,9 +131,8 @@ ptrdiff_t framing::consume(byte_span buffer, byte_span delta) {
auto
payload
=
buffer
.
subspan
(
hdr_bytes
,
std
::
min
(
buffer
.
size
()
-
hdr_bytes
,
hdr
.
payload_len
));
// Unmask the arrived data.
if
(
hdr
.
mask_key
!=
0
)
{
if
(
hdr
.
mask_key
!=
0
)
detail
::
rfc6455
::
mask_data
(
hdr
.
mask_key
,
payload
,
offset
);
}
size_t
frame_size
=
hdr_bytes
+
hdr
.
payload_len
;
// In case of text message, we want to validate the UTF-8 encoding early.
if
(
hdr
.
opcode
==
detail
::
rfc6455
::
text_frame
...
...
@@ -192,7 +190,9 @@ ptrdiff_t framing::consume(byte_span buffer, byte_span delta) {
return
-
1
;
}
// Call upper layer.
return
handle
(
hdr
.
opcode
,
payload
,
frame_size
);
auto
result
=
handle
(
hdr
.
opcode
,
payload
,
frame_size
);
validation_offset_
=
0
;
return
result
;
}
if
(
hdr
.
opcode
!=
detail
::
rfc6455
::
continuation_frame
)
{
CAF_LOG_DEBUG
(
"expected a WebSocket continuation_frame"
);
...
...
@@ -227,11 +227,6 @@ ptrdiff_t framing::consume(byte_span buffer, byte_span delta) {
if
(
opcode_
!=
detail
::
rfc6455
::
text_frame
)
{
payload_buf_
.
insert
(
payload_buf_
.
end
(),
payload
.
begin
(),
payload
.
end
());
}
if
(
opcode_
==
detail
::
rfc6455
::
text_frame
&&
!
payload_valid
(
payload_buf_
,
validation_offset_
))
{
abort_and_shutdown
(
sec
::
malformed_message
,
"invalid UTF-8 sequence"
);
return
-
1
;
}
return
static_cast
<
ptrdiff_t
>
(
frame_size
);
}
...
...
@@ -319,7 +314,6 @@ ptrdiff_t framing::handle(uint8_t opcode, byte_span payload,
payload
.
size
()};
if
(
up_
->
consume_text
(
text
)
<
0
)
return
-
1
;
validation_offset_
=
0
;
break
;
}
case
detail
:
:
rfc6455
::
binary_frame
:
...
...
libcaf_net/tests/legacy/net/web_socket/server.cpp
View file @
dc74da1a
...
...
@@ -185,12 +185,7 @@ TEST_CASE("data may arrive fragmented") {
rfc6455_append
(
detail
::
rfc6455
::
continuation_frame
,
"Socket!
\n
"
sv
,
buf
);
transport
->
push
(
buf
);
CHECK_EQ
(
transport
->
handle_input
(),
static_cast
<
ptrdiff_t
>
(
buf
.
size
()));
auto
expected
=
"Hello WebSocket!
\n
Bye WebSocket!
\n
"
sv
;
CHECK_EQ
(
app
->
text_input
.
size
(),
expected
.
size
());
for
(
auto
i
=
0ul
;
i
<
expected
.
size
();
i
++
)
{
CHECK_EQ
(
app
->
text_input
.
at
(
i
),
expected
.
at
(
i
));
}
MESSAGE
(
app
->
text_input
);
CHECK_EQ
(
app
->
text_input
,
"Hello WebSocket!
\n
Bye WebSocket!
\n
"
);
CHECK
(
!
app
->
has_aborted
());
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment