You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Nov 1, 2023. It is now read-only.
I'm using the ThrottlingMiddleware in OWIN pipeline. I need to log requests rejected when quota is exceeded.
Since I have my own separate logging middleware preceding the ThrottlingMiddleware in the pipeline (so I can log all failed requests), the first issue for me was to figure out why IOwinContext.Response has HTTP Status of 200 after coming back from ThrottlingMiddleware while I obviously receive 429 in the client. I guess it's because you use IOwinResponse.OnSendingHeaders to populate the response and that happens when all the middlewares are done with processing (correct me if I'm wrong here).
So I decided to go with implementing a separate IThrottleLogger logger. The problem is that as I can see in the source of ThrottlingMiddleware (line 191 in tag 1.4.3), the ThrottleLogEntry is built with null as request value:
I understand that this is probably because you can't build an HttpRequestMessage in OWIN context, but this makes the logger pretty useless for me (I am more interested in the contents of the incoming request rather than client's key or IP).
Is there any way to solve this? Right now it seems to me that simply populating the IOwinContext.Response on the spot would fix my issue but maybe it violates some other assumption.
Thanks in advance.
The text was updated successfully, but these errors were encountered:
I modified the code to fix this issue by adding new logger type.
Seems to me the best option would be to split this package into two NuGets, one for Web Api and another for Owin. Not sure how hard would it be though.
I am unsure if logging of every request in case of an DDoS attack is really the best idea. Maybe it is acceptable to just count the number of such events with a performance counter or ETW event.
Sign up for freeto subscribe to this conversation on GitHub.
Already have an account?
Sign in.
I'm using the
ThrottlingMiddleware
in OWIN pipeline. I need to log requests rejected when quota is exceeded.Since I have my own separate logging middleware preceding the
ThrottlingMiddleware
in the pipeline (so I can log all failed requests), the first issue for me was to figure out whyIOwinContext.Response
has HTTP Status of 200 after coming back fromThrottlingMiddleware
while I obviously receive 429 in the client. I guess it's because you useIOwinResponse.OnSendingHeaders
to populate the response and that happens when all the middlewares are done with processing (correct me if I'm wrong here).So I decided to go with implementing a separate
IThrottleLogger
logger. The problem is that as I can see in the source ofThrottlingMiddleware
(line 191 in tag 1.4.3), theThrottleLogEntry
is built with null as request value:I understand that this is probably because you can't build an
HttpRequestMessage
in OWIN context, but this makes the logger pretty useless for me (I am more interested in the contents of the incoming request rather than client's key or IP).Is there any way to solve this? Right now it seems to me that simply populating the
IOwinContext.Response
on the spot would fix my issue but maybe it violates some other assumption.Thanks in advance.
The text was updated successfully, but these errors were encountered: