Sha256: 51cec21a2509da473ecbf0825cf8113472683cdf66660c75d54c1f855dfa7950
Contents?: true
Size: 1.1 KB
Versions: 2
Compression:
Stored size: 1.1 KB
Contents
require 'open-uri' module Uricp::Strategy class PipedRemoteGet include Uricp::Strategy::Common def appropriate? case from.scheme when 'http', 'https' return proposal unless sequence_complete? else debug "#{self.class.name}: not appropriate" false end end alias :command :curl_download_to_pipe def proposal @proposed_options = options.dup @proposed_options['from_uri'] = PIPE_URI if options['target-format'] @proposed_options['source-format'] = format_peek if @proposed_options['source-format'] == @proposed_options['target-format'] @proposed_options.delete('source-format') @proposed_options.delete('target-format') end end self end def format_peek options['from_uri'].open(headers) { |u| encoding(u) } rescue OpenURI::HTTPError => e case e.io.status[0] when '416' 'raw' else raise end end def headers headers={'Range' => 'bytes=0-7'} headers['X-Auth-Token'] = options['auth-token'] if http_authentication? headers end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
uricp-0.0.7 | lib/uricp/strategy/piped_remote_get.rb |
uricp-0.0.6 | lib/uricp/strategy/piped_remote_get.rb |