| 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; | 5 package org.chromium.net; |
| 6 | 6 |
| 7 import android.content.Context; | 7 import android.content.Context; |
| 8 import android.text.TextUtils; | 8 import android.text.TextUtils; |
| 9 | 9 |
| 10 import org.apache.http.HttpStatus; | 10 import org.apache.http.HttpStatus; |
| 11 | 11 |
| 12 import java.io.FileNotFoundException; | 12 import java.io.FileNotFoundException; |
| 13 import java.io.IOException; | 13 import java.io.IOException; |
| 14 import java.io.InputStream; | 14 import java.io.InputStream; |
| 15 import java.io.OutputStream; | 15 import java.io.OutputStream; |
| 16 import java.net.HttpURLConnection; | 16 import java.net.HttpURLConnection; |
| 17 import java.net.URL; | 17 import java.net.URL; |
| 18 import java.nio.ByteBuffer; | 18 import java.nio.ByteBuffer; |
| 19 import java.nio.channels.ReadableByteChannel; | 19 import java.nio.channels.ReadableByteChannel; |
| 20 import java.nio.channels.WritableByteChannel; | 20 import java.nio.channels.WritableByteChannel; |
| 21 import java.util.List; |
| 21 import java.util.Map; | 22 import java.util.Map; |
| 22 import java.util.Map.Entry; | 23 import java.util.Map.Entry; |
| 23 import java.util.concurrent.ExecutorService; | 24 import java.util.concurrent.ExecutorService; |
| 24 import java.util.concurrent.Executors; | 25 import java.util.concurrent.Executors; |
| 25 import java.util.concurrent.ThreadFactory; | 26 import java.util.concurrent.ThreadFactory; |
| 26 import java.util.concurrent.atomic.AtomicInteger; | 27 import java.util.concurrent.atomic.AtomicInteger; |
| 27 import java.util.zip.GZIPInputStream; | 28 import java.util.zip.GZIPInputStream; |
| 28 | 29 |
| 29 /** | 30 /** |
| 30 * Network request using the HttpUrlConnection implementation. | 31 * Network request using the HttpUrlConnection implementation. |
| (...skipping 415 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 446 | 447 |
| 447 | 448 |
| 448 @Override | 449 @Override |
| 449 public String getHeader(String name) { | 450 public String getHeader(String name) { |
| 450 if (mConnection == null) { | 451 if (mConnection == null) { |
| 451 throw new IllegalStateException("Response headers not available"); | 452 throw new IllegalStateException("Response headers not available"); |
| 452 } | 453 } |
| 453 return mConnection.getHeaderField(name); | 454 return mConnection.getHeaderField(name); |
| 454 } | 455 } |
| 455 | 456 |
| 457 @Override |
| 458 public Map<String, List<String>> getAllHeaders() { |
| 459 if (mConnection == null) { |
| 460 throw new IllegalStateException("Response headers not available"); |
| 461 } |
| 462 return mConnection.getHeaderFields(); |
| 463 } |
| 464 |
| 456 private void validateNotStarted() { | 465 private void validateNotStarted() { |
| 457 if (mStarted) { | 466 if (mStarted) { |
| 458 throw new IllegalStateException("Request already started"); | 467 throw new IllegalStateException("Request already started"); |
| 459 } | 468 } |
| 460 } | 469 } |
| 461 } | 470 } |
| OLD | NEW |