internal static void ParseAmzRestoreHeader(string header, out bool restoreInProgress, out DateTime? restoreExpiration)
{
const string ONGOING_REQUEST = "ongoing-request";
const string EXPIRY_DATE = "expiry-date";
restoreExpiration = null;
restoreInProgress = false;
if (header == null)
return;
int pos = header.IndexOf(ONGOING_REQUEST, StringComparison.Ordinal);
if (pos != -1)
{
int startPos = header.IndexOf('"', pos) + 1;
int endPos = header.IndexOf('"', startPos + 1);
string value = header.Substring(startPos, endPos - startPos);
bool parseBool;
if (Boolean.TryParse(value, out parseBool))
restoreInProgress = parseBool;
}
pos = header.IndexOf(EXPIRY_DATE, StringComparison.Ordinal);
if (pos != -1)
{
int startPos = header.IndexOf('"', pos) + 1;
int endPos = header.IndexOf('"', startPos + 1);
string value = header.Substring(startPos, endPos - startPos);
DateTime parseDate;
if (DateTime.TryParseExact(value, Amazon.Util.AWSSDKUtils.RFC822DateFormat, CultureInfo.InvariantCulture, DateTimeStyles.None, out parseDate))
restoreExpiration = parseDate;
}
}