对HTTP协议感到困惑
我对 HTTP 协议有点困惑,据我所知,HTTP 是为了传递网页而创建的,主要是在 Web 服务器和浏览器之间发送消息。 但似乎许多应用程序都使用了 HTTP,这些应用程序确实使用互联网进行通信,但不是 Web 应用程序(“使用 Web 浏览器作为客户端的应用程序”)。
我问这个问题是因为我开始开发 iPhone 应用程序(一种导航应用程序),并且我需要在 iPhone 客户端和我的服务器之间发送消息。现在人们一直告诉我使用 HTTP 协议,但这真的是正确的方法吗?
I'm a little confused about the HTTP protocol, from what i know HTTP was made for delivering web pages and primarily sending messages between a web server and a browser.
But it seems that HTTP is used anywhere in a lot of apps that indeed uses the internet for communicating but are not web application("application that uses a web browser as a client").
I'm asking this because i started developing an iPhone app (kind of navigation app) and i need to send messages between the iPhone client and my server. Now people keep telling me to use HTTP protocol, but is this really the way to go?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
同意从 SOAP 转向 REST 和 QUERY 是一件好事。
我们目前正在实现一个使用 HTTP 作为双向传输机制的系统。
上传到服务器的响应是标准 HTTP 响应,例如 200 = 成功但没有正文。
对查询的响应是一个 ASCII 文本页,其中答案作为正文。然后我们只需将 ASCII 转换回二进制即可使用数据。
这种方法的优点是你只需要提供正确的 URL 和参数就可以处理一切。
除非您的协议栈知道如何格式化 post 和 get 请求,否则您将需要自己执行此操作。虽然这很乏味,但它在 W3C 协议 中有详细记录,但它有点必须自己经历这一切,这很乏味。因此,如果您必须这样做,那么我建议您购买一本电子书来帮助理清细节。一些例子是:
HTTP
Agreed that the move to REST and QUERY from SOAP is a good thing.
We are currently implementing a system that will use HTTP as the bidirectional transfer mechanism.
The response back to uploads to the server is a standard HTTP response such as 200 = success with no body.
The response to a query is an ASCII text page with the answer as the body. We then just turn the ASCII back to binary to use the data.
The advantage of this method is that you just have to provide the right URL and parameters and you can handle everything.
Unless your protocol stack knows how to format post and get requests, then you will need to do that yourself. While this is tedious it is well documented at W3C Protocols however it is a bit tedious to have to go through it all yourself. So if you are having to fo that then I recommend getting an eBook to help sort out the details. Some examples are:
HTTP
https 代表超文本传输文本,它有助于客户端与服务器进行通信。客户端称为发出请求的设备,服务器称为处理该请求,有四种方法。例如,当您进入某个网站时,您的浏览器将发出请求以获取 html、css、js 和其他文件,以及图像(如果需要)(GET 方法)。您可以在很多网站表单中看到另一个例子,您需要填写该表单才能进入系统,它被称为(POST 方法)。此外,如果您在 Facebook 上有一篇帖子,并且您想要重写或编辑该帖子,则称为(PUT 方法),您将仅更改一项内容,而不会触及另一项内容。最后一个是(DELETE 方法),当你想删除 facebook 中的某些内容时使用它
https stands for Hyper Text Transfer Text, it helps communicate a client with the server. The client is called a device being made request, server is called handling that request, there four methods. For example when you get into some website your browser will make request in order to get html, css, js and other file, and also images if they need (GET method). Another example you can see in a lot of website form which you need to fill to get into system it is called (POST method). Also if you have a post for example in facebook, and you want to rewrite or edit this post it is called (PUT method), you will change only one content without touching another one. And the last one is (DELETE method), it is used when you want delete something in facebook
你的问题是有效的,如果我可以重申一下,为什么我们对每个服务器客户端通信都使用 HTTP,而它通常用于浏览器 Web 服务器用例,并且与直接 TCP 通信相比效率较低。我的理由如下:
Your question is valid, if I can restate, why are we using HTTP for every Server-Client communications while it was meant typically for browser-web server use case and can be less efficient compared to direct TCP communication. My reasons below :
是的,这就是要走的路。您还想怎样做呢?
客户端可以是浏览器、手机、Xbox。服务器请求接收端的任何东西都是客户端。
Yes that's the way to go. How else do you want to go about it?
Client can be a browser, a mobile phone, an xbox. Anything on the receiving end of a server request is a client.