🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.cppbuilder.internet.socket
Article #199

TIdHTTPResponseInfo WriteContent (or not)

#199
From: WimB
Date: Thu, 10 Jul 2008 10:20
37 lines
2073 bytes
Hi, I've created a webserver that servers pages and binaries etc. All
works well, but I'm confused about the usage of WriteContent. Do I
need to call this, or is it automatically called? It seems that
without, the responses are also correct. Without diving into Indy10
myself, maybe anyone can shed some light on it?

Thanks in advance, WimB.

example, in serverCommandGet:

  TMemoryStream* MemoryStream = new TMemoryStream();
  MemoryStream->LoadFromFile(....->LocalDoc);

  HttpRequest->ResponseInfo->FreeContentStream = true;
  HttpRequest->ResponseInfo->ResponseNo        = 200;
  HttpRequest->ResponseInfo->ContentType       = ContentType;
  HttpRequest->ResponseInfo->ContentLength     = (int)MemoryStream-
>Size;

  HttpRequest->ResponseInfo->ContentStream     = MemoryStream;
  HttpRequest->ResponseInfo->WriteContent;

works fine, and:

  TStringList* StringList = new TStringList();
  StringList->LoadFromFile(HttpRequest->LocalDoc);
  HttpRequest->Content = StringList->Text;
  delete StringList;

  AnsiString ContentText = ReplaceTags(HttpRequest);
  HttpRequest->ResponseInfo->ResponseNo    = 200;
  HttpRequest->ResponseInfo->ContentType   = ContentType;
  HttpRequest->ResponseInfo->ContentText   = ContentText;
  HttpRequest->ResponseInfo->ContentLength = ContentText.Length();

also works fine. 
Technical Details
Message-ID: <4875e25d$1@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news3.google.com!feeder.news-service.com!news.isoc.lu!newsgroups.borland.com!not-for-mail

Show Full Headers
Complete Article Headers
X-Google-Thread: 11508e,849e342dec50f01,start
X-Google-Attributes: gid11508e,domainid0,public,usenet
X-Google-Language: ENGLISH,ASCII-7-bit
From: "WimB" <wim....@.....nl>
Sender: "WimB" <wim....@.....nl>
Reply-To: "WimB" <wim....@.....nl>
Subject: TIdHTTPResponseInfo WriteContent (or not)  
Newsgroups: borland.public.cppbuilder.internet.socket
X-User-Info: 217.166.1.250     
NNTP-Posting-Host: 207.105.83.66
Message-ID: <4875e25d$1@newsgroups.borland.com>
Date: 10 Jul 2008 03:20:13 -0700
X-Trace: newsgroups.borland.com 1215685213 207.105.83.66 (10 Jul 2008 03:20:13 -0700)
Lines: 37
Path: arc1-ca.pugleaf.net!g2news1.google.com!news3.google.com!feeder.news-service.com!news.isoc.lu!newsgroups.borland.com!not-for-mail