Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Add --compressed option to curl #14

Merged
merged 2 commits into from over 1 year ago

2 participants

Matt Brictson Michael Grosser
Matt Brictson

Some JavaScript libraries are provided by CDNs that always serve gzipped HTTP responses, regardless of the Accept-Encoding header. This is the case with code.highcharts.com, for example.

The problem is that by default, curl will not decompress these responses. So using vendorer to fetch something from code.highcharts.com will result in binary gzip data being saved, rather than the expected JavaScript.

My solution is to add the --compressed option to curl, which turns on gzip handling. With this change, resources fetched from code.highcharts.com are properly decompressed and saved as JavaScript.

Michael Grosser
Owner

Test or it did not happen :D

Matt Brictson

Test added. Can you merge it?

Michael Grosser
Owner

damn, did not get a notification when you added the test :)
consider it merged!

Michael Grosser grosser merged commit bc60203 into from
Michael Grosser
Owner

thanks! 0.1.13

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Showing 2 unique commits by 1 author.

Nov 13, 2012
Matt Brictson mbrictson Add --compressed option to curl e3c2934
Nov 15, 2012
Matt Brictson mbrictson Add spec for curl --compressed e70a3bf
This page is out of date. Refresh to see the latest.

Showing 2 changed files with 13 additions and 1 deletion. Show diff stats Hide diff stats

  1. +1 1  lib/vendorer.rb
  2. +12 0 spec/vendorer_spec.rb
2  lib/vendorer.rb
@@ -18,7 +18,7 @@ def file(path, url=nil)
18 18 if @copy_from_url
19 19 copy_from_path(target_path, url || path)
20 20 else
21   - run "curl '#{url}' -L -o #{target_path}"
  21 + run "curl '#{url}' -L --compressed -o #{target_path}"
22 22 raise "Downloaded empty file" unless File.exist?(target_path)
23 23 end
24 24 yield target_path if block_given?
12 spec/vendorer_spec.rb
@@ -159,6 +159,18 @@ def simple_vendorfile
159 159 vendorer.should_not include(@output)
160 160 end
161 161 end
  162 +
  163 + context "with a compressed resource" do
  164 + def vendorfile_for_compressed_resource
  165 + write 'Vendorfile', "file 'public/javascripts/highcharts.js', 'http://code.highcharts.com/highcharts.js'"
  166 + end
  167 +
  168 + it "decompresses to plain text" do
  169 + vendorfile_for_compressed_resource
  170 + vendorer
  171 + read('public/javascripts/highcharts.js').should include('Highcharts')
  172 + end
  173 + end
162 174 end
163 175
164 176 describe '#folder' do

Tip: You can add notes to lines in a file. Hover to the left of a line to make a note

Something went wrong with that request. Please try again.