Skip to content

Commit 67caeda

Browse files
committed
whitespace fixes
1 parent 7c634fe commit 67caeda

5 files changed

Lines changed: 18 additions & 17 deletions

File tree

src/ModelContextProtocol/Client/AutoDetectingClientSessionTransport.cs

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -65,24 +65,25 @@ private async Task InitializeAsync(JsonRpcMessage message, CancellationToken can
6565
{
6666
LogAttemptingStreamableHttp(_name);
6767
using var response = await streamableHttpTransport.SendHttpRequestAsync(message, cancellationToken).ConfigureAwait(false);
68-
69-
// If the status code is not success, fall back to SSE
70-
if (!response.IsSuccessStatusCode)
68+
69+
if (response.IsSuccessStatusCode)
70+
{
71+
LogUsingStreamableHttp(_name);
72+
ActiveTransport = streamableHttpTransport;
73+
}
74+
else
7175
{
76+
// If the status code is not success, fall back to SSE
7277
LogStreamableHttpFailed(_name, response.StatusCode);
73-
78+
7479
await streamableHttpTransport.DisposeAsync().ConfigureAwait(false);
7580
await InitializeSseTransportAsync(message, cancellationToken).ConfigureAwait(false);
76-
return;
7781
}
78-
79-
LogUsingStreamableHttp(_name);
80-
ActiveTransport = streamableHttpTransport;
8182
}
8283
catch
8384
{
8485
// If nothing threw inside the try block, we've either set streamableHttpTransport as the
85-
// ActiveTransport, or else we will have disposed it in the !IsSuccessStatusCode if statement.
86+
// ActiveTransport, or else we will have disposed it in the !IsSuccessStatusCode else block.
8687
await streamableHttpTransport.DisposeAsync().ConfigureAwait(false);
8788
throw;
8889
}
@@ -97,7 +98,7 @@ private async Task InitializeSseTransportAsync(JsonRpcMessage message, Cancellat
9798
LogAttemptingSSE(_name);
9899
await sseTransport.ConnectAsync(cancellationToken).ConfigureAwait(false);
99100
await sseTransport.SendMessageAsync(message, cancellationToken).ConfigureAwait(false);
100-
101+
101102
LogUsingSSE(_name);
102103
ActiveTransport = sseTransport;
103104
}
@@ -124,7 +125,7 @@ public async ValueTask DisposeAsync()
124125
_messageChannel.Writer.TryComplete();
125126
}
126127
}
127-
128+
128129
[LoggerMessage(Level = LogLevel.Debug, Message = "{EndpointName} attempting to connect using Streamable HTTP transport.")]
129130
private partial void LogAttemptingStreamableHttp(string endpointName);
130131

@@ -133,10 +134,10 @@ public async ValueTask DisposeAsync()
133134

134135
[LoggerMessage(Level = LogLevel.Information, Message = "{EndpointName} using Streamable HTTP transport.")]
135136
private partial void LogUsingStreamableHttp(string endpointName);
136-
137+
137138
[LoggerMessage(Level = LogLevel.Debug, Message = "{EndpointName} attempting to connect using SSE transport.")]
138139
private partial void LogAttemptingSSE(string endpointName);
139-
140+
140141
[LoggerMessage(Level = LogLevel.Information, Message = "{EndpointName} using SSE transport.")]
141142
private partial void LogUsingSSE(string endpointName);
142143
}

src/ModelContextProtocol/Client/SseClientTransport.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ public SseClientTransport(SseClientTransportOptions transportOptions, ILoggerFac
3636
/// <param name="httpClient">The HTTP client instance used for requests.</param>
3737
/// <param name="loggerFactory">Logger factory for creating loggers used for diagnostic output during transport operations.</param>
3838
/// <param name="ownsHttpClient">
39-
/// <see langword="true"/> to dispose of <paramref name="httpClient"/> when the transport is disposed;
39+
/// <see langword="true"/> to dispose of <paramref name="httpClient"/> when the transport is disposed;
4040
/// <see langword="false"/> if the caller is retaining ownership of the <paramref name="httpClient"/>'s lifetime.
4141
/// </param>
4242
public SseClientTransport(SseClientTransportOptions transportOptions, HttpClient httpClient, ILoggerFactory? loggerFactory = null, bool ownsHttpClient = false)

src/ModelContextProtocol/Client/StreamableHttpClientSessionTransport.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ internal async Task<HttpResponseMessage> SendHttpRequestAsync(JsonRpcMessage mes
8686
};
8787

8888
CopyAdditionalHeaders(httpRequestMessage.Headers, _options.AdditionalHeaders, _mcpSessionId);
89-
89+
9090
var response = await _httpClient.SendAsync(httpRequestMessage, HttpCompletionOption.ResponseHeadersRead, cancellationToken).ConfigureAwait(false);
9191

9292
// We'll let the caller decide whether to throw or fall back given an unsuccessful response.

src/ModelContextProtocol/Protocol/TransportBase.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ protected void SetConnected()
120120

121121
case StateConnected:
122122
return;
123-
123+
124124
case StateDisconnected:
125125
throw new IOException("Transport is already disconnected and can't be reconnected.");
126126

tests/ModelContextProtocol.AspNetCore.Tests/HttpServerIntegrationTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ public async Task Connect_TestServer_ShouldProvideServerFields()
5656

5757
[Fact]
5858
public async Task ListTools_Sse_TestServer()
59-
{
59+
{
6060
// arrange
6161

6262
// act

0 commit comments

Comments
 (0)