Fix TO ORT for missing Content-Length, per RFC

Content-Length MAY be omitted per HTTP/1.1 RFC 7230, and in fact MUST
NOT be included with a 'Transfer-Encoding: Chunked' header, which MUST
be accepted by clients.

Fixes TC-503


Project: http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/repo
Commit: 
http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/commit/5c50e062
Tree: 
http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/tree/5c50e062
Diff: 
http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/diff/5c50e062

Branch: refs/heads/master
Commit: 5c50e06272767415bc8b9703d3e9a1742ffb06b6
Parents: 0bec96f
Author: Robert Butts <robert.o.bu...@gmail.com>
Authored: Tue Aug 8 10:21:00 2017 -0600
Committer: Derek Gelinas <derek_geli...@cable.comcast.com>
Committed: Mon Aug 14 13:55:49 2017 -0400

----------------------------------------------------------------------
 traffic_ops/bin/traffic_ops_ort.pl | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/5c50e062/traffic_ops/bin/traffic_ops_ort.pl
----------------------------------------------------------------------
diff --git a/traffic_ops/bin/traffic_ops_ort.pl 
b/traffic_ops/bin/traffic_ops_ort.pl
index e5b551c..c5f1114 100755
--- a/traffic_ops/bin/traffic_ops_ort.pl
+++ b/traffic_ops/bin/traffic_ops_ort.pl
@@ -1633,9 +1633,7 @@ sub check_lwp_response_content_length {
        my $url           = $lwp_response->request->uri;
 
        if ( !defined($lwp_response->header('Content-Length')) ) {
-               ( $log_level >> $panic_level ) && print $log_level_str . " $url 
did not return a Content-Length header!\n";
-               exit;
-               return 1;
+               return 0; # Content-Length MAY be omitted per HTTP/1.1 RFC 
7230, and in fact MUST NOT be included with a 'Transfer-Encoding: Chunked' 
header, which MUST be accepted by clients.
        }
        elsif ( $lwp_response->header('Content-Length') != 
length($lwp_response->content()) ) {
                ( $log_level >> $panic_level ) && print $log_level_str . " $url 
returned a Content-Length of " . $lwp_response->header('Content-Length') . ", 
however actual content length is " . length($lwp_response->content()) . "!\n";

Reply via email to