How this tool gives Response in red or in green?
Closed this issue · 3 comments
I'm a new hand studying http-server recently, I know that it returns different HTTP Status Code such as 200 and 404 according to different cases, but I think in programs they are the same so I want to know how does your tool distinguish them?
Hi @Ingsuifon, you're right. The HTTP status code is just a number returned by the server as part of the response.
The code in RESTer is a bit convoluted. It uses a few browser extension APIs to get around security limitations of normal websites. This makes it quite hard to follow. But essentially, RESTer just uses fetch()
to make an HTTP request and then reads the status
from the response.
This results in a number, which would be in the rage of 100 - 599. By convention status codes are divided into 5 groups. I decided to show this in RESTer by applying a different color per group:
RESTer/src/site/elements/pages/rester-page-request.js
Lines 746 to 756 in d53cbb9
Does this make sense? Did I understand your question correctly?
Thank you very much. I haven't studied javaScript so I temporarily cann't read your code. But I understand your design concept. Thank you.
Great. I'm going to close this issue. But please feel free to re-open or open a new one if you have further questions.