Code
Explorer
You are a developer and looking for Shopware projects?
Apply Now!
getTcpConnectTimeout example
catch
(
HttpException|StreamException
)
{
// Ignore streaming errors on previous responses
}
++
$info
[
'redirect_count'
]
;
$info
[
'url'
]
=
$info
[
'redirect_url'
]
;
$info
[
'redirect_url'
]
= null;
$previousUrl
=
$location
;
$request
=
new
Request
(
$info
[
'url'
]
,
$info
[
'http_method'
]
)
;
$request
->
setProtocolVersions
(
$originRequest
->
getProtocolVersions
(
)
)
;
$request
->
setTcpConnectTimeout
(
$originRequest
->
getTcpConnectTimeout
(
)
)
;
$request
->
setTlsHandshakeTimeout
(
$originRequest
->
getTlsHandshakeTimeout
(
)
)
;
$request
->
setTransferTimeout
(
$originRequest
->
getTransferTimeout
(
)
)
;
if
(
\
in_array
(
$status
,
[
301, 302, 303
]
, true
)
)
{
$originRequest
->
removeHeader
(
'transfer-encoding'
)
;
$originRequest
->
removeHeader
(
'content-length'
)
;
$originRequest
->
removeHeader
(
'content-type'
)
;
// Do like curl and browsers: turn POST to GET on 301, 302 and 303
if
(
'POST' ===
$response
->
getRequest
(
)
->
getMethod
(
)
|| 303 ===
$status
)
{
$info
[
'http_method'
]
= 'HEAD' ===
$response
->
getRequest
(
)
->
getMethod
(
)
? 'HEAD' : 'GET';