Created
January 23, 2011 10:52
-
-
Save ashchan/791984 to your computer and use it in GitHub Desktop.
https calling in NSOperation caused Segmentation fault
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
framework 'Cocoa' | |
require 'net/https' | |
class SomeOperation < NSOperation | |
def main | |
http = Net::HTTP.new("mail.google.com", 443) | |
http.use_ssl = true | |
response = nil | |
http.start do |h| | |
req = Net::HTTP::Get.new("/mail/feed/atom") | |
req.basic_auth('ashchan', 'pass') | |
response = h.request(req) | |
end | |
puts response.code | |
end | |
end | |
class AppDelegate | |
def applicationDidFinishLaunching(notification) | |
queue = NSOperationQueue.alloc.init | |
2.times do | |
queue.addOperation SomeOperation.new | |
end | |
end | |
end | |
app = NSApplication.sharedApplication | |
app.delegate = AppDelegate.new | |
app.run | |
# MacRuby 0.9 | |
# macruby -w https_nsoperation.rb | |
# result: | |
# unknown: warning: Float 1.797693134862316E+3... out of range | |
# unknown: warning: Float 1.797693134862316E+3... out of range | |
# unknown: warning: instance variable @hostname not initialized | |
# unknown: warning: instance variable @hostname not initialized | |
# Segmentation fault |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment