Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Maxime Veber
test-sf-http-client
Commits
63c86798
Commit
63c86798
authored
Jan 05, 2020
by
Maxime Veber
Browse files
Flush headers (& fix test)
parent
b7916d1e
Pipeline
#620
canceled with stages
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
server/index.php
View file @
63c86798
...
...
@@ -27,16 +27,18 @@ foreach ($_SERVER as $k => $v) {
$json
=
json_encode
(
$vars
,
JSON_PRETTY_PRINT
|
JSON_UNESCAPED_SLASHES
|
JSON_UNESCAPED_UNICODE
);
header
(
'Content-Type: application/json'
,
true
);
switch
(
$vars
[
'REQUEST_URI'
])
{
case
'/long-to-execute'
:
flush
();
sleep
(
5
);
break
;
case
'/faster'
:
flush
();
sleep
(
1
);
break
;
}
header
(
'Content-Type: application/json'
,
true
);
echo
$json
;
test2.php
View file @
63c86798
...
...
@@ -13,11 +13,12 @@ $response2 = $response = $client->request('GET', 'http://localhost:8001/faster')
$stream2
=
$response2
->
toStream
();
stream_set_blocking
(
$stream2
,
0
);
$originalRead
=
[
$stream1
,
$stream2
];
$write
=
[];
$except
=
[];
do
{
$read
=
[
$stream1
,
$stream2
]
;
$foo
=
stream_select
(
$read
,
$write
,
$except
,
null
,
0
);
$read
=
$originalRead
;
$foo
=
@
stream_select
(
$read
,
$write
,
$except
,
null
,
0
);
foreach
(
$read
as
$item
)
{
var_dump
(
stream_get_contents
(
$item
));
...
...
@@ -25,8 +26,14 @@ do {
echo
"Stream 1:
\n
"
;
var_dump
(
\
feof
(
$stream1
));
if
(
\
feof
(
$stream1
))
{
unset
(
$originalRead
[
0
]);
}
echo
"Stream 2:
\n
"
;
var_dump
(
\
feof
(
$stream2
));
}
while
(
!
\
feof
(
$stream1
)
&&
!
\
feof
(
$stream2
));
// while streams are not finished
if
(
\
feof
(
$stream1
))
{
unset
(
$originalRead
[
1
]);
}
}
while
(
!
\
feof
(
$stream1
)
||
!
\
feof
(
$stream2
));
// while streams are not finished
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