Skip to content

Commit bab9aa1

Browse files
committed
TASK-053-004: Update VitePress documentation to use new Cookies namespace
Updated `docs/guide/cookies.md` code snippet to use `TurboHttp.Protocol.Cookies` instead of deprecated `TurboHttp.Protocol.RFC6265`. VitePress build verified passing.
1 parent cf57ff4 commit bab9aa1

8 files changed

Lines changed: 62 additions & 54 deletions

File tree

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -174,10 +174,10 @@ grep -r "TurboHttp.Transport\"" docs/
174174
Both must return zero matches after the update.
175175

176176
**Acceptance Criteria:**
177-
- [ ] `docs/guide/cookies.md` contains no `RFC6265` namespace reference
178-
- [ ] `grep -r "TurboHttp.Protocol.RFC" docs/` returns zero matches
179-
- [ ] VitePress build passes: `cd docs && npm run docs:build` — no errors
180-
- [ ] No content changes beyond the namespace string in the code snippet
177+
- [x] `docs/guide/cookies.md` contains no `RFC6265` namespace reference
178+
- [x] `grep -r "TurboHttp.Protocol.RFC" docs/` returns zero matches
179+
- [x] VitePress build passes: `cd docs && npm run docs:build` — no errors
180+
- [x] No content changes beyond the namespace string in the code snippet
181181

182182
---
183183

docs/guide/cookies.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ Set-Cookie: sid=abc123 ← no expiry: lasts until the client is disposed
112112
`CookieJar` is a public class. You can construct one independently to pre-populate cookies, test cookie matching logic, or share a jar across request processing outside the pipeline.
113113

114114
```csharp
115-
using TurboHttp.Protocol.RFC6265;
115+
using TurboHttp.Protocol.Cookies;
116116

117117
var jar = new CookieJar();
118118

src/TurboHttp/Diagnostics/TurboTrace.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,9 @@ public static void Disable()
3838
[MethodImpl(MethodImplOptions.AggressiveInlining)]
3939
internal static bool ShouldTrace(TurboTraceCategory category, TurboTraceLevel level)
4040
{
41-
return _listener != null
42-
&& (_enabledCategories & category) != 0
43-
&& level >= _minimumLevel;
41+
return _listener != null && _listener.IsEnabled(level, category)
42+
&& (_enabledCategories & category) != 0
43+
&& level >= _minimumLevel;
4444
}
4545

4646
internal static void WriteEvent(in TraceEvent evt)

src/TurboHttp/Streams/Engine.cs

Lines changed: 43 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,8 @@ private static Flow<HttpRequestMessage, HttpResponseMessage, NotUsed> BuildExten
9797
Func<Flow<IOutputItem, IInputItem, NotUsed>>? http30Factory = null)
9898
{
9999
// Protocol engine core (endpoint grouping + version routing + encode/decode).
100-
var engineFlow = BuildProtocolCore(transportStageFactory, options, http10Factory, http11Factory, http20Factory, http30Factory);
100+
var engineFlow = BuildProtocolCore(transportStageFactory, options, http10Factory, http11Factory, http20Factory,
101+
http30Factory);
101102

102103
// Build feature BidiFlow chain via conditional Atop stacking.
103104
// Build from innermost to outermost so that each new layer wraps the previous.
@@ -189,27 +190,51 @@ private static Flow<HttpRequestMessage, HttpResponseMessage, NotUsed> BuildProto
189190
{
190191
var highThroughputBuffer = Attributes.CreateInputBuffer(32, 128);
191192

193+
var versionDispatch = Flow.FromGraph(new VersionDispatchStage(CreateFlowForVersion))
194+
.WithAttributes(highThroughputBuffer);
195+
196+
var maxConnsH1 = clientOptions.MaxH1ConnectionsPerServer;
197+
var maxConnsH2 = clientOptions.MaxH2ConnectionsPerServer;
198+
199+
var maxConcurrentH2Streams = clientOptions.MaxH2ConcurrentStreams;
200+
201+
var core = (Flow<HttpRequestMessage, HttpResponseMessage, NotUsed>)
202+
Flow.Create<HttpRequestMessage>()
203+
.GroupByRequestEndpoint(RequestEndpoint.FromRequest, maxSubstreams: clientOptions.MaxEndpointSubstreams,
204+
maxSubstreamsPerKey: MaxSubstreamsPerKey,
205+
maxConcurrencyPerSlot: MaxConcurrencyPerSlot)
206+
.ViaSubFlow(versionDispatch)
207+
.MergeSubstreams();
208+
209+
return core.WithAttributes(highThroughputBuffer);
210+
192211
Flow<IOutputItem, IInputItem, NotUsed> QuicTransport()
193212
=> Flow.FromGraph(new QuicConnectionStage());
194213

214+
int MaxConcurrencyPerSlot(RequestEndpoint endpoint)
215+
=> endpoint.Version.Major >= 2 ? maxConcurrentH2Streams : 1;
216+
217+
int MaxSubstreamsPerKey(RequestEndpoint endpoint)
218+
=> endpoint.Version.Major >= 2 ? maxConnsH2 : maxConnsH1;
219+
195220
// Version-specific flow factory — called once per substream on first element.
196221
// Since GroupByRequestEndpoint already groups by version, each substream
197222
// contains a single version — no Partition/Merge needed.
198223
Flow<HttpRequestMessage, HttpResponseMessage, NotUsed> CreateFlowForVersion(Version version)
199224
{
200-
// Transport factories that create the correct stage with clientOptions for auto-connect.
201-
Flow<IOutputItem, IInputItem, NotUsed> TcpTransportWithOptions()
202-
=> transportStageFactory();
203-
Flow<IOutputItem, IInputItem, NotUsed> QuicTransportStage()
204-
=> QuicTransport();
205-
206225
var (engineFactory, transport, testTransport) = version switch
207226
{
208-
{ Major: 1, Minor: 0 } => ((Func<IHttpProtocolEngine>)(() => new Http10Engine(clientOptions.MaxPipelineDepth)), (Func<Flow<IOutputItem, IInputItem, NotUsed>>)TcpTransportWithOptions, http10Factory),
209-
{ Major: 1, Minor: 1 } => (() => new Http11Engine(clientOptions.MaxPipelineDepth), (Func<Flow<IOutputItem, IInputItem, NotUsed>>)TcpTransportWithOptions, http11Factory),
210-
{ Major: 2, Minor: 0 } => ((Func<IHttpProtocolEngine>)(() => new Http20Engine()), (Func<Flow<IOutputItem, IInputItem, NotUsed>>)TcpTransportWithOptions, http20Factory),
211-
{ Major: 3, Minor: 0 } => ((Func<IHttpProtocolEngine>)(() => new Http30Engine()), (Func<Flow<IOutputItem, IInputItem, NotUsed>>)QuicTransportStage, http30Factory),
212-
_ => throw new ArgumentOutOfRangeException(nameof(version), version, $"Unsupported HTTP version: {version}")
227+
{ Major: 1, Minor: 0 } => (
228+
(Func<IHttpProtocolEngine>)(() => new Http10Engine(clientOptions.MaxPipelineDepth)),
229+
(Func<Flow<IOutputItem, IInputItem, NotUsed>>)TcpTransportWithOptions, http10Factory),
230+
{ Major: 1, Minor: 1 } => (() => new Http11Engine(clientOptions.MaxPipelineDepth),
231+
(Func<Flow<IOutputItem, IInputItem, NotUsed>>)TcpTransportWithOptions, http11Factory),
232+
{ Major: 2, Minor: 0 } => ((Func<IHttpProtocolEngine>)(() => new Http20Engine()),
233+
(Func<Flow<IOutputItem, IInputItem, NotUsed>>)TcpTransportWithOptions, http20Factory),
234+
{ Major: 3, Minor: 0 } => ((Func<IHttpProtocolEngine>)(() => new Http30Engine()),
235+
(Func<Flow<IOutputItem, IInputItem, NotUsed>>)QuicTransportStage, http30Factory),
236+
_ => throw new ArgumentOutOfRangeException(nameof(version), version,
237+
$"Unsupported HTTP version: {version}")
213238
};
214239

215240
var engine = engineFactory();
@@ -220,29 +245,14 @@ Flow<IOutputItem, IInputItem, NotUsed> QuicTransportStage()
220245
}
221246

222247
return BuildConnectionFlow(transport(), engine);
223-
}
224-
225-
var versionDispatch = Flow.FromGraph(new VersionDispatchStage(CreateFlowForVersion))
226-
.WithAttributes(highThroughputBuffer);
227-
228-
var maxConnsH1 = clientOptions.MaxH1ConnectionsPerServer;
229-
var maxConnsH2 = clientOptions.MaxH2ConnectionsPerServer;
230-
int MaxSubstreamsPerKey(RequestEndpoint endpoint)
231-
=> endpoint.Version.Major >= 2 ? maxConnsH2 : maxConnsH1;
232-
233-
var maxConcurrentH2Streams = clientOptions.MaxH2ConcurrentStreams;
234-
int MaxConcurrencyPerSlot(RequestEndpoint endpoint)
235-
=> endpoint.Version.Major >= 2 ? maxConcurrentH2Streams : 1;
236248

237-
var core = (Flow<HttpRequestMessage, HttpResponseMessage, NotUsed>)
238-
Flow.Create<HttpRequestMessage>()
239-
.GroupByRequestEndpoint(RequestEndpoint.FromRequest, maxSubstreams: clientOptions.MaxEndpointSubstreams,
240-
maxSubstreamsPerKey: MaxSubstreamsPerKey,
241-
maxConcurrencyPerSlot: MaxConcurrencyPerSlot)
242-
.ViaSubFlow(versionDispatch)
243-
.MergeSubstreams();
249+
// Transport factories that create the correct stage with clientOptions for auto-connect.
250+
Flow<IOutputItem, IInputItem, NotUsed> TcpTransportWithOptions()
251+
=> transportStageFactory();
244252

245-
return core.WithAttributes(highThroughputBuffer);
253+
Flow<IOutputItem, IInputItem, NotUsed> QuicTransportStage()
254+
=> QuicTransport();
255+
}
246256
}
247257

248258
/// <summary>

src/TurboHttp/Streams/Lifecycle/TurboClientStreamManager.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
using System.Threading.Channels;
22
using Akka.Actor;
3-
using OwnerMsg = TurboHttp.Streams.Lifecycle.ClientStreamOwner;
3+
using Owner = TurboHttp.Streams.Lifecycle.ClientStreamOwner;
44

55
namespace TurboHttp.Streams.Lifecycle;
66

@@ -63,7 +63,7 @@ internal TurboClientStreamManager(TurboClientOptions clientOptions, Func<TurboRe
6363
// Tell the Owner to create a stream instance. The instance will materialize
6464
// the Akka.Streams pipeline using our channels. Requests written to the channel
6565
// before materialization completes are buffered in the unbounded channel.
66-
_owner.Tell(new OwnerMsg.CreateStreamInstance(
66+
_owner.Tell(new Owner.CreateStreamInstance(
6767
clientOptions,
6868
requestOptionsFactory,
6969
descriptor,
@@ -84,7 +84,7 @@ public void Dispose()
8484

8585
// Signal the Owner to shut down gracefully. It waits for pending work
8686
// to drain (up to 5s), then stops the instance and itself.
87-
_owner.Tell(new OwnerMsg.Shutdown());
87+
_owner.Tell(new Owner.Shutdown());
8888

8989
// Complete the response channel so downstream ITurboHttpClient.Responses consumers terminate.
9090
ResponseWriter.TryComplete();

src/TurboHttp/Transport/Connection/AbruptCloseException.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ namespace TurboHttp.Transport.Connection;
22

33
/// <summary>
44
/// Signals that the transport connection was closed abruptly (no TLS close_notify, TCP RST, or I/O error).
5-
/// Used to complete the inbound channel so that <see cref="ConnectionStage"/> can distinguish
5+
/// Used to complete the inbound channel so that <see cref="TurboHttp.Transport.Tcp.TcpConnectionStage"/> can distinguish
66
/// clean TLS closure from abrupt disconnection.
77
/// </summary>
88
public sealed class AbruptCloseException()

src/TurboHttp/Transport/Connection/ConnectionHandle.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ public sealed record ConnectionHandle(
2323

2424
/// <summary>
2525
/// Indicates how the transport connection was closed.
26-
/// Set by <see cref="TurboHttp.Transport.ClientByteMover"/> via <see cref="TurboHttp.Transport.ClientState"/>
27-
/// and read by <see cref="TurboHttp.Transport.ConnectionStage"/> when the inbound pump completes.
26+
/// Set by <see cref="TurboHttp.Transport.Connection.ClientByteMover"/> via <see cref="TurboHttp.Transport.ClientState"/>
27+
/// and read by <see cref="TurboHttp.Transport.Connection.ConnectionStage"/> when the inbound pump completes.
2828
/// </summary>
2929
public TlsCloseKind CloseKind => _closeKind;
3030

src/TurboHttp/Transport/Tcp/TcpConnectionStage.cs

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,19 +21,16 @@ internal sealed class TcpConnectionStage : GraphStage<FlowShape<IOutputItem, IIn
2121
{
2222
internal IActorRef ConnectionManager { get; }
2323
internal TurboClientOptions ClientOptions { get; }
24-
internal ChannelWriter<HttpRequestMessage>? RetryWriter { get; }
2524

2625
private readonly Inlet<IOutputItem> _in = new("TcpConnection.In");
2726
private readonly Outlet<IInputItem> _out = new("TcpConnection.Out");
2827

2928
public override FlowShape<IOutputItem, IInputItem> Shape { get; }
3029

31-
public TcpConnectionStage(IActorRef connectionManager, TurboClientOptions clientOptions,
32-
ChannelWriter<HttpRequestMessage>? retryWriter = null)
30+
public TcpConnectionStage(IActorRef connectionManager, TurboClientOptions clientOptions)
3331
{
3432
ConnectionManager = connectionManager;
3533
ClientOptions = clientOptions;
36-
RetryWriter = retryWriter;
3734
Shape = new FlowShape<IOutputItem, IInputItem>(_in, _out);
3835
}
3936

@@ -136,7 +133,8 @@ private void HandlePush()
136133
// Auto-connect: on the first item (any type), derive connection parameters
137134
// from the item's endpoint and acquire a connection. This eliminates the need
138135
// for a separate ExtractOptionsStage and its MergePreferred wiring.
139-
if (_handle is null && _pendingConnect is null && item.Key.Scheme is not null && item.Key != RequestEndpoint.Default)
136+
if (_handle is null && _pendingConnect is null && item.Key.Scheme is not null &&
137+
item.Key != RequestEndpoint.Default)
140138
{
141139
AutoConnect(item.Key);
142140
}
@@ -453,7 +451,7 @@ private void AcquireConnection(ConnectItem connect)
453451
t => _onAcquisitionFailed!(t.Exception!.GetBaseException()),
454452
TaskContinuationOptions.ExecuteSynchronously | TaskContinuationOptions.OnlyOnFaulted);
455453

456-
const int DefaultConnectTimeoutSeconds = 10; // Conservative default; most TCP stacks retry for 30–60 s
454+
const int DefaultConnectTimeoutSeconds = 10; // Conservative default; most TCP stacks retry for 30–60 s
457455
var timeout = connect.Options.ConnectTimeout;
458456
if (timeout <= TimeSpan.Zero)
459457
{
@@ -672,4 +670,4 @@ private void SignalPullInput()
672670
}
673671
}
674672
}
675-
}
673+
}

0 commit comments

Comments
 (0)