1. RE: cgi (correction)
- Posted by Cassidy Napoli <gonzotek at yahoo.com> Oct 11, 2001
- 378 views
Rolf, I disagree, respectfully. Please read this document: http://hoohoo.ncsa.uiuc.edu/cgi/out.html Essentially, there are three kinds of "Parsed headers": ---- Content-Type - The type of document you are returning -or- Location - Is a reference to another document. -or- Status - A status messagte, like 404 Forbidden. ---- You only need 1 of these. The browser wouldn't know what to do if you sent more than 1. If I were generating dynamic html on-the-fly, I would be using Content-Type: text/html. But I'm not even sending back text. I'm sending an image (I've changed it to gif, finally). So even if I had to use Content-Type, it would be Content-Type: image/gif. But then I would have to know how to send a binary file with puts(), and I don't think I'm up to that. Location: is essentially a redirection, a pointer to the file you want the browser to retrieve. -=Cassidy=- rolf.schroeder at desy.de wrote: > Correction, this must be the first output of the cgi based program: > > puts(1,"Content-Type: text/html\n\n") -- Essential for CGI execution! > > Sorry, and have a nice day, Rolf
2. RE: cgi (correction)
- Posted by Cassidy Napoli <gonzotek at yahoo.com> Oct 11, 2001
- 372 views
Yes, I'm doing something slightly different. Your solution returns a webpage containing an image, but what if the request from the client comes from an image tag, e.g. <img src="http://www.server.com/cgi-bin/image.exe">? My intention is to embed the tag into a messageboard signature or an existing website (say, for a radio station), that will always display what is currently playing in Winamp on the server. AND, I JUST GOT IT WORKING! I can't beleive this...It was the webserver I was using all the time. It doesn't handle win32 cgi very well. I switched to Xitami and everything fell into place. My program is now a bound dos executable consisting of this and only this: puts(1, "Location: http://209.66.18.179/IsPlaying.gif\n\n") My next step is to read the environment variable and have the program decide to return either isplaying.gif or wasplaying.gif, depending on the client's request. That's trivial. All this work is because, on the Winamp messageboards, some members used to have a neat little thing that did exactly what I'm trying to do (Put a graphic of whatever is playing in their sigs). But it was a centrally based php solution...all the clients connected to winampdb.com and passed their username/password/title and artist information through winamps minibrowser into a requesting URL. Then the server would generate the gif and send it out whenever needed. The server got so bogged down that they had to pull the program off. According to www.winampdb.com, they're bringing it back with a more decentralized solution, but I want something more flexible, so I decided to write my own version. I wish it were still running so I could show you exactly how it worked (because it was cool). But I guess now that I'm over this stumbling block, I'll be able to send the completed program pretty soon. Thanks for trying, Rolf. And thanks to everyone else one the list who replied, too. I was really getting frustrated, and at least you kept trying :). I really appreciate it. -=Cassidy=- rolf.schroeder at desy.de wrote: > Hi Cassidy, > > if you want to send back an image only to the Browser, just use only: > puts(1,"<head>\n") > puts(1,"<meta http-equiv=\"Content-Type\" " & > "content=\"text/html; charset=iso-8859-1\">") > puts(1,"<title>Test of CGI reply</title>\n") > puts(1,"</head>\n") > puts(1,"<body>\n") > -- puts(1,"CGI test OK!\n") -- No text output! > puts(1,"<img SRC=\"Pinguin.gif\" ALT=\"Dancing bird\" " & > "HSPACE=10 VSPACE=10 BORDER=0>\n") > > Have a nice day, Rolf