    # File lib/chef/rest.rb, line 324
        def streaming_request(url, headers, &block)
          headers = build_headers(:GET, url, headers, nil, true)
          retriable_rest_request(:GET, url, nil, headers) do |rest_request|
            begin
              tempfile = nil
              response = rest_request.call do |r|
                if block_given? && r.kind_of?(Net::HTTPSuccess)
                  begin
                    tempfile = stream_to_tempfile(url, r, &block)
                    yield tempfile
                  ensure
                    tempfile.close!
                  end
                else
                  tempfile = stream_to_tempfile(url, r)
                end
              end
              if response.kind_of?(Net::HTTPSuccess)
                tempfile
              elsif redirect_location = redirected_to(response)
                # TODO: test tempfile unlinked when following redirects.
                tempfile && tempfile.close!
                follow_redirect {streaming_request(create_url(redirect_location), {}, &block)}
              else
                tempfile && tempfile.close!
                response.error!
              end
            rescue Exception => e
              if e.respond_to?(:chef_rest_request=)
                e.chef_rest_request = rest_request
              end
              raise
            end
          end
        end