Skip to content
This repository was archived by the owner on Dec 18, 2018. It is now read-only.

Refactored to use the fields from the HttpMethods class #1128

Merged
merged 2 commits into from
Sep 29, 2016

Conversation

mikaelm12
Copy link
Contributor

@dnfclas
Copy link

dnfclas commented Sep 28, 2016

Hi @mikaelm12, I'm your friendly neighborhood .NET Foundation Pull Request Bot (You can call me DNFBOT). Thanks for your contribution!
You've already signed the contribution license agreement. Thanks!

The agreement was validated by .NET Foundation and real humans are currently evaluating your PR.

TTYL, DNFBOT;

[InlineData("PUT / HTTP/1.1", ' ', true, MemoryPoolIteratorExtensions.HttpPutMethod)]
[InlineData("OPTIONS / HTTP/1.1", ' ', true, MemoryPoolIteratorExtensions.HttpOptionsMethod)]
[InlineData("TRACE / HTTP/1.1", ' ', true, MemoryPoolIteratorExtensions.HttpTraceMethod)]
[InlineData("CONNECT / HTTP/1.1", ' ', true,"CONNECT")]
Copy link
Contributor

@mikeharder mikeharder Sep 28, 2016

Choose a reason for hiding this comment

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

Any reason to hardcode "CONNECT" rather than using HttpMethods.Connect, as is done in the product code?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Can't use HttpMethods.Connect here because its not a const.

Copy link
Member

Choose a reason for hiding this comment

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

Fix the missing space though.

@@ -279,7 +270,7 @@ public static bool GetKnownMethod(this MemoryPoolIterator begin, out string know

if ((value & _mask4Chars) == _httpGetMethodLong)
{
knownMethod = HttpGetMethod;
knownMethod = HttpMethods.Get;
Copy link
Contributor

@mikeharder mikeharder Sep 28, 2016

Choose a reason for hiding this comment

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

Might be a tiny performance degradation since the value is changing from const to static readonly. Is there a reason the properties on HttpMethods are static readonly rather than const? I see the HttpMethods type is new for 1.1, so we should be able to change the properties to const now. After 1.1 ships it would be a breaking change.

I don't see any possible way the value of these properties would change in the future, so const should be safe.

Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Member

Choose a reason for hiding this comment

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

I doubt the performance will degrade

@@ -12,16 +13,6 @@ public static class MemoryPoolIteratorExtensions
{
private static readonly Encoding _utf8 = Encoding.UTF8;

public const string HttpConnectMethod = "CONNECT";
Copy link
Contributor

Choose a reason for hiding this comment

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

Are breaking changes to public APIs on internal types allowed in 1.1?

Copy link
Member

Choose a reason for hiding this comment

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

It's in an "Internal" namespace.

@@ -12,16 +13,6 @@ public static class MemoryPoolIteratorExtensions
{
private static readonly Encoding _utf8 = Encoding.UTF8;

public const string HttpConnectMethod = "CONNECT";
Copy link
Member

Choose a reason for hiding this comment

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

It's in an "Internal" namespace.

@@ -279,7 +270,7 @@ public static bool GetKnownMethod(this MemoryPoolIterator begin, out string know

if ((value & _mask4Chars) == _httpGetMethodLong)
{
knownMethod = HttpGetMethod;
knownMethod = HttpMethods.Get;
Copy link
Member

Choose a reason for hiding this comment

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

@halter73
Copy link
Member

@mikaelm12 You know how to run the plaintext benchmarks, right? I really don't expect this change will make any difference, but it's easy enough to test using @mikeharder's BenchmarksDriver.

[InlineData("PUT / HTTP/1.1", ' ', true, MemoryPoolIteratorExtensions.HttpPutMethod)]
[InlineData("OPTIONS / HTTP/1.1", ' ', true, MemoryPoolIteratorExtensions.HttpOptionsMethod)]
[InlineData("TRACE / HTTP/1.1", ' ', true, MemoryPoolIteratorExtensions.HttpTraceMethod)]
[InlineData("CONNECT / HTTP/1.1", ' ', true,"CONNECT")]
Copy link
Member

Choose a reason for hiding this comment

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

Could use MemberData but meh. We could have a second set of tests that verify reference equality.

Copy link
Contributor

Choose a reason for hiding this comment

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

@@ -22,7 +22,8 @@
"Microsoft.Extensions.TaskCache.Sources": {
"version": "1.1.0-*",
"type": "build"
}
},
"Microsoft.AspNetCore.Http.Abstractions": "1.1.0-*"
Copy link
Member

Choose a reason for hiding this comment

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

Sort

Copy link
Member

Choose a reason for hiding this comment

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

Hmmmmm, this is a new dependency? Doesn't this come in transitively already?

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah, it should be coming from Microsoft.AspNetCore.Hosting transitively.

Copy link
Contributor

@muratg muratg left a comment

Choose a reason for hiding this comment

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

👍

@mikaelm12 mikaelm12 merged commit 12adc7d into dev Sep 29, 2016
@mikaelm12 mikaelm12 deleted the mikaelm12/UseHttpMethodsConstants branch September 29, 2016 19:20
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants