*Puppet Version:* Puppet 4 (at least) and up *Puppet Server Version:* n/a *OS Name/Version:* all
When running {{puppet apply}} with a file resource whose and source parameter is {{http(s)}} or {{puppet}}, then puppet will load the entire file into memory, instead of streaming it. Note the {{puppet}} case only happens if a host isn't specified, as that is interpreted to mean "use the local fileserver".
This was noticed while researching why the bug described in PUP-7482 only affected {{puppet agent}} but not {{puppet apply}}.
*Desired Behavior:*
When managing files with a {{source}} parameter, puppet apply should always stream file content from all of the following sources
{{<absolute path>}} local file {{file://<URI-encoded path>}} local file {{puppet:///modules/mymodule}} local file {{http?://host:port/path/to/file}} remote file
At first glance it appears the {{Puppet::Type::File::ParameterSource#content}} method can be deleted entirely, and should always rely on {{chunk_file_from_sourcechunk_file_from_disk}} which will invoke the or {{terminus_selector.rbchunk_file_from_source}} to determine the correct source.
This changes "puppet apply" to retrieve content for file resources with a "source" parameter in the same way that "puppet agent" does. Previously, "puppet apply" read the entire file contents into memory and cached it for the duration of the run. It also did not follow HTTP redirects or handle HTTP errors in the same way, such as HTTP service unavailable (503). Now "puppet apply" uses the same code path as "puppet agent" to stream file content from "puppet://" and "http(s)://" file sources. As a result, memory footprint should be reduced when using "puppet apply".