Skip to content

Commit 8726db0

Browse files
committed
PR feedback
1 parent 6d2d642 commit 8726db0

File tree

2 files changed

+23
-20
lines changed

2 files changed

+23
-20
lines changed

src/Servers/HttpSys/test/FunctionalTests/DelegateTests.cs

Lines changed: 22 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -29,53 +29,54 @@ public async Task DelegateRequestTest()
2929
options.RequestQueueName = queueName;
3030
});
3131

32-
DelegationRule wrapper = default;
32+
DelegationRule destination = default;
3333

3434
using var delegator = Utilities.CreateHttpServer(out var delegatorAddress, httpContext =>
3535
{
3636
var transferFeature = httpContext.Features.Get<IHttpSysRequestTransferFeature>();
37-
transferFeature.TransferRequest(wrapper);
37+
transferFeature.TransferRequest(destination);
3838
return Task.FromResult(0);
3939
});
4040

4141
var delegationProperty = delegator.Features.Get<IServerDelegationFeature>();
42-
wrapper = delegationProperty.CreateDelegationRule(queueName, receiverAddress);
42+
destination = delegationProperty.CreateDelegationRule(queueName, receiverAddress);
4343

4444
var responseString = await SendRequestAsync(delegatorAddress);
4545
Assert.Equal(_expectedResponseString, responseString);
46-
wrapper?.Dispose();
46+
destination?.Dispose();
4747
}
4848

4949
[ConditionalFact]
5050
[DelegateSupportedCondition(true)]
5151
public async Task DelegateAfterWriteToResponseBodyShouldThrowTest()
5252
{
5353
var queueName = Guid.NewGuid().ToString();
54-
using var receiver = Utilities.CreateHttpServer(out var receiverAddress, async httpContext =>
54+
using var receiver = Utilities.CreateHttpServer(out var receiverAddress, httpContext =>
5555
{
56-
await httpContext.Response.WriteAsync(_expectedResponseString);
56+
httpContext.Response.StatusCode = StatusCodes.Status418ImATeapot;
57+
return Task.CompletedTask;
5758
},
5859
options =>
5960
{
6061
options.RequestQueueName = queueName;
6162
});
6263

63-
DelegationRule wrapper = default;
64+
DelegationRule destination = default;
6465

6566
using var delegator = Utilities.CreateHttpServer(out var delegatorAddress, async httpContext =>
6667
{
6768
await httpContext.Response.WriteAsync(_expectedResponseString);
6869
var transferFeature = httpContext.Features.Get<IHttpSysRequestTransferFeature>();
6970
Assert.False(transferFeature.IsTransferable);
70-
Assert.Throws<InvalidOperationException>(() => transferFeature.TransferRequest(wrapper));
71+
Assert.Throws<InvalidOperationException>(() => transferFeature.TransferRequest(destination));
7172
});
7273

7374
var delegationProperty = delegator.Features.Get<IServerDelegationFeature>();
74-
wrapper = delegationProperty.CreateDelegationRule(queueName, receiverAddress);
75+
destination = delegationProperty.CreateDelegationRule(queueName, receiverAddress);
7576

7677
var responseString = await SendRequestAsync(delegatorAddress);
7778
Assert.Equal(_expectedResponseString, responseString);
78-
wrapper?.Dispose();
79+
destination?.Dispose();
7980
}
8081

8182
[ConditionalFact]
@@ -92,53 +93,54 @@ public async Task WriteToBodyAfterDelegateShouldNoOp()
9293
options.RequestQueueName = queueName;
9394
});
9495

95-
DelegationRule wrapper = default;
96+
DelegationRule destination = default;
9697

9798
using var delegator = Utilities.CreateHttpServer(out var delegatorAddress, httpContext =>
9899
{
99100
var transferFeature = httpContext.Features.Get<IHttpSysRequestTransferFeature>();
100-
transferFeature.TransferRequest(wrapper);
101+
transferFeature.TransferRequest(destination);
101102
Assert.False(transferFeature.IsTransferable);
102103
return Task.CompletedTask;
103104
});
104105

105106
var delegationProperty = delegator.Features.Get<IServerDelegationFeature>();
106-
wrapper = delegationProperty.CreateDelegationRule(queueName, receiverAddress);
107+
destination = delegationProperty.CreateDelegationRule(queueName, receiverAddress);
107108

108109
var responseString = await SendRequestAsync(delegatorAddress);
109110
Assert.Equal(_expectedResponseString, responseString);
110-
wrapper?.Dispose();
111+
destination?.Dispose();
111112
}
112113

113114
[ConditionalFact]
114115
[DelegateSupportedCondition(true)]
115116
public async Task DelegateAfterRequestBodyReadShouldThrow()
116117
{
117118
var queueName = Guid.NewGuid().ToString();
118-
using var receiver = Utilities.CreateHttpServer(out var receiverAddress, async httpContext =>
119+
using var receiver = Utilities.CreateHttpServer(out var receiverAddress, httpContext =>
119120
{
120-
await httpContext.Response.WriteAsync(_expectedResponseString);
121+
httpContext.Response.StatusCode = StatusCodes.Status418ImATeapot;
122+
return Task.CompletedTask;
121123
},
122124
options =>
123125
{
124126
options.RequestQueueName = queueName;
125127
});
126128

127-
DelegationRule wrapper = default;
129+
DelegationRule destination = default;
128130

129131
using var delegator = Utilities.CreateHttpServer(out var delegatorAddress, async httpContext =>
130132
{
131133
var memoryStream = new MemoryStream();
132134
await httpContext.Request.Body.CopyToAsync(memoryStream);
133135
var transferFeature = httpContext.Features.Get<IHttpSysRequestTransferFeature>();
134-
Assert.Throws<InvalidOperationException>(() => transferFeature.TransferRequest(wrapper));
136+
Assert.Throws<InvalidOperationException>(() => transferFeature.TransferRequest(destination));
135137
});
136138

137139
var delegationProperty = delegator.Features.Get<IServerDelegationFeature>();
138-
wrapper = delegationProperty.CreateDelegationRule(queueName, receiverAddress);
140+
destination = delegationProperty.CreateDelegationRule(queueName, receiverAddress);
139141

140142
_ = await SendRequestWithBodyAsync(delegatorAddress);
141-
wrapper?.Dispose();
143+
destination?.Dispose();
142144
}
143145

144146
[ConditionalFact]

src/Shared/HttpSys/NativeInterop/HttpApiTypes.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ internal enum HTTP_TIMEOUT_TYPE
7171
HeaderWait,
7272
MinSendRate,
7373
}
74+
7475
internal enum HTTP_DELEGATE_REQUEST_PROPERTY_ID : uint
7576
{
7677
DelegateRequestReservedProperty,

0 commit comments

Comments
 (0)