Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Add --compressed option to curl #14

Merged
merged 2 commits into from

2 participants

@mattbrictson

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.

@grosser
Owner

Test or it did not happen :D

@mattbrictson

Test added. Can you merge it?

@grosser
Owner

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

@grosser grosser merged commit bc60203 into grosser:master
@grosser
Owner

thanks! 0.1.13

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Nov 13, 2012
  1. @mattbrictson
Commits on Nov 15, 2012
  1. @mattbrictson
This page is out of date. Refresh to see the latest.
Showing with 13 additions and 1 deletion.
  1. +1 −1  lib/vendorer.rb
  2. +12 −0 spec/vendorer_spec.rb
View
2  lib/vendorer.rb
@@ -18,7 +18,7 @@ def file(path, url=nil)
if @copy_from_url
copy_from_path(target_path, url || path)
else
- run "curl '#{url}' -L -o #{target_path}"
+ run "curl '#{url}' -L --compressed -o #{target_path}"
raise "Downloaded empty file" unless File.exist?(target_path)
end
yield target_path if block_given?
View
12 spec/vendorer_spec.rb
@@ -159,6 +159,18 @@ def simple_vendorfile
vendorer.should_not include(@output)
end
end
+
+ context "with a compressed resource" do
+ def vendorfile_for_compressed_resource
+ write 'Vendorfile', "file 'public/javascripts/highcharts.js', 'http://code.highcharts.com/highcharts.js'"
+ end
+
+ it "decompresses to plain text" do
+ vendorfile_for_compressed_resource
+ vendorer
+ read('public/javascripts/highcharts.js').should include('Highcharts')
+ end
+ end
end
describe '#folder' do
Something went wrong with that request. Please try again.