求源码阅读-Day4求源码阅读-Day4adaptersself.mountHTTPAdapterPoolManagerSummaryadapters继续往下看:session.pyclassSession(SessionRedirectMixin):....#默认连接adapters.self.adapters=OrderedDict()self.mount('https://',HTTPAdapter())self.mount('http://',HTTPAdapter())调用了OrderedDict方法,这个方法在header中声明fromcollectionsimportOrderedDict这个在Requests源码阅读-Day2中有提到,这里就不说了,主要说说self.mount和HTTPAdapterself.mountsessions.pydefmount(self,prefix,adapter):"""将连接适配器注册到前缀。适配器按前缀长度降序排列。"""self.adapters[prefix]=adapterkeys_to_move=[kforkinself.adaptersiflen(k)
