Advanced REST Client blog
Blog for Advanced Rest Client - a Google Chrome application.

HTTP client on chrome.socket.tcp

Hi developers,

Many of you asked me about the possibility to setting in a request a HTTP headers that are prohibited in XHR. The spec for this object prevents setting headers like User-Agent, Proxy-*, Accept-Encoding etc. I couldn't do much about it, until now.

I'd like to introduce the socket-fetch library that I've made for Advanced Rest Client. It is an implementation of a HTTP client that is using chrome.sockets.tcp API and create connection directly on socket. This means that the app will no longer have any limitations from transport specification (either Fetch or XHR API). It gives you more control over what you are sending to the server and makes the app even more powerful tool for API testing.



The new implementation well be available in the app in a few weeks. I'm currently working on upgrading the app to new Chrome desktop apps where this API is available.

TLDR;

If you interested in using the library in your project, there's a good news - it's open source. You will find a project on GitHub as a socket-fetch library. There is a quick start section where is described how to use the library.
Use of the library is similar to new Fetch API. However I've added events similar to XHR specifications so you can listen for events like loadstart or loadend. Also the response object will contain information about redirects occurred during the request. The list of response will contain the same response object so it is easy to debug everything that was happened during the connection.
Alongside with redirects there is a second useful parameter in the response: stats. It is an object containing execution times that is consistent with timings object in HAR 1.2 spec.

I hope you will enjoy new library I made for Advanced Rest Client and the power that it brings to the app.
As always - happy RESTing.