Blob Blame History Raw
From 7bb4a6efee2f6f0c775df5f53b868e7c2e86919f Mon Sep 17 00:00:00 2001
From: Daniel Drake <dsd@laptop.org>
Date: Thu, 14 Feb 2013 15:05:10 -0600
Subject: [PATCH] (#18781) Be more tolerant of old clients in WEBrick server

In #18781 and #6117 there are cases of relatively simplistic puppet
setups failing between old versions of the puppet client (which
always use HTTP GET) and new versions of the puppet WEBrick server
(which has a relatively low limit on the size of a valid GET: 2083
bytes).

While there are other non-WEBrick server options available, WEBrick
has the advantage of simplicity, so it would be nice to keep it working.

Here we patch the WEBrick constant which specifies the maximum size of
a HTTP GET request, increasing it to a value that should work for common
setups.
---
 lib/puppet/util/monkey_patches.rb | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/lib/puppet/util/monkey_patches.rb b/lib/puppet/util/monkey_patches.rb
index ca19fa4..f7b13a5 100644
--- a/lib/puppet/util/monkey_patches.rb
+++ b/lib/puppet/util/monkey_patches.rb
@@ -394,3 +394,13 @@ class OpenSSL::SSL::SSLContext
     set_params(params)
   end
 end
+
+# Old puppet clients may make large GET requests, lets be reasonably tolerant
+# in our default WEBrick server.
+require 'webrick'
+if defined?(WEBrick::HTTPRequest::MAX_URI_LENGTH) and WEBrick::HTTPRequest::MAX_URI_LENGTH < 8192
+  # Silence ruby warning: already initialized constant MAX_URI_LENGTH
+  v, $VERBOSE = $VERBOSE, nil
+  WEBrick::HTTPRequest.const_set("MAX_URI_LENGTH", 8192)
+  $VERBOSE = v
+end
-- 
1.7.12.4 (Apple Git-37)