-
Notifications
You must be signed in to change notification settings - Fork 5.2k
Open
Labels
api-suggestionEarly API idea and discussion, it is NOT ready for implementationEarly API idea and discussion, it is NOT ready for implementationarea-System.Net.Http
Milestone
Description
We've got desires for a) code sharing between HttpClient and Kestrel, and b) very precise control for partners with advanced needs (e.g. reverse proxies).
What do we think of an XmlReader-like API for low level HTTP? Minimal allocation, no connection pooling, no proxy support, etc. -- something like:
HttpStreamReader reader = ...;
HttpStreamWriter writer = ...;
ReadOnlySpan<byte> uri = ...;
await writer.WriteRequestAsync(HttpMethod.Get, uri);
await writer.WriteHeaderAsync(..., ...);
await writer.FlushMessage();
HttpTokenType token = await reader.ReadNextAsync();
Debug.Assert(token == HttpTokenType.Response);
if(reader.MessageStatusCode != 200)
{
throw ...;
}
while((token = await reader.ReadNextAsync()) == HttpTokenType.Header)
{
Span<byte> name = reader.HeaderName;
Span<byte> value = reader.HeaderValue;
UseHeader(name, value);
}
while(token == HttpTokenType.Content)
{
UseContent(reader.Content);
token = await reader.ReadNextAsync();
}
while(token == HttpTokenType.TrailingHeader)
{
UseHeader(reader.HeaderName, reader.HeaderValue);
token = await reader.ReadNextAsync();
}
Debug.Assert(token == HttpTokenType.MessageComplete);
juliusfriedman, Rodrigo-Andrade, rodrigovidal, antoniofreire, halter73 and 7 moreomariom
Metadata
Metadata
Assignees
Labels
api-suggestionEarly API idea and discussion, it is NOT ready for implementationEarly API idea and discussion, it is NOT ready for implementationarea-System.Net.Http