restclient.el icon indicating copy to clipboard operation
restclient.el copied to clipboard

Disable 302 redirect

Open falood opened this issue 8 years ago • 8 comments

Is there any way to disable 302 redirect, please?

falood avatar Oct 12 '16 21:10 falood

Hm... I vaguely remember doing something to stop automatic redirects. But it's clear it doesn't work anymore indeed. Or I forgot to implement it.

Anyways, I'll have a look...

pashky avatar Oct 13 '16 13:10 pashky

Ah ok, I see now. If you need it fast, just customize url-max-redirections variable to 0, but this may affect any other libraries that use url.el, so please don't forget to reset it back when something else breaks :)

I'll make it set it 0 automatically and then restore back after request when I have spare moment. Thank you for noticing this.

pashky avatar Oct 13 '16 14:10 pashky

Amazing, it works! Thank you!

falood avatar Oct 13 '16 14:10 falood

Would be great if this plug-in didn't follow redirects (301 and 303 as well) by default but good to know there is a work-around

cjohansson avatar Mar 10 '17 07:03 cjohansson

I'd love to have a solution to this redirect issue so I can test an OAuth2 workflow.

Specifically, I'd love to turn off following for all redirect response codes 301, 302, and 303

I've tried this:

# -*- mode: restclient; url-max-redirections: 0 -*-

as well as setting variables directly in emacs, but it always follows the redirects.

I would expect it to instead return a 30X response code and associated response info.

I'm using the latest restclient, has this feature been taken out? Or is there another way to do it?

freckletonj avatar May 22 '17 01:05 freckletonj

You may need to make the variable buffer-local: (make-variable-buffer-local 'url-max-redirections). Then revert the buffer, and the file-local variable should work.

sandinmyjoints avatar Mar 19 '20 20:03 sandinmyjoints

I am not able to make this work either way - global or buffer local. It always automatically follows the redirect and doesn't retain the url it's redirected to (which in the case of oauth, contains the stuff I'm looking for).

weissjeffm avatar Dec 14 '20 21:12 weissjeffm

I know it's bit late to the party but I was hit by this recently. Poking around I've noticed that url-max-redirection is a custom variable. According to this answer proper way to modify those is via custom-set-variables. Indeed when I set it like:

(custom-set-variables '(url-max-redirections 0))

so it takes a proper effect even in the current buffer.

jkopanski avatar Feb 13 '23 10:02 jkopanski