I will not find in the documentation and in the search for such a scenario. The client sends one or more commands in one request, and the server responds as it executes with several messages.

Multipart / * types are suitable for this. The server will write messages with a multipart separated by boundary. The client will display data as it is received. It would be desirable for each part of the response to be executed Kalbak.

I know web sockets, but no.

For example , Google has such an api

Interaction example (in Google, the example is slightly different, but the response is similar)

I send a POST request to my server. The answer is:

HTTP/1.1 200 OK Content-Type: multipart/mixed; boundary=batch_pK7JBAk73-E=_AA5eFwv4m2Q= --batch_pK7JBAk73-E=_AA5eFwv4m2Q= Content-Type: application/http Content-ID: <response-1> HTTP/1.1 200 OK Content-Type: application/json; charset=UTF-8 { "id":1, "data": "data1" } --batch_pK7JBAk73-E=_AA5eFwv4m2Q= Content-Type: application/http Content-ID: <response-2> HTTP/1.1 200 OK Content-Type: application/json; charset=UTF-8 { id: 2, data: "data2" } --batch_pK7JBAk73-E=_AA5eFwv4m2Q= 

and so much response in 15-30 minutes. Another encapsulation is possible.

It would be desirable that on each answer inside big callback in javascript was executed. Like .then(successCallback, errorCallback) . Only then will be executed when the HTTP request ends.

Working with HTTP attachments or with simple attachments like mjpeg streams is interesting.

EventSource is interesting, but it will reconnect at the end of the stream. I need a request-response.

  • @vihtor is one request and one response connection. I need something else. - eri
  • multipart says that the request body consists of several parts. The server always responds 1 time. And the answer from Google comes 1 time. Read the documentation "There is a single standard HTTP response with a multipart / mixed content type" There is even an example. - Igor Golovin
  • @IgorGolovin one answer is a htp in which there are several answers api. - eri
  • one
    HTTP and websoket are two different protocols that are not related to each other. Yes, they are both implemented on top of TCP, but this does not mean that they are the same. Long polling is not a protocol at all, so by definition it cannot be the same as HTTP. In Google Api, the word response they call the data between the separators (boundary). There may be many. The server response at the docks is called HTTP response and it is only one. The HTTP response contains several response ie data. - Igor Golovin

0