From e6f5df9f9183a3bd054ecdf5bdbb0b61e2f816fc Mon Sep 17 00:00:00 2001 From: Brian Matovu Date: Wed, 4 Jul 2018 11:28:12 +0300 Subject: [PATCH] Fix middleware --- composer.json | 2 +- src/Http/Middleware/RequireXml.php | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/composer.json b/composer.json index e90476a..35336e1 100644 --- a/composer.json +++ b/composer.json @@ -16,7 +16,7 @@ { "name": "Brian Matovu", "email": "mtvbrianking@gmail.com", - "homepage": "https://bmatovu.com", + "homepage": "http://bmatovu.com", "role": "Developer" } ], diff --git a/src/Http/Middleware/RequireXml.php b/src/Http/Middleware/RequireXml.php index 8e7d262..91c0326 100644 --- a/src/Http/Middleware/RequireXml.php +++ b/src/Http/Middleware/RequireXml.php @@ -10,6 +10,8 @@ class RequireXml /** * Handle an incoming request. * + * @link https://stackoverflow.com/a/11973933/2732184 + * * @param \Illuminate\Http\Request $request * @param \Closure $next * @param string|null $guard @@ -17,8 +19,8 @@ class RequireXml */ public function handle($request, Closure $next, $guard = null) { - if ($request->header('Accept') != 'text/xml') { - return response()->xml(['error' => 'Only accepting text/xml'], 406); + if ($request->getContentType() != 'xml') { + return response()->xml(['error' => 'Only accepting xml content'], 415); } return $next($request);