🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

Indy Http Server with chunked Post

#3147
From: Koen
Date: Mon, 07 Nov 2005 14:13
69 lines
2537 bytes
Hi,

I use Indy 9.0.18, and have a problem with the Indy HTTP Server 
(TidHTTPServer)

All the data that is send to the server, is send using the Post-method.
To specify the length of the data send, there are 2 methods:

1) Content-Length

this is working correctly

2) Transfer-Encoding: chunked

When I send data via chunked Transfer-Encoding, the server does not 
recognize this, and the server only fires the OnCommandGet when the 
client disconnects.


As a testapplication, I add a TidHTTPServer and a TMemo on the mainForm, 
Set the server to Active in the constructor, and as OnCommandEvent, I
add following code:

//---------------------------------------------------------------------
void __fastcall TForm1::IdHTTPServer1CommandGet(TIdPeerThread *AThread,
      TIdHTTPRequestInfo *RequestInfo, TIdHTTPResponseInfo *ResponseInfo)
{
Memo1->Lines->Add (RequestInfo->UnparsedParams);
ResponseInfo->ContentType = "application/text";
ResponseInfo->ContentText = RequestInfo->UnparsedParams;
}
//---------------------------------------------------------------------


when I send following data, everything works as expected:

// begin http-data
POST /path/script.cgi HTTP/1.1
From: the@email.com
User-Agent: HTTPTool/1.1
Content-Length: 6
Content-Type: text/plain

a test
// end HTTP-data

when I send chunked data however, the OnCommandGet event is only 
triggered when the client disconnects, and not when all data is sent.
Off course, I cannot send a respons then:

// begin HTTP-data
POST /path/script.cgi HTTP/1.1
From: the@email.com
User-Agent: HTTPTool/1.1
Content-Type: text/plain
Transfer-Encoding: chunked

6
a test
0

// end HTTP-data


What should I do to handle chunked messages correctly?

regards,

Koen
Technical Details
Message-ID: <Xns9707A4DC782A1noemailcom@207.105.83.66>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news3.google.com!news.glorb.com!mpls-transit-01.news.qwest.net!38.119.100.82.MISMATCH!news-out.newsgroups.com!propagator2-sterling.newsfeeds.com!in.nntp.be!caladan.landsraad.net!newsgroups.borland.com!not-for-mail

Show Full Headers
Complete Article Headers
X-Google-Thread: 11508e,c64dd348982b9e0b,start
X-Google-Attributes: gid11508e,public
X-Google-Language: ENGLISH,ASCII-7-bit
Newsgroups: borland.public.cppbuilder.internet.socket
Subject: Indy Http Server with chunked Post
From: Koen <no@email.com>
Message-ID: <Xns9707A4DC782A1noemailcom@207.105.83.66>
User-Agent: Xnews/5.04.25
NNTP-Posting-Host: 80.11.198.111
Date: 7 Nov 2005 07:13:12 -0700
X-Trace: newsgroups.borland.com 1131376392 80.11.198.111 (7 Nov 2005 07:13:12 -0700)
Lines: 69
Path: arc1-ca.pugleaf.net!g2news1.google.com!news3.google.com!news.glorb.com!mpls-transit-01.news.qwest.net!38.119.100.82.MISMATCH!news-out.newsgroups.com!propagator2-sterling.newsfeeds.com!in.nntp.be!caladan.landsraad.net!newsgroups.borland.com!not-for-mail