question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

REST Client adds header to a request without a way to inspect what is added

See original GitHub issue

I spent several hours today to diagnose an issue until I learned that REST client adds some headers to REST calls without providing any way to inspect what is added.

When a cookie or header is automatically added to a request, REST client needs to provide a way to let us know what exactly is added:

rest-client.rememberCookiesForSubsequentRequests rest-client.defaultHeaders

After spending several hours, I used Wireshark and found that my requests are being changed by this extension, without any straightforward way for me to know what happened.

Postman does not do such a thing. The Console transparently shows the raw version of what has been sent to a server.

I suggest this matter be addressed.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
bohdan-kolomiietscommented, Oct 30, 2021

@Huachao , thanks for you work and this extension!

@asmith3006 , thanks for you recommendation, it helped!

But, I would not agree that this recommendation is the solution of root problem. Other peole still will face this problem, spending some time wondering what is going on, and only then start google the problem.

Doumentation does not specifies that setting "rest-client.previewOption": "exchange" shows all headers and does not hide any of them. In description, it is written “Preview the whole HTTP exchange(request and response)”. From this description I don’t get that before some headers were hidden and with this value they will become visible.

I use this extensions to debug back-end calls, and cookies are used in many places. Because of this default behavior to save previously set cookies, I have made wrong assumptions about nature of the bug and spent several hours debugging, and onlythen I realized that something wrong with extensions’ behavior.

@Huachao , why you decided to make to make option “rest-client.rememberCookiesForSubsequentRequests” default value to be “true”. Has any surver been conducted and users voted that they need more browser-like behaviour?

I would propose

  1. show all headers sent and received (presence of all headers is one of the reasones why people use Fiddler, and your extension too, I suppose).
  2. make option “rest-client.rememberCookiesForSubsequentRequests” default value to be “false”. It is a well know rule that “explicit is better than implicit”.
1reaction
asmith3006commented, Jul 21, 2021

Does this help?

Change setting: “rest-client.previewOption”: “exchange”

Then you get (I believe) the full sent request.

Also, you can disable the Cookies: “rest-client.rememberCookiesForSubsequentRequests”: false

I’m assuming the cookies is enabled so you can do authentication and pass the cookies in subsequent calls easier. Personally I’ve turned this off to make each call explicit.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Understanding REST Headers and Parameters - SoapUI
The REST headers and parameters contain a wealth of information that can help you track down issues when you encounter them. HTTP Headers...
Read more >
Add instruction 'how' to perform a REST API request by adding ...
Specify a custom header Confirmation: no-confirmation · Add a query param ?confirmation=false · Add a send_confirmation field to the request body.
Read more >
Using the "Accept" Request Header in RESTful APIs - YouTube
In this video I'll be demonstrating the usage of the "Accept" request header in HTTP (and how it's used in RESTful APIs or...
Read more >
22. What is header in API and how to pass them in Rest ...
Headers are metadata associated with the request and response of API. In this video, we are going to learn different ways of passing...
Read more >
Using the REST Client - Quarkus
The MicroProfile REST client allows amending request headers by registering a ClientHeadersFactory with the @RegisterClientHeaders annotation. Let's see it in ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found