示例#1
0
        public static void WriteLine(this FileStream fs, string line)
        {
            var buff = line.GetASCIIBytes();

            fs.Write(buff, 0, buff.Length);
            fs.WriteLine();
        }
示例#2
0
        public static void WriteLine(this FileStream fs, string format, params object[] values)
        {
            var buff = string.Format(format, values).GetASCIIBytes();

            fs.Write(buff, 0, buff.Length);
            fs.WriteLine();
        }
        internal void Store(HTTPResponse response)
        {
            if (!HTTPCacheService.IsSupported)
            {
                return;
            }

            string path = GetPath();

            // Path name too long, we don't want to get exceptions
            if (path.Length > HTTPManager.MaxPathLength)
            {
                return;
            }

            if (File.Exists(path))
            {
                Delete();
            }

            using (FileStream writer = new FileStream(path, FileMode.Create))
            {
                writer.WriteLine("HTTP/1.1 {0} {1}", response.StatusCode, response.Message);
                foreach (var kvp in response.Headers)
                {
                    for (int i = 0; i < kvp.Value.Count; ++i)
                    {
                        writer.WriteLine("{0}: {1}", kvp.Key, kvp.Value[i]);
                    }
                }

                writer.WriteLine();

                writer.Write(response.Data, 0, response.Data.Length);
            }

            BodyLength = response.Data.Length;
            LastAccess = DateTime.UtcNow;

            SetUpCachingValues(response);
        }
示例#4
0
 public static void WriteLine(this FileStream fs)
 {
     fs.Write(HTTPRequest.EOL, 0, 2);
 }