From 29b52d32c82dbc958a567b79fb697c86c65ad9fa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Rameau?= Date: Tue, 13 Feb 2018 11:02:47 +0100 Subject: [PATCH] Empty request no longer trigger fatal error. --- src/XmlRequestMiddleware.php | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/XmlRequestMiddleware.php b/src/XmlRequestMiddleware.php index 7e1dfba..678eafd 100644 --- a/src/XmlRequestMiddleware.php +++ b/src/XmlRequestMiddleware.php @@ -4,19 +4,26 @@ use Closure; +/** + * Class XmlRequestMiddleware + * @package XmlMiddleware + */ class XmlRequestMiddleware { /** * Handle an incoming request. * * @param \Illuminate\Http\Request $request - * @param \Closure $next + * @param \Closure $next + * * @return mixed */ public function handle($request, Closure $next) { - $request->merge($request->xml()); - + // We pass an array to merge if the xml parsing somewhat failed, no error will trigger + // If the xml request contains an empty body + $request->merge($request->xml() ?: []); + return $next($request); } } \ No newline at end of file