Skip to content

Instantly share code, notes, and snippets.

@venj
Created March 13, 2014 05:51
Show Gist options
  • Save venj/9522520 to your computer and use it in GitHub Desktop.
Save venj/9522520 to your computer and use it in GitHub Desktop.
UPai Cloud UA Test
#!/usr/bin/env ruby
require "open-uri"
pic = "http://xxxx.b0.upaiyun.com/1/attachments/ZWg3nr1E.jpg"
open("test_no_ua.jpg", "w+") do |f|
begin
f.write(open(pic).read)
rescue Exception => e
print "No ua:"
puts e.message
end
end
open("test.jpg", "w+") do |f|
begin
f.write(open(pic, {"user-agent" => "This is iPhone client"}).read)
rescue Exception => e
print "With ua:"
puts e.message
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment