<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">From eb865b8c425a0d23a30c2510e34797c175f168e0 Mon Sep 17 00:00:00 2001
From: Slaven Rezic &lt;slaven@rezic.de&gt;
Date: Fri, 14 Jun 2019 09:43:22 +0200
Subject: [PATCH] cease warnings (in case of missing Accept header)

This should fix RT #129818.

Change done along with new test cases.
---
 lib/REST/Utils.pm       |  1 +
 t/content-negotiation.t | 10 +++++++++-
 2 files changed, 10 insertions(+), 1 deletion(-)

diff --git a/lib/REST/Utils.pm b/lib/REST/Utils.pm
index 19a7669..e3ef7fb 100644
--- a/lib/REST/Utils.pm
+++ b/lib/REST/Utils.pm
@@ -66,6 +66,7 @@ Example:
 
 sub best_match {
     my ( $supported, $header ) = @_;
+    return undef if !defined $header;
     my @parsed_header = map { [ parse_media_range($_) ] } split /,/msx, $header;
     my @weighted_matches =
       sort { $a-&gt;[0][0] &lt;=&gt; $b-&gt;[0][0] || $a-&gt;[0][1] &lt;=&gt; $b-&gt;[0][1] }
diff --git a/t/content-negotiation.t b/t/content-negotiation.t
index 1ae4d31..72b42cf 100644
--- a/t/content-negotiation.t
+++ b/t/content-negotiation.t
@@ -3,11 +3,14 @@
 # Test content negotiation
 use strict;
 use warnings;
-use Test::More tests =&gt; 10;
+use Test::More tests =&gt; 12;
 use CGI;
 use Test::WWW::Mechanize::CGI;
 use REST::Utils qw( media_type );
 
+my @warnings;
+$SIG{__WARN__} = sub { push @warnings, @_ };
+
 my $mech = Test::WWW::Mechanize::CGI-&gt;new;
 $mech-&gt;cgi( sub {
     my $q = CGI-&gt;new;    
@@ -25,6 +28,9 @@ $mech-&gt;cgi( sub {
     }
 });
 
+$mech-&gt;get('http://localhost/');
+is($mech-&gt;response-&gt;header('content_type'), 'text/plain; charset=ISO-8859-1', 'GET preferred content type without Accept header');
+
 $mech-&gt;add_header(Accept =&gt; 'application/xhtml+xml;q=1.0, text/html;q=0.9, text/plain;q=0.8, */*;q=0.1');
 
 $mech-&gt;get('http://localhost/');
@@ -62,3 +68,5 @@ is($mech-&gt;content_type, 'text/vrml', 'no content negotiation with DELETE');
 
 $mech-&gt;post('http://localhost/', Content_Type =&gt; undef);
 is($mech-&gt;status, '415', 'no content type');
+
+is_deeply \@warnings, [], 'No warnings';
-- 
2.1.4

</pre></body></html>