public void ResponseHeadersCanBeSetFrom_MapImpl() { var response = new Mock <HttpResponse>(); var headers = new MapImpl(); headers.SetIndexedValue(ValueFactory.Create("Content-Length"), ValueFactory.Create("123456")); headers.SetIndexedValue(ValueFactory.Create("Content-Encoding"), ValueFactory.Create("utf-8")); var testedHeaders = new HeaderDictionary(); response.SetupGet(x => x.Headers).Returns(testedHeaders); var scriptRequest = new HttpResponseImpl(response.Object); scriptRequest.SetHeaders(headers); Assert.Equal(testedHeaders["Content-Length"], "123456"); Assert.Equal(testedHeaders["Content-Encoding"], "utf-8"); }
private void UpdateHeaders() { var mapHdrs = new MapImpl(); foreach (var realObjectHeader in _realObject.Headers) { mapHdrs.SetIndexedValue(ValueFactory.Create(realObjectHeader.Key), ValueFactory.Create(realObjectHeader.Value)); } Headers = new FixedMapImpl(mapHdrs); }
public HttpRequestImpl(HttpRequest request) { _realObject = request; var mapHdrs = new MapImpl(); foreach (var realObjectHeader in _realObject.Headers) { mapHdrs.SetIndexedValue(ValueFactory.Create(realObjectHeader.Key), ValueFactory.Create(realObjectHeader.Value)); } Headers = new FixedMapImpl(mapHdrs); }
private void UpdateCookies() { var cookieMap = new MapImpl(); if (_realObject.Cookies != null) { foreach (var cookie in _realObject.Cookies) { cookieMap.SetIndexedValue(ValueFactory.Create(cookie.Key), ValueFactory.Create(cookie.Value)); } } Cookies = new FixedMapImpl(cookieMap); }
public FormFileContext(IFormFile realObject) { _realObject = realObject; _headers = new Lazy <FixedMapImpl>(() => { var mapHdrs = new MapImpl(); foreach (var realObjectHeader in _realObject.Headers) { mapHdrs.SetIndexedValue(ValueFactory.Create(realObjectHeader.Key), ValueFactory.Create(realObjectHeader.Value)); } return(new FixedMapImpl(mapHdrs)); } ); }
public void ContentTypeIsReflectedInHeadersAfterSetHeaders() { var response = MockRequestClass(); var headers = new MapImpl(); headers.SetIndexedValue(ValueFactory.Create("Content-Type"), ValueFactory.Create("text/plain")); var scriptRequest = new HttpResponseImpl(response); scriptRequest.SetHeaders(headers); Assert.Equal("text/plain", scriptRequest.Headers.GetIndexedValue(ValueFactory.Create("Content-Type")).AsString()); Assert.Equal("text/plain", scriptRequest.RealObject.Headers["Content-Type"]); Assert.Equal("text/plain", scriptRequest.RealObject.ContentType); }
private void RetrieveResponseData(HttpWebResponse response, string dumpToFile) { using (response) { StatusCode = (int)response.StatusCode; _defaultCharset = response.CharacterSet; ProcessHeaders(response.Headers); ProcessResponseBody(response, dumpToFile); if (_body != null && _body.AutoDecompress) { _headers.Delete(ValueFactory.Create("Content-Encoding")); _headers.SetIndexedValue(ValueFactory.Create("Content-Length"), ValueFactory.Create(_body.ContentSize)); } } }
public void ContentTypeIsReflectedInHeadersAfterSetHeaders() { lock (TestOrderingLock.Lock) { var se = new MinimalTypeSystemHack(); var context = new DefaultHttpContext(); var response = new DefaultHttpResponse(context); var headers = new MapImpl(); headers.SetIndexedValue(ValueFactory.Create("Content-Type"), ValueFactory.Create("text/plain")); var scriptRequest = new HttpResponseImpl(response); scriptRequest.SetHeaders(headers); Assert.True(scriptRequest.Headers.GetIndexedValue(ValueFactory.Create("Content-Type")).AsString().Equals("text/plain")); Assert.Equal("text/plain", scriptRequest.RealObject.Headers["Content-Type"]); Assert.Equal("text/plain", scriptRequest.RealObject.ContentType); } }