@@ -73,6 +73,24 @@ public void ConvertRequest_Creates_HttpRequestMessage_For_All_HttpMethods(HttpMe
7373 Assert . Equal ( httpMethod , request . Method ) ;
7474 }
7575
76+ [ Fact ]
77+ public void ConvertRequest_DoesNotAddContentLength ( )
78+ {
79+ // Arrange
80+ HttpContextBase contextBase = CreateStubContextBase ( "Get" , new MemoryStream ( ) ) ;
81+
82+ // Act
83+ HttpRequestMessage request = HttpControllerHandler . ConvertRequest ( contextBase ) ;
84+
85+ // Assert
86+ var headers = request . Content . Headers ;
87+ Assert . NotNull ( headers ) ;
88+ Assert . Null ( headers . ContentLength ) ;
89+
90+ IEnumerable < string > unused ;
91+ Assert . False ( headers . TryGetValues ( "Content-Length" , out unused ) ) ;
92+ }
93+
7694 [ Fact ]
7795 public void ConvertRequest_Copies_Headers_And_Content_Headers ( )
7896 {
@@ -130,8 +148,10 @@ public void ConvertRequest_AddsOwinEnvironment_WhenPresentInHttpContext()
130148 {
131149 HttpRequestBase stubRequest = CreateStubRequestBase ( "IgnoreMethod" , ignoreStream ) ;
132150 IDictionary < string , object > expectedEnvironment = new Dictionary < string , object > ( ) ;
133- IDictionary items = new Hashtable ( ) ;
134- items . Add ( HttpControllerHandler . OwinEnvironmentHttpContextKey , expectedEnvironment ) ;
151+ IDictionary items = new Hashtable
152+ {
153+ { HttpControllerHandler . OwinEnvironmentHttpContextKey , expectedEnvironment }
154+ } ;
135155 HttpContextBase context = CreateStubContextBase ( stubRequest , items ) ;
136156
137157 // Act
@@ -1946,13 +1966,6 @@ private static HttpResponseBase CreateStubResponseBase()
19461966 return new Mock < HttpResponseBase > ( ) . Object ;
19471967 }
19481968
1949- private static HttpResponseBase CreateStubResponseBase ( CancellationToken clientDisconnectedToken )
1950- {
1951- Mock < HttpResponseBase > mock = new Mock < HttpResponseBase > ( ) ;
1952- mock . Setup ( r => r . ClientDisconnectedToken ) . Returns ( clientDisconnectedToken ) ;
1953- return mock . Object ;
1954- }
1955-
19561969 private static HttpResponseBase CreateStubResponseBase ( Stream outputStream )
19571970 {
19581971 Mock < HttpResponseBase > responseBaseMock = new Mock < HttpResponseBase > ( ) ;
0 commit comments