-
Notifications
You must be signed in to change notification settings - Fork 191
Adding HTTP method constants #712
Changes from 2 commits
f9a9bde
b79adf1
3426646
8a3a4e0
0262337
8346fa0
4e93c97
3759ad7
d5edcab
80f0f21
c443c51
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
// 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; | ||
|
||
namespace Microsoft.AspNetCore.Http | ||
{ | ||
public static class HttpMethods | ||
{ | ||
public const string Connect = "CONNECT"; | ||
public const string Delete = "DELETE"; | ||
public const string Get = "GET"; | ||
public const string Options = "OPTIONS"; | ||
public const string Patch = "PATCH"; | ||
public const string Post = "POST"; | ||
public const string Put = "PUT"; | ||
public const string Trace = "TRACE"; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm for keeping these const. ReferenceEquals still works across assembly boundaries. Just don't mess up 😛 . There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. static readonly There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah, constants would be nicer (e.g they could be used for attribute values) 👍 |
||
|
||
public static bool Equals(string firstMethod, string secondMethod) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do we need this? Where are we going to use it? |
||
{ | ||
return StringComparer.OrdinalIgnoreCase.Equals(firstMethod, secondMethod); | ||
} | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. we should still have the Equals(string, string) method |
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,6 +4,7 @@ | |
using System.Collections.Generic; | ||
using Microsoft.AspNetCore.Http.Features; | ||
using Xunit; | ||
using Microsoft.AspNetCore.Http; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sort usings |
||
|
||
namespace Microsoft.AspNetCore.Owin | ||
{ | ||
|
@@ -25,15 +26,15 @@ public void OwinHttpEnvironmentCanBeCreated() | |
{ | ||
var env = new Dictionary<string, object> | ||
{ | ||
{ "owin.RequestMethod", "POST" }, | ||
{ "owin.RequestMethod", HttpMethods.Post }, | ||
{ "owin.RequestPath", "/path" }, | ||
{ "owin.RequestPathBase", "/pathBase" }, | ||
{ "owin.RequestQueryString", "name=value" }, | ||
}; | ||
var features = new OwinFeatureCollection(env); | ||
|
||
var requestFeature = Get<IHttpRequestFeature>(features); | ||
Assert.Equal(requestFeature.Method, "POST"); | ||
Assert.Equal(requestFeature.Method, HttpMethods.Post); | ||
Assert.Equal(requestFeature.Path, "/path"); | ||
Assert.Equal(requestFeature.PathBase, "/pathBase"); | ||
Assert.Equal(requestFeature.QueryString, "?name=value"); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this be singular?
HttpMethod.Get
HttpMethod.IsGet(string)
HttpMethod.Equals(string, string)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed. This is similar to a non-flag enum.