I would like to create a custom header to send back to a client
request. I have a web server created using the Indy HTTP Server
component (TIdHTTPServer). If you create an OnCommandGet event then there is a ResponseInfo command with parameters you can set
that will then get sent to the client. There is a CustomHeaders
option but it's a TIdHeaderList type and how would I set text for
it? When I try it obviously gives me a can not convert char to
TIdHeaderList. Can anyone help?
Thanks in advance.
Andy
Gambit
"Andy" <ju...@guessagain.net> wrote in message news:3c9a4497$2_1@dnews...
That worked perfect, thank you!
Now this question is more for HTML probably but since you knew the last
question I thought maybe
you would know this to. I am setting the custom header to return "HTTP/1.0
200 OK". I was told
if I send this and do not send a ContentLength, then the client would not
know when the page was
done loading and would keep the connection open to the web server. This
would allow me to keep
pushing down data from the server as I need to. So I tried this but the
client keeps loading the web
page and stopping like normal. Do you know what I might be doing wrong (or
anyone)? Thanks again.
Andy
"Remy Lebeau [TeamB]" <gamb...@yahoo.com> wrote in message
news:3c9a4943$1_2@dnews...
If all you want to do is keep the connection open, you can simply make sure
the AResponseInfo->CloseConnection property is false. It's already false by
default (based on the HTTPServer's KeepAlive property).
Gambit
"Junk" <ju...@guessagain.net> wrote in message news:3c9a8687_1@dnews...
"Remy Lebeau [TeamB]" <gamb...@yahoo.com> wrote in message
news:3c9a8c6f$1_1@dnews...
(untested) In your case, as soon as OnCommandGet exits, the connection will
probably close. So what you can try doing is enter a loop that repeatedly
sets the AResponseInfo->ContentText property (not ContentStream, as it gets
automatically freed every time) and then call it's WriteContent() method
until your'e done. Drop a TIdAntiFreeze component onto the form (or call
Application->ProcessMessages()) so your program remains responsive.
Gambit
"Junk" <ju...@guessagain.net> wrote in message news:3c9ae4ee$1_1@dnews...
Thank you again, that does keep the page open but it's not
quite the same as what the chat page does. Let me paste a
conversation between myself and Simon Kissel (the one who
created the chatjet program that's used on Borland's chat
page)...
andy: I love the way your chatjet program works and from what I understand it was created using Delphi? Is that right?
SimonK: Yes
SimonK: And the linux version is done with kylix
andy: Ok. Yeah, I understand that´s what Borland is using.
andy: Now, I use C++ Builder and here is what I´m trying to do....
andy: Create a web page that will update multiple clients (web browsers) connected with live changing data...
andy: Now your chat program looks like it keeps an open port to the client and the client looks like it´s constantly loading the page thus constantly grabbing new data the server puts out, is this how it works?
SimonK: yes
SimonK: the connection is never closed...
SimonK: there are a few tweaks so that it also works with proxys,
SimonK: but yes, that´s the basic idea.
SimonK: open a http connection and never close it...
SimonK: and make the streaming frame update all other frames.
andy: Now obviously you can´t give me your source code ;) but is there anyway you can give me an example of how this works. Would I have to use C++ to do this or do you have HTML or Javascript or something that would give me a clue as to how this works?
SimonK: Well
andy: My main thing is how do you keep the streaming frame connected and constantly pulling data?
SimonK: it´s not pulling
SimonK: the server is pushing
andy: Server is pushing?
SimonK: it´s very easy
SimonK: open a server socket,
SimonK: write out HTTP/1.0 200 OK
SimonK: and all additional headers you want,
SimonK: but DON´T set a Content-Length Header
SimonK: this way the browser doesn´t know when loading of file has finished
SimonK: so instead it will load until server closes connection.
SimonK: then just write out all the data you want.
SimonK: if you need longer pauses, you´ll have to send some filler stuff,
SimonK: so the connection doesn´t time out.
Now how would I implement the way Simon does it? Thanks again.
Andy
void __fastcall TIdHTTPServer1CommandGet(TIdPeerThread *AThread,
TIdHTTPRequestInfo *ARequestInfo, TIdHTTPResponseInfo *AResponseInfo)
{
// ... process the request as needed first
AThread->Connection->WriteLn("HTTP/1.0 200 OK");
// Write your own headers directly
AThread->Connection->WriteLn("Content-Type: TheContentType");
// etc...
AResponseInfo->HeaderHasBeenWritten = true;
while(doSomething)
{
AResponseInfo->ContentText = "new text";
AResponseInfo->WriteContent();
}
}
Gambit
"Andy" <ju...@guessagain.net> wrote in message news:3c9b7bf2$1_2@dnews...