service $anchorScroll $cacheFactory $compile $controller $document $exceptionHandler $filter $http $httpBackend angular.noop angular.toJson angular.uppercase angular.version module ngMock service $exceptionHandler $httpBackend angular.mock.TzDate module AUTO service $injector $provide ngCookies service $cookies $cookieStore ngMockE2E service $httpBackend
这些规则最终在Collector的httpBackend成员中执行。 一个Collector只有一个httpBackend结构体指针,而一个httpBackend结构体可以有一组规则 type httpBackend struct { LimitRules []*LimitRule c.Limit(&colly.LimitRule{DomainGlob: "*", Parallelism: 2}) Collector的Limit最终会调用到httpBackend的Limit 当发起请求时,流程最终会走到httpBackend的Do方法 func (h *httpBackend) Do(request *http.Request, bodySize int) (*Response httpBackend的Do方法最终将被Collector的fetch方法调用,而该方法可以被异步执行,即是一个goroutine。这就意味着承载Do逻辑的goroutine执行完毕后就会退出。
ScrapedCallback requestCount uint32 responseCount uint32 backend *httpBackend HTMLElement) ChildAttr(goquerySelector, attrName string) string K,http_backend.go定义了,用户设置的一些限制性条件 type httpBackend regexp.Regexp compiledGlob glob.Glob } func (r *LimitRule) Match(domain string) bool func (h *httpBackend
JsonpClientBackend 类及构造函数 @Injectable() export class JsonpClientBackend implements HttpBackend { constructor private callbackMap: JsonpCallbackContext, @Inject(DOCUMENT) private document: any) {} } 其中 HttpBackend 接口的定义如下: export abstract class HttpBackend implements HttpHandler { abstract handle(req: HttpRequest
其次就是给测试带来的麻烦,我们不得不使用$httpBackend来模拟一个HTTP请求的发送。
[]ScrapedCallback requestCount uint32 responseCount uint32 backend *httpBackend
$httpBackend HTTP backend used by the service that delegates to XMLHttpRequest object or JSONP and deals