Skip to content

Make Kestrels Internals truly internal. #8517

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 14 commits into from
Mar 18, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,13 @@
using System.IO;
using System.IO.Pipelines;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http;
using Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Infrastructure;
using Microsoft.AspNetCore.Server.Kestrel.Transport.Abstractions.Internal;
using Microsoft.Extensions.Logging;

namespace Microsoft.AspNetCore.Server.Kestrel.Core.Adapter.Internal
{
public class AdaptedPipeline : IDuplexPipe
internal class AdaptedPipeline : IDuplexPipe
{
private static readonly int MinAllocBufferSize = KestrelMemoryPool.MinimumSegmentSize / 2;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

namespace Microsoft.AspNetCore.Server.Kestrel.Core.Adapter.Internal
{
public class LoggingConnectionAdapter : IConnectionAdapter
internal class LoggingConnectionAdapter : IConnectionAdapter
{
private readonly ILogger _logger;

Expand Down
2 changes: 1 addition & 1 deletion src/Servers/Kestrel/Core/src/Adapter/Internal/RawStream.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

namespace Microsoft.AspNetCore.Server.Kestrel.Core.Adapter.Internal
{
public class RawStream : Stream
internal class RawStream : Stream
{
private readonly PipeReader _input;
private readonly PipeWriter _output;
Expand Down
8 changes: 3 additions & 5 deletions src/Servers/Kestrel/Core/src/BadHttpRequestException.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Copyright (c) .NET Foundation. All rights reserved.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wish git better tools around normalizing BOMs similar to what it has for line endings gitattributes.

// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.

using System.Diagnostics;
Expand Down Expand Up @@ -42,10 +42,8 @@ internal static void Throw(RequestRejectionReason reason)
}

[StackTraceHidden]
#pragma warning disable PUB0001 // Pubternal type in public API
public static void Throw(RequestRejectionReason reason, HttpMethod method)
internal static void Throw(RequestRejectionReason reason, HttpMethod method)
=> throw GetException(reason, method.ToString().ToUpperInvariant());
#pragma warning restore PUB0001 // Pubternal type in public API

[MethodImpl(MethodImplOptions.NoInlining)]
internal static BadHttpRequestException GetException(RequestRejectionReason reason)
Expand Down Expand Up @@ -175,4 +173,4 @@ internal static BadHttpRequestException GetException(RequestRejectionReason reas
return ex;
}
}
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.

using System;
Expand Down
4 changes: 2 additions & 2 deletions src/Servers/Kestrel/Core/src/Internal/ConnectionDispatcher.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.

using System;
Expand All @@ -13,7 +13,7 @@

namespace Microsoft.AspNetCore.Server.Kestrel.Core.Internal
{
public class ConnectionDispatcher : IConnectionDispatcher
internal class ConnectionDispatcher : IConnectionDispatcher
{
private static long _lastConnectionId = long.MinValue;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.

using System.Threading.Tasks;
Expand All @@ -8,7 +8,7 @@

namespace Microsoft.AspNetCore.Server.Kestrel.Core.Internal
{
public class ConnectionLimitMiddleware
internal class ConnectionLimitMiddleware
{
private readonly ConnectionDelegate _next;
private readonly ResourceCounter _concurrentConnectionCounter;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

namespace Microsoft.AspNetCore.Server.Kestrel.Core.Internal
{
public class ConnectionLogScope : IReadOnlyList<KeyValuePair<string, object>>
internal class ConnectionLogScope : IReadOnlyList<KeyValuePair<string, object>>
{
private readonly string _connectionId;

Expand Down
5 changes: 4 additions & 1 deletion src/Servers/Kestrel/Core/src/Internal/DuplexPipe.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
namespace System.IO.Pipelines
// Copyright (c) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.

namespace System.IO.Pipelines
{
internal class DuplexPipe : IDuplexPipe
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
namespace Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http
{
[Flags]
public enum ConnectionOptions
internal enum ConnectionOptions
{
None = 0,
Close = 1,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http
/// <summary>
/// Manages the generation of the date header value.
/// </summary>
public class DateHeaderValueManager : IHeartbeatHandler
internal class DateHeaderValueManager : IHeartbeatHandler
{
private static readonly byte[] _datePreambleBytes = Encoding.ASCII.GetBytes("\r\nDate: ");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,14 @@
using System.Threading;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Connections;
using Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Infrastructure;
using Microsoft.AspNetCore.Server.Kestrel.Transport.Abstractions.Internal;

namespace Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http
{
/// <summary>
/// http://tools.ietf.org/html/rfc2616#section-3.6.1
/// </summary>
public class Http1ChunkedEncodingMessageBody : Http1MessageBody
internal class Http1ChunkedEncodingMessageBody : Http1MessageBody
{
// byte consts don't have a data type annotation so we pre-cast it
private const byte ByteCR = (byte)'\r';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

namespace Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http
{
public partial class Http1Connection : IHttpMinRequestBodyDataRateFeature,
internal partial class Http1Connection : IHttpMinRequestBodyDataRateFeature,
IHttpMinResponseDataRateFeature
{
MinDataRate IHttpMinRequestBodyDataRateFeature.MinDataRate
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,10 @@
using Microsoft.AspNetCore.Connections;
using Microsoft.AspNetCore.Http.Features;
using Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Infrastructure;
using Microsoft.AspNetCore.Server.Kestrel.Transport.Abstractions.Internal;

namespace Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http
{
public partial class Http1Connection : HttpProtocol, IRequestProcessor
internal partial class Http1Connection : HttpProtocol, IRequestProcessor
{
private const byte ByteAsterisk = (byte)'*';
private const byte ByteForwardSlash = (byte)'/';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

namespace Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http
{
public class Http1ContentLengthMessageBody : Http1MessageBody
internal class Http1ContentLengthMessageBody : Http1MessageBody
{
private readonly long _contentLength;
private long _inputLength;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

namespace Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http
{
public abstract class Http1MessageBody : MessageBody
internal abstract class Http1MessageBody : MessageBody
{
protected readonly Http1Connection _context;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

namespace Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http
{
public class Http1OutputProducer : IHttpOutputProducer, IHttpOutputAborter, IDisposable
internal class Http1OutputProducer : IHttpOutputProducer, IHttpOutputAborter, IDisposable
{
// Use C#7.3's ReadOnlySpan<byte> optimization for static data https://vcsjones.com/2019/02/01/csharp-readonly-span-bytes-static/
// "HTTP/1.1 100 Continue\r\n\r\n"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

namespace Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http
{
public readonly struct Http1ParsingHandler : IHttpRequestLineHandler, IHttpHeadersHandler
internal readonly struct Http1ParsingHandler : IHttpRequestLineHandler, IHttpHeadersHandler
{
public readonly Http1Connection Connection;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http
/// The upgrade stream uses the raw connection stream instead of going through the RequestBodyPipe. This
/// removes the redundant copy from the transport pipe to the body pipe.
/// </summary>
public class Http1UpgradeMessageBody : Http1MessageBody
internal class Http1UpgradeMessageBody : Http1MessageBody
{
public bool _completed;
public Http1UpgradeMessageBody(Http1Connection context)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
namespace Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http
{

public partial class HttpRequestHeaders
internal partial class HttpRequestHeaders
{

private long _bits = 0;
Expand Down Expand Up @@ -4705,7 +4705,7 @@ public bool MoveNext()
}
}

public partial class HttpResponseHeaders
internal partial class HttpResponseHeaders
{
private static ReadOnlySpan<byte> HeaderBytes => new byte[]
{
Expand Down Expand Up @@ -8531,7 +8531,7 @@ public bool MoveNext()
}
}

public partial class HttpResponseTrailers
internal partial class HttpResponseTrailers
{
private static ReadOnlySpan<byte> HeaderBytes => new byte[]
{
Expand Down
2 changes: 1 addition & 1 deletion src/Servers/Kestrel/Core/src/Internal/Http/HttpHeaders.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

namespace Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http
{
public abstract class HttpHeaders : IHeaderDictionary
internal abstract class HttpHeaders : IHeaderDictionary
{
protected long? _contentLength;
protected bool _isReadOnly;
Expand Down
2 changes: 1 addition & 1 deletion src/Servers/Kestrel/Core/src/Internal/Http/HttpMethod.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

namespace Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http
{
public enum HttpMethod: byte
internal enum HttpMethod: byte
{
Get,
Put,
Expand Down
2 changes: 1 addition & 1 deletion src/Servers/Kestrel/Core/src/Internal/Http/HttpParser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

namespace Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http
{
public class HttpParser<TRequestHandler> : IHttpParser<TRequestHandler> where TRequestHandler : IHttpHeadersHandler, IHttpRequestLineHandler
internal class HttpParser<TRequestHandler> : IHttpParser<TRequestHandler> where TRequestHandler : IHttpHeadersHandler, IHttpRequestLineHandler
{
private bool _showErrorDetails;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.IO.Pipelines;
using System.Net;
Expand All @@ -17,7 +16,7 @@

namespace Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http
{
public partial class HttpProtocol : IHttpRequestFeature,
internal partial class HttpProtocol : IHttpRequestFeature,
IHttpResponseFeature,
IResponseBodyPipeFeature,
IRequestBodyPipeFeature,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

namespace Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http
{
public partial class HttpProtocol : IFeatureCollection
internal partial class HttpProtocol : IFeatureCollection
{
private static readonly Type IHttpRequestFeatureType = typeof(IHttpRequestFeature);
private static readonly Type IHttpResponseFeatureType = typeof(IHttpResponseFeature);
Expand Down
2 changes: 1 addition & 1 deletion src/Servers/Kestrel/Core/src/Internal/Http/HttpProtocol.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@

namespace Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http
{
public abstract partial class HttpProtocol : IDefaultHttpContextContainer, IHttpResponseControl
internal abstract partial class HttpProtocol : IDefaultHttpContextContainer, IHttpResponseControl
{
private static readonly byte[] _bytesConnectionClose = Encoding.ASCII.GetBytes("\r\nConnection: close");
private static readonly byte[] _bytesConnectionKeepAlive = Encoding.ASCII.GetBytes("\r\nConnection: keep-alive");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

namespace Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http
{
public sealed partial class HttpRequestHeaders : HttpHeaders
internal sealed partial class HttpRequestHeaders : HttpHeaders
{
private static long ParseContentLength(string value)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http
/// <summary>
/// Default HttpRequest PipeReader implementation to be used by Kestrel.
/// </summary>
public class HttpRequestPipeReader : PipeReader
internal class HttpRequestPipeReader : PipeReader
{
private MessageBody _body;
private HttpStreamState _state;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

namespace Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http
{
public enum HttpRequestTarget
internal enum HttpRequestTarget
{
Unknown = -1,
// origin-form is the most common
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

namespace Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http
{
public sealed partial class HttpResponseHeaders : HttpHeaders
internal sealed partial class HttpResponseHeaders : HttpHeaders
{
private static ReadOnlySpan<byte> _CrLf => new[] { (byte)'\r', (byte)'\n' };
private static ReadOnlySpan<byte> _colonSpace => new[] { (byte)':', (byte)' ' };
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

namespace Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http
{
public class HttpResponsePipeWriter : PipeWriter
internal class HttpResponsePipeWriter : PipeWriter
{
private HttpStreamState _state;
private readonly IHttpResponseControl _pipeControl;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

namespace Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http
{
public partial class HttpResponseTrailers : HttpHeaders
internal partial class HttpResponseTrailers : HttpHeaders
{
public Enumerator GetEnumerator()
{
Expand Down
2 changes: 1 addition & 1 deletion src/Servers/Kestrel/Core/src/Internal/Http/HttpScheme.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

namespace Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http
{
public enum HttpScheme
internal enum HttpScheme
{
Unknown = -1,
Http = 0,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

namespace Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http
{
enum HttpStreamState
internal enum HttpStreamState
{
Open,
Closed,
Expand Down
2 changes: 1 addition & 1 deletion src/Servers/Kestrel/Core/src/Internal/Http/HttpVersion.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

namespace Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http
{
public enum HttpVersion
internal enum HttpVersion
{
Unknown = -1,
Http10 = 0,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

namespace Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http
{
public interface IHttpHeadersHandler
internal interface IHttpHeadersHandler
{
void OnHeader(Span<byte> name, Span<byte> value);
}
Expand Down
Loading