OLD | NEW |
---|---|
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 package org.chromium.net.urlconnection; | 5 package org.chromium.net.urlconnection; |
6 | 6 |
7 import android.util.Pair; | 7 import android.util.Pair; |
8 | 8 |
9 import org.chromium.net.ExtendedResponseInfo; | 9 import org.chromium.net.ExtendedResponseInfo; |
10 import org.chromium.net.ResponseInfo; | 10 import org.chromium.net.ResponseInfo; |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
64 @Override | 64 @Override |
65 public void connect() throws IOException { | 65 public void connect() throws IOException { |
66 if (connected) { | 66 if (connected) { |
67 checkHasResponse(); | 67 checkHasResponse(); |
68 return; | 68 return; |
69 } | 69 } |
70 connected = true; | 70 connected = true; |
71 for (Pair<String, String> requestHeader : mRequestHeaders) { | 71 for (Pair<String, String> requestHeader : mRequestHeaders) { |
72 mRequest.addHeader(requestHeader.first, requestHeader.second); | 72 mRequest.addHeader(requestHeader.first, requestHeader.second); |
73 } | 73 } |
74 if (!getUseCaches()) { | |
mmenke
2015/01/22 16:21:20
Can you add a test for this, ideally one that comp
xunjieli
2015/01/26 21:36:09
Partially done. It looks like the default implemen
| |
75 mRequest.bypassCache(); | |
76 } | |
74 mRequest.start(); | 77 mRequest.start(); |
75 // Blocks until onResponseStarted or onFailed is called. | 78 // Blocks until onResponseStarted or onFailed is called. |
76 mMessageLoop.loop(); | 79 mMessageLoop.loop(); |
77 checkHasResponse(); | 80 checkHasResponse(); |
78 } | 81 } |
79 | 82 |
80 /** | 83 /** |
81 * Releases this connection so that its resources may be either reused or | 84 * Releases this connection so that its resources may be either reused or |
82 * closed. | 85 * closed. |
83 */ | 86 */ |
(...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
338 */ | 341 */ |
339 private void checkHasResponse() throws IOException { | 342 private void checkHasResponse() throws IOException { |
340 if (mException != null) { | 343 if (mException != null) { |
341 throw mException; | 344 throw mException; |
342 } else if (mResponseInfo == null) { | 345 } else if (mResponseInfo == null) { |
343 throw new NullPointerException( | 346 throw new NullPointerException( |
344 "Response info is null when there is no exception."); | 347 "Response info is null when there is no exception."); |
345 } | 348 } |
346 } | 349 } |
347 } | 350 } |
OLD | NEW |