alf/ob-restclient.el

Add header argument for hiding the headers

rodrigo-morales-1 opened this issue · 2 comments

The default behavior is the following.

#+BEGIN_SRC restclient
GET http://127.0.0.1:8000/api/news/
#+END_SRC

#+RESULTS:
#+BEGIN_SRC js
[
  {
    "title": "foo",
  },
  {
    "title": "bar",
  }
]
// GET http://127.0.0.1:8000/api/news/
// HTTP/1.1 200 OK
// Date: Wed, 30 Jun 2021 19:38:41 GMT
// Server: WSGIServer/0.2 CPython/3.9.5
// Content-Type: application/json
// Vary: Accept, Cookie, Origin
// Allow: GET, POST, HEAD, OPTIONS
// X-Frame-Options: DENY
// Content-Length: 553
// X-Content-Type-Options: nosniff
// Referrer-Policy: same-origin
// Request duration: 0.004431s
#+END_SRC

However, let's say that someone wants to hide the headers of the request, since I don't know a way for accomplishing this, I make the following proposal: Add the :headers header argument.

With the :headers no header argument, the result would be the following.

#+BEGIN_SRC restclient :headers no
GET http://127.0.0.1:8000/api/news/
#+END_SRC

#+RESULTS:
#+BEGIN_SRC js
[
  {
    "title": "foo",
  },
  {
    "title": "bar",
  }
]
#+END_SRC

I guess the following is a better idea. Support the :results header argument with the following values.

  • :results body shows the body of the response.
  • :results header shows the header of the response.
  • :results both shows both the body and the header of the response.
alf commented

This is related to pashky/restclient.el#141.