-
-
Save littlefyr/ac5508c50bd1435174d7 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
undefined method `to_sym' for nil:NilClass | |
/Users/adamvandenhoven/.rvm/rubies/ruby-1.9.3-head/lib/ruby/1.9.1/net/http.rb:551:in `block in start' | |
(eval):3:in `each' | |
(eval):3:in `each_with_optional_block' | |
/Users/adamvandenhoven/.rvm/rubies/ruby-1.9.3-head/lib/ruby/1.9.1/net/http.rb:550:in `grep' | |
/Users/adamvandenhoven/.rvm/rubies/ruby-1.9.3-head/lib/ruby/1.9.1/net/http.rb:550:in `start' | |
/Users/adamvandenhoven/Development/Glacier/api.glaciermedia.ca/lib/cheetah_mail.rb:23:in `fetch' | |
/Users/adamvandenhoven/Development/Glacier/api.glaciermedia.ca/lib/cheetah_mail/set_user.rb:88:in `setuser1' | |
/Users/adamvandenhoven/Development/Glacier/api.glaciermedia.ca/lib/cheetah_mail/set_user.rb:27:in `perform' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def fetch uri, params, use_cookie=true | |
uri = URI( uri ) | |
uri.query = URI.encode_www_form(params) | |
Net::HTTP.start(uri.host, uri.port, | |
:use_ssl => true) do |http| | |
request = Net::HTTP::Get.new uri.request_uri | |
request['cookie'] = Resque.redis.get(CheetahMail::PASSKEY) if use_cookie | |
response = http.request request # Net::HTTPResponse object | |
return response | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# call-seq: | |
# HTTP.start(address, port, p_addr, p_port, p_user, p_pass, &block) | |
# HTTP.start(address, port=nil, p_addr=nil, p_port=nil, p_user=nil, p_pass=nil, opt, &block) | |
# | |
# Creates a new Net::HTTP object, then additionally opens the TCP | |
# connection and HTTP session. | |
# | |
# Arguments are the following: | |
# _address_ :: hostname or IP address of the server | |
# _port_ :: port of the server | |
# _p_addr_ :: address of proxy | |
# _p_port_ :: port of proxy | |
# _p_user_ :: user of proxy | |
# _p_pass_ :: pass of proxy | |
# _opt_ :: optional hash | |
# | |
# _opt_ sets following values by its accessor. | |
# The keys are ca_file, ca_path, cert, cert_store, ciphers, | |
# close_on_empty_response, key, open_timeout, read_timeout, ssl_timeout, | |
# ssl_version, use_ssl, verify_callback, verify_depth and verify_mode. | |
# If you set :use_ssl as true, you can use https and default value of | |
# verify_mode is set as OpenSSL::SSL::VERIFY_PEER. | |
# | |
# If the optional block is given, the newly | |
# created Net::HTTP object is passed to it and closed when the | |
# block finishes. In this case, the return value of this method | |
# is the return value of the block. If no block is given, the | |
# return value of this method is the newly created Net::HTTP object | |
# itself, and the caller is responsible for closing it upon completion | |
# using the finish() method. | |
def HTTP.start(address, *arg, &block) # :yield: +http+ | |
arg.pop if opt = Hash.try_convert(arg[-1]) | |
port, p_addr, p_port, p_user, p_pass = *arg | |
port = https_default_port if !port && opt && opt[:use_ssl] | |
http = new(address, port, p_addr, p_port, p_user, p_pass) | |
if opt | |
if opt[:use_ssl] | |
opt = {verify_mode: OpenSSL::SSL::VERIFY_PEER}.update(opt) | |
end | |
http.methods.grep(/\A(\w+)=\z/) do |meth| | |
key = $1.to_sym | |
opt.key?(key) or next | |
http.__send__(meth, opt[key]) | |
end | |
end | |
http.start(&block) | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"[:inspect, :set_debug_output, :address, :port, :open_timeout, :open_timeout=, :read_timeout, :read_timeout=, :continue_timeout, :continue_timeout=, :started?, :active?, :close_on_empty_response, :close_on_empty_response=, :use_ssl?, :use_ssl=, :ca_file, :ca_file=, :ca_path, :ca_path=, :cert, :cert=, :cert_store, :cert_store=, :ciphers, :ciphers=, :key, :key=, :ssl_timeout, :ssl_timeout=, :ssl_version, :ssl_version=, :verify_callback, :verify_callback=, :verify_depth, :verify_depth=, :verify_mode, :verify_mode=, :peer_cert, :start, :finish, :proxy?, :proxy_address, :proxy_port, :proxy_user, :proxy_pass, :proxyaddr, :proxyport, :get, :head, :post, :patch, :put, :proppatch, :lock, :unlock, :options, :propfind, :delete, :move, :copy, :mkcol, :trace, :request_get, :request_head, :request_post, :request_put, :get2, :head2, :post2, :put2, :send_request, :request, :psych_to_yaml, :to_yaml_properties, :to_yaml, :blank?, :present?, :presence, :acts_like?, :pretty_print, :pretty_print_cycle, :pretty_print_instance_variables, :pretty_print_inspect, :to_json, :nil?, :===, :=~, :!~, :eql?, :hash, :<=>, :class, :singleton_class, :clone, :dup, :initialize_dup, :initialize_clone, :taint, :tainted?, :untaint, :untrust, :untrusted?, :trust, :freeze, :frozen?, :to_s, :methods, :singleton_methods, :protected_methods, :private_methods, :public_methods, :instance_variables, :instance_variable_get, :instance_variable_set, :instance_variable_defined?, :instance_of?, :kind_of?, :is_a?, :tap, :send, :public_send, :respond_to?, :respond_to_missing?, :extend, :display, :method, :public_method, :define_singleton_method, :object_id, :to_enum, :enum_for, :gem, :require_with_backports, :try, :returning, :silence_warnings, :enable_warnings, :with_warnings, :silence_stderr, :silence_stream, :suppress, :pretty_inspect, :==, :equal?, :!, :!=, :instance_eval, :instance_exec, :__send__, :__id__]" | |
******************************************************************************** | |
open_timeout= | |
nil | |
******************************************************************************** | |
read_timeout= | |
nil | |
******************************************************************************** | |
continue_timeout= | |
nil | |
******************************************************************************** | |
close_on_empty_response= | |
nil | |
******************************************************************************** | |
use_ssl= | |
nil | |
******************************************************************************** | |
ca_file= | |
nil | |
******************************************************************************** | |
ca_path= | |
nil | |
******************************************************************************** | |
cert= | |
nil | |
******************************************************************************** | |
cert_store= | |
nil | |
******************************************************************************** | |
ciphers= | |
nil | |
******************************************************************************** | |
key= | |
nil | |
******************************************************************************** | |
ssl_timeout= | |
nil | |
******************************************************************************** | |
ssl_version= | |
nil | |
******************************************************************************** | |
verify_callback= | |
nil | |
******************************************************************************** | |
verify_depth= | |
nil | |
******************************************************************************** | |
verify_mode= | |
nil | |
*** (Job{subscriptions} | CheetahMail::SetUser | [{"email"=>"adam2@littlefyr.com", "sub"=>"2088191115", "aid"=>"2088191115", "check_aid"=>1}]) failed: #<NoMethodError: undefined method `to_sym' for nil:NilClass> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Monkey Patch to see what is happening. | |
module Net | |
def HTTP.start(address, *arg, &block) # :yield: +http+ | |
arg.pop if opt = Hash.try_convert(arg[-1]) | |
port, p_addr, p_port, p_user, p_pass = *arg | |
port = https_default_port if !port && opt && opt[:use_ssl] | |
http = new(address, port, p_addr, p_port, p_user, p_pass) | |
p http.methods.inspect | |
if opt | |
if opt[:use_ssl] | |
opt = {verify_mode: OpenSSL::SSL::VERIFY_PEER}.update(opt) | |
end | |
http.methods.grep(/\A(\w+)=\z/){ |m| | |
puts "*"*80 | |
puts m | |
p $1 | |
p $1.to_sym rescue next | |
} | |
http.methods.grep(/\A(\w+)=\z/) do |meth| | |
key = $1.to_sym | |
opt.key?(key) or next | |
http.__send__(meth, opt[key]) | |
end | |
end | |
http.start(&block) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment