protected Dictionary <string, object> ParseForm(Bamboo.DataStructures.MemoryStream stream) { if (stream == null || stream.Length == 0) { return(new Dictionary <string, object>(0)); } else { return(ParseVariables(new System.IO.StreamReader(stream))); } }
public static System.IO.Stream Get(string url, Bamboo.DataStructures.BufferPool bufferPool) { System.Net.WebRequest request = System.Net.HttpWebRequest.Create(url); request.Method = "GET"; System.Net.WebResponse response = request.GetResponse(); System.IO.Stream responseStream = new Bamboo.DataStructures.MemoryStream(bufferPool); Copy(response.GetResponseStream(), responseStream, (int)response.ContentLength, bufferPool); response.Close(); responseStream.Position = 0; return(responseStream); }
private Bamboo.DataStructures.MemoryStream ReadContent(int contentLength, System.IO.Stream stream, byte[] buffer) { Bamboo.DataStructures.MemoryStream content = new Bamboo.DataStructures.MemoryStream(this._bufferPool); int bytesRemaining = contentLength; while (bytesRemaining > 0) { int bytesRead = stream.Read(buffer, 0, Math.Min(buffer.Length, bytesRemaining)); content.Write(buffer, 0, bytesRead); bytesRemaining -= bytesRead; } content.Position = 0; return(content); }
public HttpRequest(string method, string path, string host, int contentLength, string contentType, Bamboo.DataStructures.MemoryStream content) { this.Method = method; int index = path.IndexOf("?"); if (index == -1) { this.Path = path; this.Query = ""; } else { this.Path = path.Substring(0, index); this.Query = path.Substring(index + 1); } this.Host = host; this.ContentLength = contentLength; this.ContentType = contentType; this.Content = content; }
public static System.IO.Stream Post(string url, System.IO.Stream stream, Bamboo.DataStructures.BufferPool bufferPool) { System.Net.WebRequest request = System.Net.HttpWebRequest.Create(url); request.Method = "POST"; System.IO.Stream requestStream = request.GetRequestStream(); Copy(stream, requestStream, (int)stream.Length, bufferPool); requestStream.Close(); System.Net.WebResponse response = request.GetResponse(); if (response.ContentLength == 0) { response.Close(); return(null); } System.IO.Stream responseStream = new Bamboo.DataStructures.MemoryStream(bufferPool); Copy(response.GetResponseStream(), responseStream, (int)response.ContentLength, bufferPool); response.Close(); if (responseStream.Length > 0) { responseStream.Position = 0; } return(responseStream); }
public HttpResponse(Bamboo.DataStructures.BufferPool bufferPool) { this.Status = 200; this.Content = new Bamboo.DataStructures.MemoryStream(bufferPool); this.Writer = new System.IO.StreamWriter(this.Content); }