Writing a back-to-back HTTP Server plus HTTP Client for stream data?

Giganews Newsgroups
Subject: Writing a back-to-back HTTP Server plus HTTP Client for stream data?
Posted by:  AndrewFG (…@bb.com)
Date: Sun, 19 Apr 2009

I have an application where I need an HTTP server that receives incoming
HTTP requests, and then depending on the request headers, it opens a
back-to-back HTTP client session to a another (third party) server that
will serve the required data.

I think the starting point is to use an TIdHTTPServer, and in its
OnCommandGet, I would create a local TIdHTTPClient to fetch the data.

I think this would work so long as the amount of Content data is small:
it seems to me that the local TIdHTTPClient must download all the
requested data to its memory during the server's OnCommandGet, and only
after all data has been read, can it return from OnCommandGet, and thus
release the data to the calling client.

My problem is that the Content data is a music stream, (so it is to all
intents and purposes infinitely long). I think this means that my
OnCommandGet would never return, and my application will probably crash
due to memory overflow...

Any ideas how to get around this problem?

AndrewFG

Replies