HTTP Request originated from HTTP Server

2019-08-29 11:06发布

问题:

I have a HTTP Client connected to a HTTP Server - HTTP 1.1 and the TCP connection is persisted. HTTP client is sending request over an interval and receives response from server.

In this persisted TCP connection, can HTTP Server send a HTTP request over the existing TCP connection to the HTTP client? (We need this - say the page has an information which is changing dynamically (Example: some one hit a goal / some one hit six / some one took a wicket / some VVVIP killed / etc).

Does the existing standard allows HTTP server to send HTTP request to its connected client?

Note: I am not looking at page refresh / other web or application protocols like AJAX...

回答1:

You are asking for a server push, and no, it is not supported by HTTP/1.1.

Requests headers are distinct from response headers, such that the push mechanism defined in the proposed HTTP/2 spec works by combining together the headers of the request and response.

You should look at AJAX/Comet because it essentially implements what you describe: the client-side application defines a method to receive any kind of game action, and then the server specifies which action occurred for each push.



标签: http