开发者

Confused about the HTTP protocol

开发者 https://www.devze.com 2023-04-11 23:07 出处:网络
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.

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 H开发者_开发百科TTP protocol, but is this really the way to go?


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 :

  • HTTP protocol is extremely simple and like many things in tech simplicity trumps complexity even if the complex solution is more efficient (unless by a huge margin).
  • HTTP protocol is stateless making it much simpler to scale horizontally by adding more machines and balance load by simple load balancing techniques like round robin.
  • Easy to find a reasonable and free HTTP server to get your app up and running soon than implementing your own protocols, servers and taking your focus away from the real problem you want to solve.
  • Like any simple technology used by many parties, it gets better with time and with modern features like Keep-Alive, chunked transfer, pipelining you can overcome some drawbacks of connections overheads.


Yes that's the way to go. How else do you want to go about it?

Web Server <-------HTTP-------> Client

Client can be a browser, a mobile phone, an xbox. Anything on the receiving end of a server request is a client.


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

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号