Method: Puppet::Configurer::FactHandler#encode_facts

Defined in:
lib/puppet/configurer/fact_handler.rb

#encode_facts(facts) ⇒ Object



35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/puppet/configurer/fact_handler.rb', line 35

def encode_facts(facts)
  # facts = find_facts

  # NOTE: :facts specified as parameters are URI encoded here,
  # then  encoded for a second time depending on their length:
  #
  # <= 1024 characters sent via query string of a HTTP GET, additionally query string encoded
  # > 1024 characters sent in POST data, additionally x-www-form-urlencoded
  # so it's only important that encoding method here return original values
  # correctly when CGI.unescape called against it (in compiler code)
  if Puppet[:preferred_serialization_format] == "pson"
    { :facts_format => :pson, :facts => Puppet::Util.uri_query_encode(facts.render(:pson)) }
  else
    { :facts_format => 'application/json', :facts => Puppet::Util.uri_query_encode(facts.render(:json)) }
  end
end