-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
160eff8
commit 2300050
Showing
3 changed files
with
108 additions
and
136 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
tests/Elastic.Transport.IntegrationTests/Http/StreamResponseTests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
// Licensed to Elasticsearch B.V under one or more agreements. | ||
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License. | ||
// See the LICENSE file in the project root for more information | ||
|
||
using System.IO; | ||
using System.Text.Json; | ||
using System.Threading.Tasks; | ||
using Elastic.Transport.IntegrationTests.Plumbing; | ||
using Elastic.Transport.Products.Elasticsearch; | ||
using Microsoft.AspNetCore.Mvc; | ||
using Xunit; | ||
|
||
namespace Elastic.Transport.IntegrationTests.Http; | ||
|
||
public class StreamResponseTests(TransportTestServer instance) : AssemblyServerTestsBase(instance) | ||
{ | ||
private const string Path = "/streamresponse"; | ||
|
||
[Fact] | ||
public async Task StreamResponse_ShouldNotBeDisposed() | ||
{ | ||
var nodePool = new SingleNodePool(Server.Uri); | ||
var config = new TransportConfiguration(nodePool, productRegistration: new ElasticsearchProductRegistration(typeof(Clients.Elasticsearch.ElasticsearchClient))); | ||
var transport = new DistributedTransport(config); | ||
|
||
var response = await transport.PostAsync<StreamResponse>(Path, PostData.String("{}")); | ||
|
||
var sr = new StreamReader(response.Body); | ||
var responseString = sr.ReadToEndAsync(); | ||
} | ||
} | ||
|
||
[ApiController, Route("[controller]")] | ||
public class StreamResponseController : ControllerBase | ||
{ | ||
[HttpPost] | ||
public Task<JsonElement> Post([FromBody] JsonElement body) => Task.FromResult(body); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters