pashky/restclient.el

Ignoring headers for redirection

Opened this issue · 2 comments

Hi, there is a problem when restclient gets 301 status code as response. For example I'm dealing with a server that redirects /profile to /profile/ (an slash appended to the end of URL) and the endpoint needs Authorization header. This is my restclient file:

# Profile
GET :address/profile
Content-Type: application/json
Authorization: :token

Response in Emacs:

{
  "code": 401,
  "error_message": "Authentication credentials were not provided."
}
// GET http://127.0.0.1:8000/profile
// HTTP/1.1 200 OK
// Date: Fri, 24 Apr 2020 19:05:27 GMT
// Server: WSGIServer/0.2 CPython/3.6.10
// Content-Type: application/json
// Vary: Accept, Origin, Accept-Language, Cookie
// Allow: GET, PUT, HEAD, OPTIONS
// X-Http-Status-Code: 401
// X-Frame-Options: SAMEORIGIN
// Content-Length: 123
// Content-Language: en
// Request duration: 0.274723s

Copy as Curl:

$ curl -i -H Authorization\:\ JWT\ tokenblablablah -H Content-Type\:\ application/json -XGET http\://127.0.0.1\:8000/profile
HTTP/1.1 301 Moved Permanently
Date: Fri, 24 Apr 2020 19:13:23 GMT
Server: WSGIServer/0.2 CPython/3.6.10
Content-Type: text/html; charset=utf-8
Location: /profile/
Content-Length: 0
Vary: Origin, Accept-Language, Cookie
Content-Language: en

Emacs version: 26.3
Restclient: 20191009.1208

I've had the same issue with a 308 Permanent Redirect (for an http to https redirection).

Emacs 25.2.2, restclient.el 20191009.1208.

Happened to me, too. Expecting restclient to print the intermediate 301 response with 'Location:' header and later following the redirect, as curl --location/-L would do. Is there any variable which I'm missing to achieve this? Otherwise, at least some warning/notice/todo in the readme would be helpful (willing to send a PR for the readme, if needed).