Making a converter(proxy) HTTP server with wwwlib?

Remember me? I wanted to do a proxy/converter using WWW library


Client                        Proxy/Converter              The WEB
(requestor)                                            (real WWW server)

          GET URL             (pass through)        GET URL
----------------------------> .............. ------------> ........
                              ..............               ........
                              ..............   HTTP Reply  ........
                              .............. <------------ ........
                                HTServHTTP
                               HTMIMEConvert
                          + the whole converter
                        stacking and type matching
                            stuff sitting here
   application/x-mheg-5       ..............
<---------------------------- ..............

With the library version 4.0D and following setup

HTProtocol_add("http", NO, HTLoadHTTP, HTServHTTP);
HTProtocol_add("file", NO, HTLoadFile, NULL);
HTProtocol_add("ftp", NO, HTLoadFTP, NULL);
HTProtocol_add("nntp", NO, HTLoadNews, NULL);
HTProtocol_add("news", NO, HTLoadNews, NULL);
HTProtocol_add("gopher", NO, HTLoadGopher, NULL);
conv = HTList_new();
HTConversion_add(conv,"text/x-http","*/*",HTTPStatus_new,1.0, 0.0, 0.0);
HTConversion_add(conv,"text/*","*/*", TextObject, 1.0,0.0,0.0);
HTConversion_add(conv,"image/*","*/*", ImageObject, 1.0,0.0,0.0);
HTConversion_add(conv,"message/x-rfc822-head","*/*",HTMIMEHeader,1.0,0.0,0.0);
HTConversion_add(conv,"message/rfc822","*/*",HTMIMEConvert,1.0,0.0,0.0);
HTConversion_add(conv,"text/html","*/*", HtmlObject, 1.0,0.0,0.0);

..and with a HTTP/1.0 request  "GET <some image URL>" I manage to get
a call to my "ImageObject" stream, which

	- successfully receives and buffers the image content

	- in the free "method" of the HTStream I actually convert the
	  image to the output format (x-mheg-5) and write the byte
	  stream to target stream.

The problem:

	- what do I have to do to get the output target (which now is
	  actually HTTPServ.c/HTTPReply) actually generate my new
	  reply headers, most importantly

		content-type: application/x-mheg-5

What happens now is that

	- HTTPServ/HTTPReply calls MakeReplyPipe, which finds out that
	  the client->net pointer exists, and goes into "Direct
	  output" mode without generating any headers! (Thus, my
	  binary MHEG-5 stream is returned to original client without
	  any header information).

Solution? Of course, knowing that this "Direct output" happens, I
could just write the headers myself to the target, before the actual
content, but

	- is this correct solution in respect to WWWLIB architecture?

	- will it always work this way (I would be hosed, if the
	  library in some cases would not go into "direct output")?

	- if not, how do I instruct the HTTPReply to generate the
	  headers I want? (If this is documented, just mail me the
	  appropriate WWW pointer :-)
--

Actually there is an other issue in the general picture: in my
converter proxy, I may get client request using HTTP/0.9 protocol, but
might always wish to forward the requests as HTTP/1.0. But, if such
"upgrade" happens, I still have to remember the original client
protocol and reply to client according to that. Any comments on this?
It already is taken care by the library? Or, I have to to something
special to support it?

--
Markku Savela (msa@hemuli.tte.vtt.fi),     Technical Research Centre of Finland
Multimedia Systems, P.O.Box 1203,FIN-02044 VTT,http://www.vtt.fi/tte/staff/msa/

Received on Thursday, 22 February 1996 04:42:14 UTC