Server Push - Request and Reply Requirements

The client browser sends the pre-defined URI to request media data through server push. The HTTP server replies multipart mixed-media and boundary delimiter telling the client to expect the document to follow in several parts.

The following is an example, the blue part of the reply presents the HTTP server reply, and the other part, the separator and media data, is produced by the third-party process, server push process.

Request
GET /video.mjpg HTTP/1.1
Host: 192.168.2.121
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1) Gecko/20061010 Firefox/2.0
Accept: text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5
Accept-Language: en-us,en;q=0.5
Accept-Encoding: gzip,deflate
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
Keep-Alive: 300
Connection: keep-alive
Reply
HTTP/1.1 200 OK
Content-Type: multipart/x-mixed-replace;boundary=myboundary
Server: Vivotek Video Server
Date: Wed, 13 Dec 2006 09:07:33 GMT
Cache-Control: no-store
Pragma: no-cache
Connection: close

--myboundary
Content-Type: image/jpeg
Content-Length: 25688

......JFIF.....H.H............."............
.
.
.
.
...
.. .....'... .)10.)-,3:J>36F7,-@WAFLNRSR2>ZaZP`JQRO.......

The MIME message format is used by HTTP to encapsulate data returned from a server in response to a request. Typically, an HTTP response consists of only a single piece of data. However, MIME has a standard facility for representing many pieces of data in a single message (or HTTP response). This facility uses a standard MIME type called "multipart/mixed"; a multipart/mixed message looks something like:

Content-type: multipart/mixed;boundary=ThisRandomString

--ThisRandomString
Content-type: text/plain

Data for the first object.

--ThisRandomString
Content-type: text/plain

Data for the second and last object.

--ThisRandomString--

The above message contains two data blocks, both of type "text/plain". The final two dashes after the last occurrence of "ThisRandomString" indicate that the message is over; there is no more data.

For server push we use a variant of "multipart/mixed" called "multipart/x-mixed-replace". The "x-" indicates this type is experimental. The "replace" indicates that each new data block will cause the previous data block to be replaced -- that is, new data will be displayed instead of (not in addition to) old data.

So here's an example of "multipart/x-mixed-replace" in action:

Content-type: multipart/x-mixed-replace;boundary=ThisRandomString

--ThisRandomString
Content-type: text/plain

Data for the first object.

--ThisRandomString
Content-type: text/plain

Data for the second and last object.

--ThisRandomString--

The key to the use of this technique is that the server does not push the whole "multipart/x-mixed-replace" message down all at once but rather sends down each successive data block whenever it sees fit. The HTTP connection stays open all the time, and the server pushes down new data blocks as rapidly or as infrequently as it wants, and in between data blocks the browser simply sits and waits for more data in the current window. The user can even go off and do other things in other windows; when the server has more data to send, it just pushes another data block down the pipe, and the appropriate window updates itself.

So here's exactly what happens:

Note: You must NOT use any spaces in your content type, this includes the boundary argument. NCSA HTTPD will only accept a single string with no white space as a content type. If you put any spaces in the line (besides the one right after the colon) any text after the white space will be truncated.

As an example, the following will work:
Content-type: multipart/x-mixed-replace;boundary=ThisRandomString

The following will not work:
Content-type: multipart/x-mixed-replace; boundary=ThisRandomString