Skip to content

Commit 9f0608b

Browse files
Merge pull request #10891 from dotnet/main
Merge main into live
2 parents 8058d83 + e669d4a commit 9f0608b

File tree

22 files changed

+1704
-1646
lines changed

22 files changed

+1704
-1646
lines changed
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
using System;
2+
using System.Net.Http;
3+
using System.Threading.Tasks;
4+
5+
namespace HttpCompletionOptionSnippets
6+
{
7+
class HttpCompletionOptionSnippets
8+
{
9+
public static async Task RunAsync()
10+
{
11+
//<SnippetHttpCompletionOption>
12+
using var httpClient = new HttpClient();
13+
httpClient.Timeout = TimeSpan.FromSeconds(30);
14+
httpClient.MaxResponseContentBufferSize = 1_000; // This will be ignored
15+
16+
// Because we're specifying the ResponseHeadersRead option,
17+
// the 30-second timeout applies only up until the headers are received.
18+
// It does not affect future operations that interact with the response content.
19+
using HttpResponseMessage response = await httpClient.GetAsync(
20+
"http://localhost:12345/",
21+
HttpCompletionOption.ResponseHeadersRead);
22+
23+
// Do other checks that don't rely on the content first, like status code validation.
24+
response.EnsureSuccessStatusCode();
25+
26+
// Since the HttpClient.Timeout will not apply to reading the content,
27+
// you must enforce it yourself, for example by using a CancellationTokenSource.
28+
using var cancellationSource = new CancellationTokenSource(TimeSpan.FromSeconds(15));
29+
30+
// If you wish to enforce the MaxResponseContentBufferSize limit as well,
31+
// you can do so by calling the LoadIntoBufferAsync helper first.
32+
await response.Content.LoadIntoBufferAsync(1_000, cancellationSource.Token);
33+
34+
// Make sure to pass the CancellationToken to all methods.
35+
string content = await response.Content.ReadAsStringAsync(cancellationSource.Token);
36+
//</SnippetHttpCompletionOption>
37+
}
38+
}
39+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<OutputType>Exe</OutputType>
5+
<TargetFramework>net9.0</TargetFramework>
6+
<ImplicitUsings>enable</ImplicitUsings>
7+
<Nullable>enable</Nullable>
8+
</PropertyGroup>
9+
10+
</Project>
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
using System;
2+
3+
namespace HttpCompletionOptionSnippets
4+
{
5+
class MetadataReaderSnippets
6+
{
7+
class Program
8+
{
9+
static async Task Main()
10+
{
11+
await HttpCompletionOptionSnippets.RunAsync();
12+
}
13+
}
14+
}
15+
}

xml/Microsoft.SqlServer.Server/SqlMetaData.xml

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -176,19 +176,17 @@
176176
177177
The following are the default values assigned to `dbType`, depending on the `SqlDbType` (the <xref:Microsoft.SqlServer.Server.SqlMetaData.XmlSchemaCollectionDatabase%2A>, <xref:Microsoft.SqlServer.Server.SqlMetaData.XmlSchemaCollectionName%2A>, <xref:Microsoft.SqlServer.Server.SqlMetaData.XmlSchemaCollectionOwningSchema%2A>, and <xref:Microsoft.SqlServer.Server.SqlMetaData.Type%2A> properties are set to `null`):
178178
179-
|SqlDbType|Precision|Scale|Locale|Compare options|
180-
|---------------|---------------|-----------|------------|---------------------|
181-
|Binary|0|0|0|IgnoreCase, IgnoreKanaType, IgnoreWidth|
182-
|Char|0|0|\<thread>|IgnoreCase, IgnoreKanaType, IgnoreWidth|
183-
|Image|0|0|0|None|
184-
|NChar|0|0|\<thread>|IgnoreCase, IgnoreKanaType, IgnoreWidth|
185-
|NText|0|0|\<thread>|IgnoreCase, IgnoreKanaType, IgnoreWidth|
186-
|NVarChar|0|0|\<thread>|IgnoreCase, IgnoreKanaType, IgnoreWidth|
187-
|Text|0|0|\<thread>|IgnoreCase, IgnoreKanaType, IgnoreWidth|
188-
|VarBinary|0|0||IgnoreCase, IgnoreKanaType, IgnoreWidth|
189-
|VarChar|0|0|\<thread>|IgnoreCase, IgnoreKanaType, IgnoreWidth|
190-
191-
179+
| SqlDbType | Precision | Scale | Locale | Compare options |
180+
|-----------|-----------|-------|-----------|-----------------------------------------|
181+
| Binary | 0 | 0 | 0 | IgnoreCase, IgnoreKanaType, IgnoreWidth |
182+
| Char | 0 | 0 | \<thread> | IgnoreCase, IgnoreKanaType, IgnoreWidth |
183+
| Image | 0 | 0 | 0 | None |
184+
| NChar | 0 | 0 | \<thread> | IgnoreCase, IgnoreKanaType, IgnoreWidth |
185+
| NText | 0 | 0 | \<thread> | IgnoreCase, IgnoreKanaType, IgnoreWidth |
186+
| NVarChar | 0 | 0 | \<thread> | IgnoreCase, IgnoreKanaType, IgnoreWidth |
187+
| Text | 0 | 0 | \<thread> | IgnoreCase, IgnoreKanaType, IgnoreWidth |
188+
| VarBinary | 0 | 0 | | IgnoreCase, IgnoreKanaType, IgnoreWidth |
189+
| VarChar | 0 | 0 | \<thread> | IgnoreCase, IgnoreKanaType, IgnoreWidth |
192190
193191
## Examples
194192
The following example creates a new <xref:Microsoft.SqlServer.Server.SqlMetaData> object by specifying the column name, a column data type of <xref:System.Data.SqlDbType>`.NVarChar`, and a maximum length of 12 characters.

0 commit comments

Comments
 (0)