You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficcontrol.apache.org by da...@apache.org on 2018/11/05 23:12:07 UTC

[trafficcontrol] branch master updated: Prevent Perl input record separator change in TO dbdump API

This is an automated email from the ASF dual-hosted git repository.

dangogh pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/trafficcontrol.git


The following commit(s) were added to refs/heads/master by this push:
     new 612bedd  Prevent Perl input record separator change in TO dbdump API
612bedd is described below

commit 612bedd89c31e3e0187705411a1ffb281cf453bf
Author: Rawlin Peters <ra...@comcast.com>
AuthorDate: Wed Oct 31 14:15:49 2018 -0600

    Prevent Perl input record separator change in TO dbdump API
    
    Due to the way this code was previously written, the first call to the
    dbdump API is successful, but subsequent calls are broken because the
    chomp() function no longer strips trailing whitespace from the output of
    the `hostname` command. This ends up breaking the response headers
    because of the unexpected newline, causing traffic_ops_golang to emit
    this error and return a 502:
    
        http: proxy error: net/http: HTTP/1.x transport connection broken:
        malformed MIME header line: -20181031125221.pg_dump"
    
    By only locally declaring $/ (undefined), subsequent calls to `chomp()`
    actually strip newlines because `$/ == "\n"` by default.
---
 traffic_ops/app/lib/API/Database.pm | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/traffic_ops/app/lib/API/Database.pm b/traffic_ops/app/lib/API/Database.pm
index caf6598..bd277c8 100644
--- a/traffic_ops/app/lib/API/Database.pm
+++ b/traffic_ops/app/lib/API/Database.pm
@@ -40,7 +40,7 @@ sub dbdump {
 	}
 
 	# slurp it in..
-	undef $/;
+	local $/;
 	my $data = <$fh>;