This commit is contained in:
Родитель
749384689e
Коммит
1f27750128
|
@ -187,7 +187,7 @@ namespace System.Web.Http.Batch
|
|||
foreach (HttpContent httpContent in streamProvider.Contents)
|
||||
{
|
||||
cancellationToken.ThrowIfCancellationRequested();
|
||||
HttpRequestMessage innerRequest = await httpContent.ReadAsHttpRequestMessageAsync();
|
||||
HttpRequestMessage innerRequest = await httpContent.ReadAsHttpRequestMessageAsync(request.RequestUri.Scheme);
|
||||
innerRequest.CopyBatchRequestProperties(request);
|
||||
requests.Add(innerRequest);
|
||||
}
|
||||
|
|
|
@ -102,7 +102,8 @@ namespace System.Web.Http
|
|||
{
|
||||
new HttpMessageContent(new HttpRequestMessage(HttpMethod.Get, "http://example.com/")),
|
||||
new HttpMessageContent(new HttpRequestMessage(HttpMethod.Post, "http://example.org/"))
|
||||
}
|
||||
},
|
||||
RequestUri = new Uri("http://example.com/")
|
||||
};
|
||||
|
||||
var response = await batchHandler.ProcessBatchAsync(batchRequest, CancellationToken.None);
|
||||
|
@ -269,7 +270,8 @@ namespace System.Web.Http
|
|||
{
|
||||
new HttpMessageContent(new HttpRequestMessage(HttpMethod.Get, "http://example.com/")),
|
||||
new HttpMessageContent(new HttpRequestMessage(HttpMethod.Post, "http://example.com/values"))
|
||||
}
|
||||
},
|
||||
RequestUri = new Uri("http://example.com/")
|
||||
};
|
||||
|
||||
IList<HttpRequestMessage> requests = await batchHandler.ParseBatchRequestsAsync(request, CancellationToken.None);
|
||||
|
@ -281,6 +283,29 @@ namespace System.Web.Http
|
|||
Assert.Equal("http://example.com/values", requests[1].RequestUri.AbsoluteUri);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task ParseBatchRequestsAsync_Returns_RequestsFromMultipartContent_WithUriSchemeSet_FromRequest()
|
||||
{
|
||||
DefaultHttpBatchHandler batchHandler = new DefaultHttpBatchHandler(new HttpServer());
|
||||
HttpRequestMessage request = new HttpRequestMessage
|
||||
{
|
||||
Content = new MultipartContent("mixed")
|
||||
{
|
||||
new HttpMessageContent(new HttpRequestMessage(HttpMethod.Get, "http://example.com/")),
|
||||
new HttpMessageContent(new HttpRequestMessage(HttpMethod.Post, "https://example.com/values"))
|
||||
},
|
||||
RequestUri = new Uri("https://example.com/")
|
||||
};
|
||||
|
||||
IList<HttpRequestMessage> requests = await batchHandler.ParseBatchRequestsAsync(request, CancellationToken.None);
|
||||
|
||||
Assert.Equal(2, requests.Count);
|
||||
Assert.Equal(HttpMethod.Get, requests[0].Method);
|
||||
Assert.Equal("https://example.com/", requests[0].RequestUri.AbsoluteUri);
|
||||
Assert.Equal(HttpMethod.Post, requests[1].Method);
|
||||
Assert.Equal("https://example.com/values", requests[1].RequestUri.AbsoluteUri);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task ParseBatchRequestsAsync_CopiesPropertiesFromRequest_WithoutExcludedProperties()
|
||||
{
|
||||
|
@ -291,7 +316,8 @@ namespace System.Web.Http
|
|||
{
|
||||
new HttpMessageContent(new HttpRequestMessage(HttpMethod.Get, "http://example.com/")),
|
||||
new HttpMessageContent(new HttpRequestMessage(HttpMethod.Post, "http://example.com/values"))
|
||||
}
|
||||
},
|
||||
RequestUri = new Uri("http://example.com/")
|
||||
};
|
||||
request.Properties.Add("foo", "bar");
|
||||
request.SetRouteData(new HttpRouteData(new HttpRoute()));
|
||||
|
|
|
@ -43,7 +43,8 @@ namespace System.Web.Http.WebHost
|
|||
Content = new MultipartContent("mixed")
|
||||
{
|
||||
new HttpMessageContent(new HttpRequestMessage(HttpMethod.Post, "http://contoso.com/values/ space"))
|
||||
}
|
||||
},
|
||||
RequestUri = new Uri("http://contoso.com/")
|
||||
};
|
||||
|
||||
// Arrange
|
||||
|
|
Загрузка…
Ссылка в новой задаче