在前面的文章中,我们提到过,在NetworkDispatcher中传入了BasicNetwork实例,BasicNetwork中又存在HurlStack对象,他们就是负责真正向网络发起请求的部分。
Android:Volley框架分析(三)—— Dispatcher中提到了下面的代码,由BasicNetwork对象发起请求。
NetworkResponse e = this.mNetwork.performRequest(request);
public NetworkResponse performRequest(Request<?> request) throws VolleyError {
long requestStart = SystemClock.elapsedRealtime();
while(true) {
HttpResponse httpResponse = null;
Object responseContents = null;
Map responseHeaders = Collections.emptyMap();
try {
HashMap e = new HashMap();
//从缓存中根据ETag和Last-Modified添加对应头信息
this.addCacheHeaders(e, request.getCacheEntry());
//执行HurlStack的网络请求
httpResponse = this.mHttpStack.performRequest(request, e);