public override bool TryParseValue(string value, object storeValue, ref int index, out object parsedValue)
{
parsedValue = null;
// Some headers support empty/null values. This one doesn't.
if (string.IsNullOrEmpty(value) || (index == value.Length))
{
return false;
}
string base64String = value;
if (index > 0)
{
base64String = value.Substring(index);
}
// Try convert the string (we assume it's a valid Base64 string) to byte[].
try
{
parsedValue = Convert.FromBase64String(base64String);
index = value.Length;
return true;
}
catch (FormatException e)
{
if (NetEventSource.IsEnabled) NetEventSource.Error(this, SR.Format(SR.net_http_parser_invalid_base64_string, base64String, e.Message));
}
return false;
}
}