大网数据广告活动
网站运营与故障问答

What are the differences between a regular HTTP web server and a REST server?

· 52CE 我爱测

I am learning about REST services and from what I understood until now the only difference is the language of the file that is outputted by the script that runs as a backend. Can a regular web server that outputs a HTML file that…

问题原文

原帖链接 · yoyo_fun · CC BY-SA 3.0

I am learning about REST services and from what I understood until now the only difference is the language of the file that is outputted by the script that runs as a backend.

Can a regular web server that outputs a HTML file that contains the number of users of a website be considered a REST web service? After all it can be called by a program using a GET request and in the response body there is the number of students inside some tag that can be programatically read by an application after parsing the HTML file like it would parse a JSON of XML in case of more traditional REST service.

There are also web pages where it shows for example details of a book and the book id is sent through the GET request URL. That response may again be parsed by an application that called that URL with the GET verb and than the program can find out information about the book if it knows what is the structure of the HTML file. That again may be seen as a REST web service in my knowledge.

Am I wrong in the way I understood REST services until now?

社区高分解答

原帖链接 · Rob · CC BY-SA 3.0

HTTP is a standard method, a protocol, for transporting information. REST is a non-standard method for representing state of that information. REST requests take place using the HTTP protocol. That protocol gives methods of exchanging data via GET, POST, DELETE, etc. REST defines how to use those methods but those methods are part of HTTP.

Bad example, HTTP is the air carrying my voice to your ears. REST is how I ask you my question and you give me an answer.

Any web server that handles HTTP can also do REST but some servers, iirc, do not handle DELETE or PUT, both of which are used by REST. Note that REST uses GET/POST/DELETE/PUT but that's part of the HTTP protocol, not REST.

The structure of the HTML file means nothing. What matters is how the information is requested from the server. The state of the information, or page, is kept on the server. That URL remains a constant as it represents some information. Variations of the information change as the URL changes but you always retrieve it from the same URL.

I apologize for rambling cause it's been a while since I've studied this (and I just woke up).

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Webmasters Stack Exchange
适用范围
以原帖系统、软件版本与发布日期为准(2016-04-28)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 3.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。