public AspNetResponse(HttpContext context) { NativeContext = context; Headers = new HttpHeaderDictionary(); Entity = new HttpEntity(Headers, NativeContext.Response.OutputStream); // context.Response.AddOnSendingHeaders(httpContext => _nativeHeadersSent = true); }
public InMemoryRequest() { Headers = new HttpHeaderDictionary(); Headers.Add("Host", "http://localhost/"); Entity = new HttpEntity(Headers, new MemoryStream()); CodecParameters = new List <string>(); }
void SetHeaders(HttpHeaderDictionary headers, HttpResponseHeaders responseMessageHeaders) { foreach (var header in responseMessageHeaders) { SetHeader(headers, header.Key, header.Value); } }
public HttpListenerResponse(HttpListenerCommunicationContext context, System.Net.HttpListenerResponse response) { _context = context; _nativeResponse = response; Headers = new HttpHeaderDictionary(); Entity = new HttpEntity(Headers, response.OutputStream); }
public HttpListenerResponse(HttpListenerCommunicationContext context, System.Net.HttpListenerResponse response) { _context = context; _nativeResponse = response; Headers = new HttpHeaderDictionary(); Entity = new HttpEntity(Headers, _tempStream); _nativeResponse.SendChunked = false; }
public HttpListenerResponse(HttpListenerCommunicationContext context, System.Net.HttpListenerResponse response) { _context = context; _nativeResponse = response; Headers = new HttpHeaderDictionary(); // TODO: Wrap stream and send chunked when needed if write starts before sending response Entity = new HttpEntity(Headers, _tempStream); _nativeResponse.SendChunked = false; }
public OwinResponse(IOwinContext context) { var response = context.Response; NativeContext = response; Headers = new HttpHeaderDictionary(); var delayedStream = new DelayedStream(context.Response.Body); Entity = new HttpEntity(Headers, delayedStream); }
public static void ShouldNotHaveHeader(this HttpHeaderDictionary headers, string fieldName) { headers[fieldName].ShouldBeNull(); headers.TryGetValue(fieldName, out _).ShouldBeFalse(); headers.TryGetValues(fieldName, out _).ShouldBeFalse(); headers.Keys.ShouldNotContain(fieldName); }
public void create_from_nvc() { var nvc = new NameValueCollection(); nvc.Add("key", "value"); nvc.Add("key", "value2"); headers = new HttpHeaderDictionary(nvc); headers.ShouldHaveHeaderValues("key", "value", "value2"); }
public OwinResponse(IOwinContext context) { var response = context.Response; NativeContext = response; Headers = new HttpHeaderDictionary(); //var delayedStream = new DelayedStream(context.Response.Body); Entity = new HttpEntity(Headers, context.Response.Body); }
public HttpEntity(HttpHeaderDictionary messageheaders, Stream entityBodyStream) { Headers = messageheaders; if (entityBodyStream != null) { Stream = new LengthTrackingStream(entityBodyStream); } Errors = new List<Error>(); }
public void op_Contains_Token() { var obj = new HttpHeaderDictionary(); Assert.False(obj.Contains("name")); obj.Add(new HttpHeader("name", "value")); Assert.True(obj.Contains("name")); }
public OwinResponse(IOwinContext context) { var response = context.Response; context.Response.OnSendingHeaders(r => r.NativeHeadersSent = true, this); NativeContext = response; Headers = new HttpHeaderDictionary(); Entity = new HttpEntity(Headers, context.Response.Body); _statusCode = context.Response.StatusCode; }
public void op_Add_HttpHeader() { var expected = new HttpHeader("name", "value"); var obj = new HttpHeaderDictionary { expected }; Assert.Equal("value", obj["name"]); }
public WebRequestResponse(HttpWebResponse response) { _response = response; if (!string.IsNullOrEmpty(response.ContentType)) ContentType = new MediaType(response.ContentType); ContentLength = response.ContentLength; Headers = new HttpHeaderDictionary(); foreach (string headerName in response.Headers.AllKeys) Headers[headerName] = response.Headers[headerName]; }
void PopulateHeaders(IOwinRequest ctx) { var headerCollection = new HttpHeaderDictionary(); foreach (var header in ctx.Headers) { headerCollection.Add(header.Key, string.Join(",", header.Value)); } Headers = headerCollection; }
public HttpListenerRequest(HttpListenerCommunicationContext context, System.Net.HttpListenerRequest request) { _context = context; _nativeRequest = request; Uri = _nativeRequest.Url; CodecParameters = new List<string>(); Headers = new HttpHeaderDictionary(_nativeRequest.Headers); Entity = new HttpEntity(Headers, new HistoryStream(_nativeRequest.InputStream)); if (!string.IsNullOrEmpty(_nativeRequest.ContentType)) Entity.ContentType = new MediaType(_nativeRequest.ContentType); }
public AspNetRequest(HttpContext context) { NativeContext = context; Uri = NativeContext.Request.Url; Headers = new HttpHeaderDictionary(NativeContext.Request.Headers); // TODO: Finish off the new input stream that goes to the // WorkerRequest and bypasses asp.net completely. Entity = new HttpEntity(Headers, NativeContext.Request.InputStream); if (!string.IsNullOrEmpty(NativeContext.Request.ContentType)) Entity.ContentType = new MediaType(NativeContext.Request.ContentType); CodecParameters = new List<string>(); }
public WebRequestResponse(HttpWebResponse response) { _response = response; if (!string.IsNullOrEmpty(response.ContentType)) { ContentType = new MediaType(response.ContentType); } ContentLength = response.ContentLength; Headers = new HttpHeaderDictionary(); foreach (string headerName in response.Headers.AllKeys) { Headers[headerName] = response.Headers[headerName]; } }
public AspNetRequest(HttpContext context) { NativeContext = context; Uri = NativeContext.Request.Url; Headers = new HttpHeaderDictionary(NativeContext.Request.Headers); Entity = new HttpEntity(Headers, NativeContext.Request.InputStream); if (!string.IsNullOrEmpty(NativeContext.Request.ContentType)) { Entity.ContentType = new MediaType(NativeContext.Request.ContentType); } CodecParameters = new List <string>(); }
public AspNetRequest(HttpContext context) { NativeContext = context; Uri = NativeContext.Request.Url; Headers = new HttpHeaderDictionary(NativeContext.Request.Headers); // TODO: Finish off the new input stream that goes to the // WorkerRequest and bypasses asp.net completely. Entity = new HttpEntity(Headers, NativeContext.Request.InputStream); if (!string.IsNullOrEmpty(NativeContext.Request.ContentType)) { Entity.ContentType = new MediaType(NativeContext.Request.ContentType); } CodecParameters = new List <string>(); }
public HttpListenerRequest(HttpListenerCommunicationContext context, System.Net.HttpListenerRequest request) { _context = context; _nativeRequest = request; Uri = _nativeRequest.Url; CodecParameters = new List <string>(); Headers = new HttpHeaderDictionary(_nativeRequest.Headers); Entity = new HttpEntity(Headers, _nativeRequest.InputStream); if (!string.IsNullOrEmpty(_nativeRequest.ContentType)) { Entity.ContentType = new MediaType(_nativeRequest.ContentType); } }
private void PopulateHeaders(IOwinRequest ctx) { var headerCollection = new NameValueCollection(); foreach (var header in ctx.Headers) { headerCollection.Add(header.Key, header.Value.First()); } Headers = new HttpHeaderDictionary(headerCollection); if (Headers.ContentLength == null) { Headers.ContentLength = ctx.Body.Length; } }
static void SetHeader(HttpHeaderDictionary headers, string fieldName, IEnumerable <string> fieldValues) { if (HttpHeaderClassification.IsHopByHopHeader(fieldName)) { return; } if (HttpHeaderClassification.IsAppendedOnForwardHeader(fieldName)) { headers.AddValues(fieldName, fieldValues); } else { headers.Remove(fieldName); headers.AddValues(fieldName, fieldValues); } }
public OwinResponse(IOwinContext context) { _nativeAssignements = new Dictionary <string, Action <IOwinResponse, string> >(StringComparer.OrdinalIgnoreCase) { ["content-type"] = (r, val) => r.ContentType = val, ["content-length"] = (r, val) => r.ContentLength = Headers.ContentLength }; var response = context.Response; context.Response.OnSendingHeaders(r => r.NativeHeadersSent = true, this); NativeContext = response; Headers = new HttpHeaderDictionary(); Entity = new HttpEntity(Headers, context.Response.Body); _statusCode = context.Response.StatusCode; }
private void WriteBlock(string transferId, long blockNumber, Stream input) { //get meta information from headers VfsHttpHeaders headerNames = VfsHttpHeaders.Default; HttpHeaderDictionary headers = Request.Headers; var blockLength = Convert.ToInt32(headers[headerNames.BlockLength]); var isLastBlock = headers.ContainsKey(headerNames.IsLastBlock) ? Convert.ToBoolean(headers[headerNames.IsLastBlock]) : false; var offset = Convert.ToInt64(headers[headerNames.BlockOffset]); StreamedDataBlock block = new StreamedDataBlock { TransferTokenId = transferId, BlockNumber = blockNumber, IsLastBlock = isLastBlock, BlockLength = blockLength, Offset = offset, Data = new NonSeekableStream(input) }; FileSystem.UploadTransfers.WriteBlockStreamed(block); }
public static void ShouldHaveHeaderValues(this HttpHeaderDictionary headers, string fieldName, params string[] fieldValue) { var combinedFieldValues = string.Join(",", fieldValue); // indexer headers[fieldName].ShouldBe(combinedFieldValues); // singular headers.TryGetValue(fieldName, out var singular).ShouldBeTrue(); singular.ShouldBe(combinedFieldValues); // multi headers.TryGetValues(fieldName, out var all).ShouldBeTrue(); all.ShouldBe(fieldValue); // keys contain headers.Keys.ShouldContain(fieldName); headers.ContainsKey(fieldName).ShouldBeTrue(); // values contain (why again, why?) headers.Values.ShouldContain(combinedFieldValues); foreach (var val in fieldValue) { headers.Contains(new KeyValuePair <string, string>(fieldName, val)).ShouldBeTrue(); } // convert to dictionary new Dictionary <string, string>(headers)[fieldName].ShouldBe(combinedFieldValues); // copy to array (why why why?) var array = new KeyValuePair <string, string> [10]; headers.CopyTo(array, 0); array.Any(item => item.Key == fieldName && item.Value == combinedFieldValues).ShouldBeTrue(); }
public MultipartHttpEntity() { Headers = new HttpHeaderDictionary(); }
public InMemoryRequest() { Headers = new HttpHeaderDictionary(); Entity = new HttpEntity(Headers, new MemoryStream()); CodecParameters = new List<string>(); }
public InMemoryResponse() { Headers = new HttpHeaderDictionary(); Entity = new HttpEntity(Headers, _outputStream); }
public void op_GetEnumerator() { var expected = new KeyValuePair<Token, string>("name", "value"); var obj = new HttpHeaderDictionary { { "name", "value" } }; foreach (var actual in obj) { Assert.Equal(expected, actual); } }
public AspNetResponse(HttpContext context) { NativeContext = context; Headers = new HttpHeaderDictionary(); Entity = new HttpEntity(Headers, NativeContext.Response.OutputStream); }
public InMemoryRequest() { Headers = new HttpHeaderDictionary(); Entity = new HttpEntity(Headers, new MemoryStream()); CodecParameters = new List <string>(); }