drill icon indicating copy to clipboard operation
drill copied to clipboard

Expected HTTP status codes / redirects

Open acdha opened this issue 3 years ago • 4 comments

While giving drill a try, I noticed that it follows redirects and reports the resulting final page. I had been planning to have a sequence where it would do something like /, /login, etc. and was hoping to have a way to either say “Don't follow redirects on this URL” or “Expect this page to return a 403” so I can exercise the unauthenticated endpoints as well as their targets.

acdha avatar Aug 25 '20 23:08 acdha

The current behaviour for redirects, right now, is the default from reqwest, that follows 10 redirects. You can find more information here:

https://docs.rs/reqwest/0.10.4/reqwest/redirect/struct.Policy.html

If you think this could be a useful feature to be added to drill to let the user set the number of redirects, let me know.

fcsonline avatar Sep 04 '20 15:09 fcsonline

The main thing I was thinking was having two options to say it's not an error to get a non-200 for a particular response and to disable redirects so you could do something like this:

plan:
  - name: user_page_without_session
    request:
      url: /private/content/
      follow_redirects: false
      expected_status: 302

The reqwest docs make me wonder whether that could simply be something like this (it's not immediately clear to me whether there's any difference between limited(0) and none()):

plan:
  - name: user_page_without_session
    request:
      url: /private/content/
      redirect_policy:
        limited: 0
      expected_status: 302

acdha avatar Sep 04 '20 18:09 acdha

It could be really interesting to add this follow_redirects option you mentioned :ok_hand: About expected_status, I'm not sure to understand what is going to do.

fcsonline avatar Oct 24 '20 17:10 fcsonline

I would really like the feature of not following redirects :) It's very common for a web app (implemented in the old style of generating HTML templates on the server) to use the Post/Redirect/Get pattern. So almost all POST endpoints return redirects haha.

arcstur avatar Apr 01 '24 14:04 arcstur