Skip to content

easyextensionsaspnetcore HttpRequestExtensions

BigMakCode edited this page Aug 5, 2024 · 1 revision

HttpRequestExtensions Public class

Description

HttpRequest extensions.

Diagram

 flowchart LR
classDef interfaceStyle stroke-dasharray: 5 5;
classDef abstractStyle stroke-width:4px
subgraph EasyExtensions.AspNetCore
EasyExtensions.AspNetCore.HttpRequestExtensions[[HttpRequestExtensions]]
end
Loading

Members

Methods

Public Static methods

ReturnsName
stringGetRemoteAddress(HttpRequest request)
Get remote host IP address using proxy "X-Real-IP", "CF-Connecting-IP", "X-Forwarded-For" headers, or connection remote IP address.
boolTooManyRequests(...)
Check if there are too many requests from the same IP address, using in-memory cache.

Details

Summary

HttpRequest extensions.

Methods

GetRemoteAddress

publicstaticstringGetRemoteAddress(HttpRequestrequest)
Arguments
TypeNameDescription
HttpRequestrequest
Summary

Get remote host IP address using proxy "X-Real-IP", "CF-Connecting-IP", "X-Forwarded-For" headers, or connection remote IP address.

Returns

IP address, or "Unknown" by default.

TooManyRequests [1/3]

publicstaticboolTooManyRequests(HttpRequestrequest,intatTimeSeconds,intmaxRepeats)
Arguments
TypeNameDescription
HttpRequestrequestHTTP request.
intatTimeSecondsTime period to check, default is 60 seconds.
intmaxRepeatsMaximum number of requests for the specified time period, default is 1.
Summary

Check if there are too many requests from the same IP address, using in-memory cache.

Returns

True if there are too many requests, otherwise false.

TooManyRequests [2/3]

publicstaticboolTooManyRequests(HttpRequestrequest,TimeSpanatTime,intmaxRepeats)
Arguments
TypeNameDescription
HttpRequestrequestHTTP request.
TimeSpanatTimeTime period to check, default is 60 seconds.
intmaxRepeatsMaximum number of requests for the specified time period, default is 1.
Summary

Check if there are too many requests from the same IP address, using in-memory cache.

Returns

True if there are too many requests, otherwise false.

TooManyRequests [3/3]

publicstaticboolTooManyRequests(stringip,TimeSpanatTime,intmaxRepeats)
Arguments
TypeNameDescription
stringipIP address.
TimeSpanatTimeTime period to check.
intmaxRepeatsMaximum number of requests for the specified time period, default is 1.
Summary

Check if there are too many requests from the same IP address, using in-memory cache.

Returns

True if there are too many requests, otherwise false.

Generated withModularDoc

Clone this wiki locally