Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
typo3
qfq
Commits
923125ae
Commit
923125ae
authored
Sep 05, 2020
by
Carsten Rose
Browse files
Refs #11076. Reports a bit more error messages.
parent
505c4e35
Pipeline
#3758
passed with stages
in 4 minutes and 7 seconds
Changes
2
Pipelines
1
Show whitespace changes
Inline
Side-by-side
extension/Classes/Core/Report/Link.php
View file @
923125ae
...
...
@@ -537,12 +537,13 @@ class Link {
}
$urlParts
=
parse_url
(
$param
[
TOKEN_WEBSOCKET
]);
if
(
empty
(
$urlParts
[
'host'
])
||
empty
(
$urlParts
[
'port'
])
||
empty
(
$urlParts
[
'path'
]))
{
$urlParts
=
array_merge
([
'scheme'
=>
'ws'
,
'host'
=>
''
,
'port'
=>
80
,
'path'
=>
''
],
$urlParts
);
if
(
empty
(
$urlParts
[
'host'
]))
{
throw
new
\
UserFormException
(
json_encode
([
ERROR_MESSAGE_TO_USER
=>
'Target URL incomplete'
,
ERROR_MESSAGE_TO_DEVELOPER
=>
'host:'
.
$urlParts
[
'host'
]
.
', '
.
'port:'
.
$urlParts
[
'port'
]
.
', '
.
'path:'
.
$urlParts
[
'path'
]])
'host:
'
.
$urlParts
[
'host'
]
.
', '
.
'port:
'
.
$urlParts
[
'port'
]
.
', '
.
'path:
'
.
$urlParts
[
'path'
]])
,
ERROR_MISSING_VALUE
);
}
...
...
@@ -555,12 +556,13 @@ class Link {
}
// Open Socket
if
(
false
===
$websocket
->
connect
(
$urlParts
[
'host'
],
$urlParts
[
'port'
],
$urlParts
[
'path'
]))
{
throw
new
\
UserFormException
(
json_encode
([
ERROR_MESSAGE_TO_USER
=>
'Failed connect websocket'
,
$errorMsg
=
''
;
if
(
false
===
$websocket
->
connect
(
$urlParts
[
'host'
],
$urlParts
[
'port'
],
$urlParts
[
'path'
],
''
,
$errorMsg
))
{
throw
new
\
UserFormException
(
json_encode
([
ERROR_MESSAGE_TO_USER
=>
'Failed connect websocket: '
.
$errorMsg
,
ERROR_MESSAGE_TO_DEVELOPER
=>
'host:'
.
$urlParts
[
'host'
]
.
', '
.
'port:'
.
$urlParts
[
'port'
]
.
', '
.
'path:'
.
$urlParts
[
'path'
]])
'host:
'
.
$urlParts
[
'host'
]
.
', '
.
'port:
'
.
$urlParts
[
'port'
]
.
', '
.
'path:
'
.
$urlParts
[
'path'
]])
,
ERROR_MISSING_VALUE
);
}
...
...
extension/Classes/Core/Report/WebSocket.php
View file @
923125ae
...
...
@@ -143,9 +143,10 @@ class WebSocket {
* @param int $port
* @param string $path
* @param string $origin
* @param string $errorMsg # In case of an error, return error msg.
* @return bool
*/
public
function
connect
(
string
$host
,
int
$port
,
string
$path
,
string
$origin
=
''
)
{
public
function
connect
(
string
$host
,
int
$port
,
string
$path
,
string
$origin
=
''
,
&
$errorMsg
=
''
)
{
$this
->
host
=
$host
;
$this
->
port
=
$port
;
$this
->
path
=
$path
;
...
...
@@ -171,12 +172,18 @@ class WebSocket {
@
fwrite
(
$this
->
socket
,
$header
);
$response
=
@
fread
(
$this
->
socket
,
1500
);
$errorMsg
=
$response
;
$this
->
connected
=
false
;
preg_match
(
'#Sec-WebSocket-Accept:\s(.*)$#mU'
,
$response
,
$matches
);
if
(
$matches
)
{
$keyAccept
=
trim
(
$matches
[
1
]);
$expectedResponse
=
base64_encode
(
pack
(
'H*'
,
sha1
(
$key
.
'258EAFA5-E914-47DA-95CA-C5AB0DC85B11'
)));
$this
->
connected
=
(
$keyAccept
===
$expectedResponse
)
?
true
:
false
;
if
(
$keyAccept
===
$expectedResponse
)
{
$this
->
connected
=
true
;
$errorMsg
=
''
;
}
}
return
$this
->
connected
;
...
...
Write
Preview
Supports
Markdown
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