From: Steve C. <sco...@gm...> - 2009-02-14 17:02:36
|
Hi everyone. I'm trying to make my own URL Protocol. I've been marching along pretty well but have hit a hang problem - if you can spot the problem I'd appreciate help, but I might be even more interested in what you'd do to debug the problem - I don't even know what to try next. It seems that I've defined startLoading properly - the framework complains if it's not there, or the method signature is incorrect. canonicalRequestForRequest gets called and then the whole operation hangs - startLoading never gets invoked. My class: require 'osx/cocoa' OSX.require_framework 'WebKit' class LocalProtocol < OSX::NSURLProtocol objc_class_method(:canInitWithRequest_, '@:@@') def self.canInitWithRequest(ns_url_request) p" canInitWithRequest" 0 end objc_class_method(:canonicalRequestForRequest_, '@:@@') def self.canonicalRequestForRequest(ns_url_request) p"canonicalRequestForRequest #{ns_url_request.inspect}" ns_url_request end def startLoading p "startLoading" end def stopLoading p "stopLoading" end end Calling code: protocol = LocalProtocol.alloc OSX::NSURLProtocol.registerClass(LocalProtocol) url = OSX::NSURL.alloc.initWithString("local://foo") url_request = OSX::NSURLRequest.requestWithURL(url) url_response = OSX::NSURLResponse.alloc response = OSX::NSURLConnection.sendSynchronousRequest_returningResponse_error(url_request, url_response, nil) str = "." * response.length response.getBytes_length(str) Console result: " canInitWithRequest" " canInitWithRequest" " canInitWithRequest" "canonicalRequestForRequest #<OSX::NSURLRequest:0x8beeee class='NSURLRequest' id=0x2003e50>" <HANGS HERE FOREVER> Regards, Steve |