Method: WebStub::Protocol#startLoading

Defined in:
lib/webstub/protocol.rb

#startLoadingObject



82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
# File 'lib/webstub/protocol.rb', line 82

def startLoading
  request = self.request
  client = self.client

  unless @stub = self.class.stub_for(self.request)
    error = NSError.errorWithDomain("WebStub", code:0, userInfo:{ NSLocalizedDescriptionKey: "network access is not permitted!"})
    client.URLProtocol(self, didFailWithError:error)

    return
  end

  if body = self.class.parse_body(request)
    @stub.do_callback(self.request.allHTTPHeaderFields, body)
  end
  @timer = NSTimer.scheduledTimerWithTimeInterval(@stub.response_delay, target:self, selector: :completeLoading, userInfo:nil, repeats:false)
end