File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -34,16 +34,23 @@ public static function isApiRequest(Request $request): bool
3434
3535 public static function isHtmlRequest (Request $ request ): bool
3636 {
37- return Str::contains (
38- $ request ->getHeaderLine ('Accept ' ),
39- 'text/html '
40- );
37+ return ! self ::isApiRequest ($ request );
4138 }
4239
40+ /**
41+ * @param Request $request
42+ * @param array $types The content types to check against, in order of priority. The best match will be returned.
43+ * @return string
44+ */
4345 public static function getPreferredContentType (Request $ request , array $ types ): string
4446 {
4547 $ accept = $ request ->getHeaderLine ('Accept ' );
4648
49+ // We get some errors if $accept is empty, so we need to check for that and set it to */* if it is.
50+ if (! filled ($ accept )) {
51+ $ accept = '*/* ' ;
52+ }
53+
4754 return Mimeparse::bestMatch ($ types , $ accept );
4855 }
4956
You can’t perform that action at this time.
0 commit comments