HttpClient===》HttpMessageHandler===》HttpMessageHandlerBuilder===》DefaultHttpMessageHandlerBuilder
没有自定义的话,将采取DefaultHttpMessageHandlerBuilder中的实现
HttpMessageHandlerBuilder中build方法在DefaultHttpMessageHandlerBuilder为实现,并调用父级CreateHandlerPipeline来实现HttpMessageHandler
(就直接new对象),链接器DelegatingHandler 也是直接new List<DelegatingHandler>();
在CreateHandlerPipeline 中将DelegatingHandler 设置为只读
然后遍历 List<DelegatingHandler>()
primaryHandler 主处理器,其他的为DelegatingHandler 处理器,通过InnerHandler 引用下一个处理器
部分源码
标签:InnerHandler,next,构建,DelegatingHandler,HttpMessageHandler,DefaultHttpMessageHand From: https://www.cnblogs.com/liujian1368928/p/17204795.html
for (int i = additionalHandlersList.Count - 1; i >= 0; i--) { handler.InnerHandler = next;//InnerHandler为 HttpMessageHandler next = handler;
}
return next;