private void WriteMetadata(JObject metadata)
{
if (metadata == null || metadata.Count == 0)
{
webRequest.ContentLength = 0;
return;
}
foreach (var prop in metadata)
{
if (prop.Value == null)
continue;
if (prop.Value.Type == JTokenType.Object ||
prop.Value.Type == JTokenType.Array)
continue;
var headerName = prop.Key;
if (headerName == "ETag")
headerName = "If-Match";
var value = prop.Value.Value<object>().ToString();
switch (headerName)
{
case "Content-Length":
break;
case "Content-Type":
webRequest.ContentType = value;
break;
default:
webRequest.Headers[headerName] = value;
break;
}
}
}