| 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/checks.h" |
| 16 #include "webrtc/base/common.h" | |
| 17 #include "webrtc/base/diskcache.h" | 16 #include "webrtc/base/diskcache.h" |
| 18 #include "webrtc/base/httpclient.h" | 17 #include "webrtc/base/httpclient.h" |
| 19 #include "webrtc/base/httpcommon-inl.h" | 18 #include "webrtc/base/httpcommon-inl.h" |
| 20 #include "webrtc/base/logging.h" | 19 #include "webrtc/base/logging.h" |
| 21 #include "webrtc/base/pathutils.h" | 20 #include "webrtc/base/pathutils.h" |
| 22 #include "webrtc/base/socketstream.h" | 21 #include "webrtc/base/socketstream.h" |
| 23 #include "webrtc/base/stringencode.h" | 22 #include "webrtc/base/stringencode.h" |
| 24 #include "webrtc/base/stringutils.h" | 23 #include "webrtc/base/stringutils.h" |
| 25 #include "webrtc/base/thread.h" | 24 #include "webrtc/base/thread.h" |
| 25 #include "webrtc/common_types.h" |
| 26 | 26 |
| 27 namespace rtc { | 27 namespace rtc { |
| 28 | 28 |
| 29 ////////////////////////////////////////////////////////////////////// | 29 ////////////////////////////////////////////////////////////////////// |
| 30 // Helpers | 30 // Helpers |
| 31 ////////////////////////////////////////////////////////////////////// | 31 ////////////////////////////////////////////////////////////////////// |
| 32 | 32 |
| 33 namespace { | 33 namespace { |
| 34 | 34 |
| 35 const size_t kCacheHeader = 0; | 35 const size_t kCacheHeader = 0; |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 155 HttpRequestValidatorLevel(const HttpRequestData& request) { | 155 HttpRequestValidatorLevel(const HttpRequestData& request) { |
| 156 if (HV_GET != request.verb) | 156 if (HV_GET != request.verb) |
| 157 return HVS_STRONG; | 157 return HVS_STRONG; |
| 158 return request.hasHeader(HH_RANGE, NULL) ? HVS_STRONG : HVS_WEAK; | 158 return request.hasHeader(HH_RANGE, NULL) ? HVS_STRONG : HVS_WEAK; |
| 159 } | 159 } |
| 160 | 160 |
| 161 HttpValidatorStrength | 161 HttpValidatorStrength |
| 162 HttpResponseValidatorLevel(const HttpResponseData& response) { | 162 HttpResponseValidatorLevel(const HttpResponseData& response) { |
| 163 std::string value; | 163 std::string value; |
| 164 if (response.hasHeader(HH_ETAG, &value)) { | 164 if (response.hasHeader(HH_ETAG, &value)) { |
| 165 bool is_weak = (strnicmp(value.c_str(), "W/", 2) == 0); | 165 bool is_weak = (STR_NCASE_CMP(value.c_str(), "W/", 2) == 0); |
| 166 return is_weak ? HVS_WEAK : HVS_STRONG; | 166 return is_weak ? HVS_WEAK : HVS_STRONG; |
| 167 } | 167 } |
| 168 if (response.hasHeader(HH_LAST_MODIFIED, &value)) { | 168 if (response.hasHeader(HH_LAST_MODIFIED, &value)) { |
| 169 time_t last_modified, date; | 169 time_t last_modified, date; |
| 170 if (HttpDateToSeconds(value, &last_modified) | 170 if (HttpDateToSeconds(value, &last_modified) |
| 171 && response.hasHeader(HH_DATE, &value) | 171 && response.hasHeader(HH_DATE, &value) |
| 172 && HttpDateToSeconds(value, &date) | 172 && HttpDateToSeconds(value, &date) |
| 173 && (last_modified + 60 < date)) { | 173 && (last_modified + 60 < date)) { |
| 174 return HVS_STRONG; | 174 return HVS_STRONG; |
| 175 } | 175 } |
| (...skipping 651 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 827 const std::string& agent, | 827 const std::string& agent, |
| 828 HttpTransaction* transaction) | 828 HttpTransaction* transaction) |
| 829 : ReuseSocketPool(factory ? factory : Thread::Current()->socketserver()), | 829 : ReuseSocketPool(factory ? factory : Thread::Current()->socketserver()), |
| 830 HttpClient(agent, NULL, transaction) { | 830 HttpClient(agent, NULL, transaction) { |
| 831 set_pool(this); | 831 set_pool(this); |
| 832 } | 832 } |
| 833 | 833 |
| 834 ////////////////////////////////////////////////////////////////////// | 834 ////////////////////////////////////////////////////////////////////// |
| 835 | 835 |
| 836 } // namespace rtc | 836 } // namespace rtc |
| OLD | NEW |