Sha256: 0fee63a8492074e19e7bad68fff8ffe65228c1e90885dfdf47c01febc9aa8f9a
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['authenticator'].call if http_authentication? headers end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
uricp-0.0.9 | lib/uricp/strategy/piped_remote_get.rb |
uricp-0.0.8 | lib/uricp/strategy/piped_remote_get.rb |