Пример #1
0
		bool Process(string contentType, IO.IByteInDevice device, Func<string, IO.IByteInDevice, bool> process)
		{
			bool result = false;
			if (contentType.NotNull() && contentType.StartsWith("multipart/x-mixed-replace"))
			{
				byte[] boundary = this.GetBoundary(contentType);
				device.Skip(boundary);
				while (this.response.NotNull() && device.Opened)
				{
					Collection.IDictionary<string, string> headers = new Collection.Dictionary<string, string>(
						                                                 device.Read(13, 10, 13, 10).Decode().Join()
						.Split(new string[] { "\r\n" }, StringSplitOptions.RemoveEmptyEntries)
						.Map(header =>
						{
							string[] splitted = header.Split(new string[] { ": " }, 2, StringSplitOptions.None);
							return splitted.Length == 2 ? KeyValue.Create(splitted[0], splitted[1]) : KeyValue.Create((string)null, (string)null);
						}));
					this.Process(headers["Content-Type"], Wrap.PartialByteInDevice.Open(device, boundary), process);
				}
			}
			else
				result = process(contentType, device);
			return result;
		}
Пример #2
0
		Parser(IO.ICharacterReader reader)
		{
			this.tokenizer = new Tokenizer(reader);
		}
Пример #3
0
		public static Parser Open(IO.ICharacterReader reader)
		{
			return reader.NotNull() ? new Parser(reader) : null;
		}
Пример #4
0
		public static Parser Open(IO.ICharacterInDevice device)
		{
			return Parser.Open(IO.CharacterReader.Open(device));
		}
Пример #5
0
		public static Parser Open(IO.IByteDevice device)
		{
			return Parser.Open(IO.CharacterDevice.Open(device));
		}
Пример #6
0
		public static Parser Open(IO.IByteInDevice device)
		{
			return Parser.Open(IO.ByteDeviceCombiner.Open(device));
		}
Пример #7
0
 Parser(IO.ICharacterReader reader)
 {
     this.reader = reader;
 }
Пример #8
0
		public Formatting(IO.ICharacterWriter backend)
		{
			this.writer = new IO.Text.Indenter(backend);
			this.Format = true;
		}