Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
O
opentrafficshaper
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Francisco Manuel Cardoso
opentrafficshaper
Commits
e95ece18
Commit
e95ece18
authored
11 years ago
by
Nigel Kukard
Browse files
Options
Downloads
Patches
Plain Diff
Use same websocket state and don't mask replied
parent
387bbb7b
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
opentrafficshaper/POE/Filter/HybridHTTP.pm
+16
-13
16 additions, 13 deletions
opentrafficshaper/POE/Filter/HybridHTTP.pm
with
16 additions
and
13 deletions
opentrafficshaper/POE/Filter/HybridHTTP.pm
+
16
−
13
View file @
e95ece18
...
...
@@ -154,18 +154,22 @@ sub put
push
(
@results
,
$self
->
_build_raw_response
(
$response
));
}
# Handle WebSocket data
}
elsif
(
$self
->
{'
state
'}
==
ST_WEBSOCKET_STREAM
)
{
# Compile our list of results
foreach
my
$response
(
@
{
$responses
})
{
# If we don't have a websocket
write
state, create one
if
(
!
$self
->
{'
state_
websocket_
wri
te
'})
{
$self
->
{'
state_
websocket_
wri
te
'}
=
new
POE::Filter::HybridHTTP::
WebSocketFrame
();
# If we don't have a websocket state, create one
if
(
!
$self
->
{'
websocket_
sta
te
'})
{
$self
->
{'
websocket_
sta
te
'}
=
new
POE::Filter::HybridHTTP::
WebSocketFrame
();
}
$self
->
{'
state_websocket_write
'}
->
append
(
$response
);
push
(
@results
,
$self
->
{'
state_websocket_write
'}
->
to_bytes
());
# Don't mask replies from server to client RFC6455 secion 5.1.
$self
->
{'
websocket_state
'}
->
masked
(
0
);
# Consume the response with websockets...
$self
->
{'
websocket_state
'}
->
append
(
$response
);
# Spit out bytes...
my
$payload
=
$self
->
{'
websocket_state
'}
->
to_bytes
();
push
(
@results
,
$payload
);
}
}
...
...
@@ -187,8 +191,7 @@ sub _reset
# Reset our filter state
$self
->
{'
buffer
'}
=
'';
$self
->
{'
state
'}
=
ST_HTTP_HEADERS
;
$self
->
{'
state_websocket_read
'}
=
undef
;
$self
->
{'
state_websocket_write
'}
=
undef
;
$self
->
{'
websocket_state
'}
=
undef
;
$self
->
{'
last_request
'}
=
$self
->
{'
request
'};
$self
->
{'
request
'}
=
undef
;
# We want the last request always
$self
->
{'
content_len
'}
=
0
;
...
...
@@ -400,16 +403,16 @@ sub _get_one_websocket_record
# If we don't have a websocket state, create one
if
(
!
$self
->
{'
state_
websocket_
read
'})
{
$self
->
{'
state_
websocket_
read
'}
=
new
POE::Filter::HybridHTTP::
WebSocketFrame
();
if
(
!
$self
->
{'
websocket_
state
'})
{
$self
->
{'
websocket_
state
'}
=
new
POE::Filter::HybridHTTP::
WebSocketFrame
();
}
$self
->
{'
state_
websocket_
read
'}
->
append
(
$self
->
{'
buffer
'});
$self
->
{'
websocket_
state
'}
->
append
(
$self
->
{'
buffer
'});
# Blank our buffer
$self
->
{'
buffer
'}
=
'';
# Loop with records and push onto result set
my
@results
;
while
(
my
$item
=
$self
->
{'
state_
websocket_
read
'}
->
next
())
{
while
(
my
$item
=
$self
->
{'
websocket_
state
'}
->
next
())
{
push
(
@results
,
$item
);
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment