Reggae tutorial: http.stream

From MorphOS Library

Revision as of 18:10, 24 August 2010 by Krashan (talk | contribs) (Idea of live software update: Added the last paragraph.)

Grzegorz Kraszewski

Idea of live software update

Live software update over Internet is becoming popular in mainstream operating systems and its applications. It is comfortable to users, allows for fast distribution of bugfixes and security updates and also (what is important for commercial products) creates an additional channel of advertising. The general idea of live update is simple. An application connects to a remote server, checks for updates, download them if any found, then install new files in proper places. After that application asks user for a restart and optionally restarts itself.

While it sounds easy in the above description, there are some obstacles on the way. MorphOS provides network connections handling on TCP/UDP protocol level (or socket level API-wise). Some higher level protocol must be used to handle update check and files downloading. It may be some custom thing (which has a big disadvantage that it must be implemented on the server side too), or some standard protocol, like FTP or HTTP. While FTP seems to be better suited, looking at its name, HTTP is more versatile as it allows for easy implementation of additional features on server side like download counters, dynamic content generation, sending information to the server and more.

HTTP is not a very complicated protocol, handling it at socket level is some serious work however. On the other hand using an external application like wget gives very little control over downloading process. MorphOS had no embeddable HTTP client, but now it has one, which is Reggae http.stream class. It is a lightweight implementation of HTTP/1.1 protocol. The only limitation is that it supports GET requests only (it may support also POST in the future).

What is http.stream class?

Basic download operation

Downloading to disk on subprocess

Network error reporting

Additional features of http.stream