Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
ubl
finc
fid
zend-psr18bridge
Commits
dee0c35c
Commit
dee0c35c
authored
Feb 18, 2019
by
Sebastian Kehr
🚣🏼
Browse files
Catch all zend http exceptions when and reset parameters after sending request.
parent
15cd9611
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/Client.php
View file @
dee0c35c
...
...
@@ -7,7 +7,7 @@ use Psr\Http\Message\RequestInterface;
use
Psr\Http\Message\ResponseInterface
;
use
Zend\Diactoros\Request\Serializer
;
use
Zend\Http\Client
as
ZendClient
;
use
Zend\Http\Exception\
Runtime
Exception
;
use
Zend\Http\Exception\
ExceptionInterface
as
Zend
Exception
;
use
Zend\Http\Request
as
ZendRequest
;
use
Zend\Psr7Bridge\Psr7Response
;
...
...
@@ -31,18 +31,18 @@ class Client implements ClientInterface
*/
public
function
sendRequest
(
RequestInterface
$request
):
ResponseInterface
{
$
requestString
=
Serializer
::
toString
(
$request
);
$zendRequest
=
ZendRequest
::
fromString
(
$
requestString
);
$
serializedRequest
=
Serializer
::
toString
(
$request
);
$zendRequest
=
ZendRequest
::
fromString
(
$
serializedRequest
);
$zendRequest
->
getUri
()
->
setHost
(
$request
->
getUri
()
->
getHost
());
try
{
$zendResponse
=
$this
->
zendClient
->
send
(
$zendRequest
);
}
catch
(
Runtime
Exception
$e
)
{
throw
new
ClientException
(
$e
->
getMessage
(),
$e
->
getCode
(),
$e
);
}
catch
(
Zend
Exception
$e
xception
)
{
throw
new
ClientException
(
$e
xception
->
getMessage
(),
null
,
$exception
);
}
$this
->
zendClient
->
resetParameters
(
true
);
return
Psr7Response
::
fromZend
(
$zendResponse
);
}
}
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