Posted By

bcmoney on 12/10/10


Tagged

http rails ruby on proxy


Versions (?)

proxy.rb


 / Published in: Ruby
 

URL: http://bcmoney-mobiletv.com/blog/2009/05/01/the-server-side-proxy/

Useful resources: https://github.com/yuiseki/chaos_proxy/blob/master/proxy.rb

http://stackoverflow.com/questions/3072682/jquery-consuming-json-resources-some-return-data-others-dont-why

http://www.java-samples.com/showtutorial.php?tutorialid=1118

http://stackoverflow.com/questions/2500462/how-to-extract-url-parameters-from-a-url-with-ruby-or-rails

http://guides.rubyonrails.org/command_line.html

http://ruby-doc.org/core/classes/String.html#M000839

http://rails.nuvvo.com/lesson/6371-action-controller-parameters

http://www.ruby-doc.org/stdlib/libdoc/net/http/rdoc/classes/Net/HTTP.html

http://net.tutsplus.com/tutorials/ruby/ruby-for-newbies-conditional-statements-and-loops/

http://dirk.net/2009/09/16/globalizing-the-current-url-in-a-rails-view/

  1. require 'net/http'
  2. require 'cgi'
  3. require 'uri'
  4.  
  5. u = request.env['PATH_INFO']
  6. if u == "" then u = ARGV[1]; end
  7. if u == "" then u = "http://example.com/?url=http://flickr.com/&f=text/plain&e=utf-8"; end
  8.  
  9. link = URI.parse(uri)
  10. params = CGI::parse(link.query)
  11.  
  12. url = params[:url]
  13. format = params[:f]
  14. encoding = params[:e]
  15.  
  16. if url == "" then url = "http://example.com"; end
  17. if format == "" then format = "text/plain"; end
  18. if encoding == "" then encoding = "utf-8"; end
  19.  
  20.  
  21. response = Net::HTTP.get_response()
  22. p response['content-type']
  23. put response.body

Report this snippet  

You need to login to post a comment.