crawly icon indicating copy to clipboard operation
crawly copied to clipboard

Dropped request handling

Open Ziinc opened this issue 4 years ago • 4 comments

There needs to be a mechanism to handle dropped requests/error response codes. Would it be better to implement it through a callback in the settings, or through a pipeline?

Ziinc avatar Oct 14 '20 06:10 Ziinc

To clarify, when I say handle, I mean "to do something with the request, like update a database)

Ziinc avatar Oct 14 '20 07:10 Ziinc

I suggest you moving onto Request / Response Middlewares.

This way we can integrate current middleware type as Request Middleware and provide a way to basically tag, filter or do something else upon getting new response using Response Middleware.

dkgitdev avatar Oct 24 '20 18:10 dkgitdev

Hmmm. This would mean a middleware piping step prior to piping the success response through the item pipeline.

Let's call this hypothetical step Response Middlewares.

Should the sole responsibility of the Response Middlewares be to do something with the responses, successful or not? This could be the step where we check for retries, and tag responses, or basically control the flow of the response (whether to be dropped, logged, piped etc).

Currently, as is, only code 200 responses are passed to the item pipelines

Ziinc avatar Oct 25 '20 09:10 Ziinc

I think, that the more flexibility you have – the better.

The response middleware list can contain only one middleware by default, like AllowStatusCodes with the tuple of 200, 201 as argument. This way it'll provide both sensible defaults and flexible way to inject some additional code, based on what actions you actually want to happen.

Because when the status code IS the information you'd like to gather, you'll need some way to override the defaults in a non-hacky way.

dkgitdev avatar Oct 25 '20 10:10 dkgitdev