Skip to content

Commit 5f996f9

Browse files
glucacimichaelstaib
authored andcommitted
Forward the GET request to next handler if contains no query (#135)
1 parent 1ec7eae commit 5f996f9

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

src/AspNetCore/GetRequest.cs

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,20 +10,22 @@ internal static class GetRequest
1010

1111
internal static bool IsGet(this HttpRequest request)
1212
{
13-
return request.Method.Equals(_getMethod, StringComparison.OrdinalIgnoreCase);
13+
return request.Method.Equals(_getMethod, StringComparison.OrdinalIgnoreCase)
14+
&& HasQueryParameter(request.HttpContext);
1415
}
1516

1617
internal static QueryRequest ReadRequest(HttpContext context)
1718
{
18-
string query = string.Empty;
19-
20-
if (context.Request.QueryString.HasValue &&
21-
context.Request.Query.ContainsKey(_queryIdentifier))
19+
return new QueryRequest()
2220
{
23-
query = context.Request.Query[_queryIdentifier].ToString();
24-
}
21+
Query = context.Request.Query[_queryIdentifier].ToString()
22+
};
23+
}
2524

26-
return new QueryRequest() {Query = query};
25+
private static bool HasQueryParameter(HttpContext context)
26+
{
27+
return context.Request.QueryString.HasValue &&
28+
context.Request.Query.ContainsKey(_queryIdentifier);
2729
}
2830
}
2931
}

0 commit comments

Comments
 (0)