Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(314)

Unified Diff: net/http/http_util.cc

Issue 706203003: Update from https://crrev.com/303153 (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 6 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « net/http/http_util.h ('k') | net/http/http_util_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/http/http_util.cc
diff --git a/net/http/http_util.cc b/net/http/http_util.cc
index 4574c7fd25f661e4259ac9af7b507eec4fb0191b..9bdc04596a5963a4aef6a857d610d5d6f812cbef 100644
--- a/net/http/http_util.cc
+++ b/net/http/http_util.cc
@@ -275,6 +275,29 @@ bool HttpUtil::ParseRangeHeader(const std::string& ranges_specifier,
}
// static
+bool HttpUtil::ParseRetryAfterHeader(const std::string& retry_after_string,
+ base::Time now,
+ base::TimeDelta* retry_after) {
+ int seconds;
+ base::Time time;
+ base::TimeDelta interval;
+
+ if (base::StringToInt(retry_after_string, &seconds)) {
+ interval = base::TimeDelta::FromSeconds(seconds);
+ } else if (base::Time::FromUTCString(retry_after_string.c_str(), &time)) {
+ interval = time - now;
+ } else {
+ return false;
+ }
+
+ if (interval < base::TimeDelta::FromSeconds(0))
+ return false;
+
+ *retry_after = interval;
+ return true;
+}
+
+// static
bool HttpUtil::HasHeader(const std::string& headers, const char* name) {
size_t name_len = strlen(name);
std::string::const_iterator it =
« no previous file with comments | « net/http/http_util.h ('k') | net/http/http_util_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698