Ejemplo n.º 1
0
 public long GetTotalLengthFromContentRange()
 {
     if (!string.IsNullOrEmpty(contentRange))
     {
         return(WebRequestExtensions.ContentLengthFromContentRange(contentRange));
     }
     return(-1);
 }
Ejemplo n.º 2
0
        internal void SetHeaders(string headers)
        {
            var lines  = headers.Split('\r', '\n');
            var status = lines[0];

            this.statusCode        = (HttpStatusCode)Int32.Parse(status.Split(' ')[1].Trim());
            this.statusDescription = status.Split(' ')[2];
            foreach (var line in lines)
            {
                var index = line.IndexOf(':');
                if (index > 0)
                {
                    var key   = line.Substring(0, index).ToLowerInvariant();
                    var value = line.Substring(index + 1).Trim();
                    switch (key)
                    {
                    case "content-length":
                        this.contentLength = Int64.Parse(value);
                        break;

                    case "content-range":
                        this.contentRange = value;
                        break;

                    case "content-type":
                        this.contentType = value;
                        break;

                    case "content-disposition":
                        this.contentDispositionFileName = WebRequestExtensions.GetContentDispositionFileName(value);
                        break;

                    default:
                        break;
                    }
                }
            }
        }