Article View: borland.public.cppbuilder.internet.socket
Article #1093Re: TIdHTTPClient read blocking when keep-alive is enabled
From: emerson.pardo
Date: Mon, 07 May 2007 16:09
Date: Mon, 07 May 2007 16:09
48 lines
2590 bytes
2590 bytes
Solved.
Here the solution (simplified) I've coded:
...
IdHTTP -> ProtocolVersion << pv1_1;
IdHTTP -> Request -> Connection = "keep-alive";
IdHTTP -> Request -> ProxyConnection = "keep-alive";
IdHTTP -> Response -> KeepAlive = true;
// next lines replace IdHTTP -> Get("http://localhost:81")
IdHTTP -> Host = "localhost";
IdHTTP -> Port = 81;
IdHTTP -> Connect(100);
IdHTTP -> Write("GET / \n\n");
AnsiString line = IdHTTP -> ReadLn("\n", 100, 500);
while(IdHTTP -> Connected())
{
if(line . Length() > 0)
{
// process line
}
::Sleep(100);
line = IdHTTP -> ReadLn("\n", 100, 500);
}
...
[]s
On 3 maio, 15:55, emerson.pa...@gmail.com wrote:
> Hi all,
>
> I'm trying to create a client with keep-alive enabled but when I do
> the request the app blocks. Here the code snippet (IdHTTP is a
> TIdHTTPClient*):
>
> ...
> IdHTTP -> ProtocolVersion << pv1_1;
> IdHTTP -> Request -> Connection = "keep-alive";
> IdHTTP -> Request -> ProxyConnection = "keep-alive";
> IdHTTP -> Response -> KeepAlive = true;
> AnsiString response = IdHTTP -> Get("http://localhost:81"); //
> it blocks here
> ...
>
> I've already tried with Post and with DoRequest. Both blocks too.
>
> What am I doing wrong?
>
> Thanks in advance!
Technical Details
Message-ID:
<1178554180.638229.240770@e65g2000hsc.googlegroups.com>Path:
arc1-ca.pugleaf.net!g2news1.google.com!postnews.google.com!e65g2000hsc.googlegroups.com!not-for-mailReferences:
<1178218514.079295.14020@q75g2000hsh.googlegroups.com>Show Full Headers
Complete Article Headers
X-Google-Thread: 11508e,cb0a8671aaf0de86 X-Google-Attributes: gid11508e,public X-Google-Language: ENGLISH,ASCII-7-bit Path: arc1-ca.pugleaf.net!g2news1.google.com!postnews.google.com!e65g2000hsc.googlegroups.com!not-for-mail From: emerson.pardo@gmail.com Newsgroups: borland.public.cppbuilder.internet.socket Subject: Re: TIdHTTPClient read blocking when keep-alive is enabled Date: 7 May 2007 09:09:40 -0700 Organization: http://groups.google.com Lines: 50 Message-ID: <1178554180.638229.240770@e65g2000hsc.googlegroups.com> References: <1178218514.079295.14020@q75g2000hsh.googlegroups.com> NNTP-Posting-Host: 201.20.201.226 Mime-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" X-Trace: posting.google.com 1178554180 6317 127.0.0.1 (7 May 2007 16:09:40 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Mon, 7 May 2007 16:09:40 +0000 (UTC) In-Reply-To: <1178218514.079295.14020@q75g2000hsh.googlegroups.com> User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.8.1.3) Gecko/20070309 Firefox/2.0.0.3,gzip(gfe),gzip(gfe) Complaints-To: groups-abuse@google.com Injection-Info: e65g2000hsc.googlegroups.com; posting-host=201.20.201.226; posting-account=QvXz7Q0AAABpEoGXcn0fFVJYSsupcqGQ