| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2004 The WebRTC Project Authors. All rights reserved. | 2 * Copyright 2004 The WebRTC Project Authors. All rights reserved. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
| 5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
| 6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
| 7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
| 8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
| 9 */ | 9 */ |
| 10 | 10 |
| 11 #include <time.h> | 11 #include <time.h> |
| 12 #include <algorithm> | 12 #include <algorithm> |
| 13 #include <memory> | 13 #include <memory> |
| 14 #include "webrtc/base/asyncsocket.h" | 14 #include "webrtc/base/asyncsocket.h" |
| 15 #include "webrtc/base/checks.h" |
| 15 #include "webrtc/base/common.h" | 16 #include "webrtc/base/common.h" |
| 16 #include "webrtc/base/diskcache.h" | 17 #include "webrtc/base/diskcache.h" |
| 17 #include "webrtc/base/httpclient.h" | 18 #include "webrtc/base/httpclient.h" |
| 18 #include "webrtc/base/httpcommon-inl.h" | 19 #include "webrtc/base/httpcommon-inl.h" |
| 19 #include "webrtc/base/logging.h" | 20 #include "webrtc/base/logging.h" |
| 20 #include "webrtc/base/pathutils.h" | 21 #include "webrtc/base/pathutils.h" |
| 21 #include "webrtc/base/socketstream.h" | 22 #include "webrtc/base/socketstream.h" |
| 22 #include "webrtc/base/stringencode.h" | 23 #include "webrtc/base/stringencode.h" |
| 23 #include "webrtc/base/stringutils.h" | 24 #include "webrtc/base/stringutils.h" |
| 24 #include "webrtc/base/thread.h" | 25 #include "webrtc/base/thread.h" |
| (...skipping 304 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 329 request().setHeader(HH_HOST, HttpAddress(server_, false), true); | 330 request().setHeader(HH_HOST, HttpAddress(server_, false), true); |
| 330 } | 331 } |
| 331 | 332 |
| 332 StreamInterface* HttpClient::GetDocumentStream() { | 333 StreamInterface* HttpClient::GetDocumentStream() { |
| 333 return base_.GetDocumentStream(); | 334 return base_.GetDocumentStream(); |
| 334 } | 335 } |
| 335 | 336 |
| 336 void HttpClient::start() { | 337 void HttpClient::start() { |
| 337 if (base_.mode() != HM_NONE) { | 338 if (base_.mode() != HM_NONE) { |
| 338 // call reset() to abort an in-progress request | 339 // call reset() to abort an in-progress request |
| 339 ASSERT(false); | 340 RTC_NOTREACHED(); |
| 340 return; | 341 return; |
| 341 } | 342 } |
| 342 | 343 |
| 343 ASSERT(!IsCacheActive()); | 344 ASSERT(!IsCacheActive()); |
| 344 | 345 |
| 345 if (request().hasHeader(HH_TRANSFER_ENCODING, NULL)) { | 346 if (request().hasHeader(HH_TRANSFER_ENCODING, NULL)) { |
| 346 // Exact size must be known on the client. Instead of using chunked | 347 // Exact size must be known on the client. Instead of using chunked |
| 347 // encoding, wrap data with auto-caching file or memory stream. | 348 // encoding, wrap data with auto-caching file or memory stream. |
| 348 ASSERT(false); | 349 RTC_NOTREACHED(); |
| 349 return; | 350 return; |
| 350 } | 351 } |
| 351 | 352 |
| 352 attempt_ = 0; | 353 attempt_ = 0; |
| 353 | 354 |
| 354 // If no content has been specified, using length of 0. | 355 // If no content has been specified, using length of 0. |
| 355 request().setHeader(HH_CONTENT_LENGTH, "0", false); | 356 request().setHeader(HH_CONTENT_LENGTH, "0", false); |
| 356 | 357 |
| 357 if (!agent_.empty()) { | 358 if (!agent_.empty()) { |
| 358 request().setHeader(HH_USER_AGENT, agent_, false); | 359 request().setHeader(HH_USER_AGENT, agent_, false); |
| (...skipping 449 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 808 } else if (CS_READING == cache_state_) { | 809 } else if (CS_READING == cache_state_) { |
| 809 cache_state_ = CS_READY; | 810 cache_state_ = CS_READY; |
| 810 } | 811 } |
| 811 release(); | 812 release(); |
| 812 SignalHttpClientComplete(this, err); | 813 SignalHttpClientComplete(this, err); |
| 813 } | 814 } |
| 814 | 815 |
| 815 void HttpClient::onHttpClosed(HttpError err) { | 816 void HttpClient::onHttpClosed(HttpError err) { |
| 816 // This shouldn't occur, since we return the stream to the pool upon command | 817 // This shouldn't occur, since we return the stream to the pool upon command |
| 817 // completion. | 818 // completion. |
| 818 ASSERT(false); | 819 RTC_NOTREACHED(); |
| 819 } | 820 } |
| 820 | 821 |
| 821 ////////////////////////////////////////////////////////////////////// | 822 ////////////////////////////////////////////////////////////////////// |
| 822 // HttpClientDefault | 823 // HttpClientDefault |
| 823 ////////////////////////////////////////////////////////////////////// | 824 ////////////////////////////////////////////////////////////////////// |
| 824 | 825 |
| 825 HttpClientDefault::HttpClientDefault(SocketFactory* factory, | 826 HttpClientDefault::HttpClientDefault(SocketFactory* factory, |
| 826 const std::string& agent, | 827 const std::string& agent, |
| 827 HttpTransaction* transaction) | 828 HttpTransaction* transaction) |
| 828 : ReuseSocketPool(factory ? factory : Thread::Current()->socketserver()), | 829 : ReuseSocketPool(factory ? factory : Thread::Current()->socketserver()), |
| 829 HttpClient(agent, NULL, transaction) { | 830 HttpClient(agent, NULL, transaction) { |
| 830 set_pool(this); | 831 set_pool(this); |
| 831 } | 832 } |
| 832 | 833 |
| 833 ////////////////////////////////////////////////////////////////////// | 834 ////////////////////////////////////////////////////////////////////// |
| 834 | 835 |
| 835 } // namespace rtc | 836 } // namespace rtc |
| OLD | NEW |