Skip to content

Commit

Permalink
Merge pull request #8 from cherepets/http_methods
Browse files Browse the repository at this point in the history
HTTP methods
  • Loading branch information
StefH authored Apr 27, 2017
2 parents 45830d7 + 7e08ce1 commit b55e76d
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/NETStandard.HttpListener/HttpListenerRequest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ private void ParseRequestLine(string[] lines)

private async Task PrepareInputStream(StreamReader reader)
{
if (HttpMethod == HttpMethods.Post || HttpMethod == HttpMethods.Put || HttpMethod == HttpMethods.Patch)
if (HttpMethods.CanHaveContent(HttpMethod))
{
Encoding encoding = Encoding.UTF8;

Expand Down
24 changes: 22 additions & 2 deletions src/NETStandard.HttpListener/HttpMethods.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,30 @@
{
public static class HttpMethods
{
public static readonly string Post = "POST";
public static readonly string Get = "GET";
public static readonly string Patch = "PATCH";
public static readonly string Post = "POST";
public static readonly string Put = "PUT";
public static readonly string Patch = "PATCH";
public static readonly string Delete = "DELETE";
public static readonly string Copy = "COPY";
public static readonly string Head = "HEAD";
public static readonly string Options = "OPTIONS";
public static readonly string Link = "LINK";
public static readonly string Unlink = "UNLINK";
public static readonly string Purge = "PURGE";
public static readonly string Lock = "LOCK";
public static readonly string Unlock = "UNLOCK";
public static readonly string Propfind = "PROPFIND";
public static readonly string View = "VIEW";
public static readonly string Trace = "TRACE";
public static readonly string Connect = "CONNECT";

public static bool CanHaveContent(string method)
=> method != Get
&& method != Copy
&& method != Head
&& method != Purge
&& method != Trace
&& method != Connect;
}
}

0 comments on commit b55e76d

Please sign in to comment.