BorlandTalk.com Forum Index BorlandTalk.com
Borland discussion newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

HTTP buffer error
Goto page 1, 2  Next
 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi Internet Winsock
View previous topic :: View next topic  
Author Message
Paul
Guest





PostPosted: Thu Nov 18, 2004 9:02 pm    Post subject: HTTP buffer error Reply with quote



Hi all

I am tyring to download a stream with idHTTP.get(aurl,St),
but Í allways get a 'Buffer error'.
The stream size is approx 15k , the receivebuffer size is 32 k.
I am trying for 5 days now without success. (newbie)
Can anyone give me some hints/ examples?

I'm using indy 9 with D7.

TIA

Paul



Back to top
Remy Lebeau (TeamB)
Guest





PostPosted: Thu Nov 18, 2004 9:10 pm    Post subject: Re: HTTP buffer error Reply with quote




"Paul" <paul.blommaerts (AT) telenet (DOT) be> wrote


Quote:
I am tyring to download a stream with idHTTP.get(aurl,St),
but Í allways get a 'Buffer error'.

Please show your actual code, and please specific the full error message.


Gambit



Back to top
Paul
Guest





PostPosted: Thu Nov 18, 2004 9:39 pm    Post subject: Re: HTTP buffer error Reply with quote



Hi Gambit,

this is the code

connection part

HTTP1.Host:='localHost';
HTTP1.Request.Connection:='Keep-Alive';
HTTP1.Connect;

download picture

picStream:= TMemoryStream.Create;
try
HTTP1.Get(hUrl,picStream);
image1.Picture.Bitmap.LoadFromStream(picStream);
finally
FreeAndNil(picStream);
end;

Paul


Back to top
Remy Lebeau (TeamB)
Guest





PostPosted: Thu Nov 18, 2004 9:44 pm    Post subject: Re: HTTP buffer error Reply with quote

"Paul" <paul.blommaerts (AT) telenet (DOT) be> wrote


Quote:
HTTP1.Host:='localHost';
HTTP1.Request.Connection:='Keep-Alive';
HTTP1.Connect;

You are not supposed to be using Host or Connect() directly. Only use Get()
and Post(). The Host and Connect() are managed internally by Get() and
Post(), based on the URL specified.

Quote:
HTTP1.Get(hUrl,picStream);
image1.Picture.Bitmap.LoadFromStream(picStream);

You did not reset the stream's Position back to 0 after downloading.

HTTP1.Get(hUrl,picStream);
picStream->Position = 0; // <-- here
image1.Picture.Bitmap.LoadFromStream(picStream);

Also, what kind of images are you actually downloading? Are they BMP files?
If not, then your code won't work anyway, since the Bitmap property can only
load BMP data.


Gambit



Back to top
Paul
Guest





PostPosted: Thu Nov 18, 2004 9:55 pm    Post subject: Re: HTTP buffer error Reply with quote

I'm trying to keep the connection open.

Quote:

You are not supposed to be using Host or Connect() directly. Only use
Get()
and Post(). The Host and Connect() are managed internally by Get() and
Post(), based on the URL specified.

HTTP1.Get(hUrl,picStream);
picStream->Position = 0; // <-- here
image1.Picture.Bitmap.LoadFromStream(picStream);

You did not reset the stream's Position back to 0 after downloading.


I have tried this also, but I got the error this way too.

Quote:

Also, what kind of images are you actually downloading? Are they BMP
files?
If not, then your code won't work anyway, since the Bitmap property can
only
load BMP data.

Yes, it;s a bmp


Paul



Back to top
Paul
Guest





PostPosted: Thu Nov 18, 2004 10:44 pm    Post subject: Re: HTTP buffer error Reply with quote


Hi Gambit

The received stream size is 0, so the problem is maybe on the server side.
This instruction is used on the server side. The stream size here is approx.
15k

AResponseInfo.ContentStream:= picStream;

Paul





Back to top
Robby Tanner
Guest





PostPosted: Thu Nov 18, 2004 10:46 pm    Post subject: Re: HTTP buffer error Reply with quote


"Paul" <paul.blommaerts (AT) telenet (DOT) be> wrote

Quote:

I'm trying to keep the connection open.


You shouldn't. If you need to keep a connection open, use a different set
of components. HTTP is for atomic functions more or less.




Back to top
Remy Lebeau (TeamB)
Guest





PostPosted: Thu Nov 18, 2004 10:48 pm    Post subject: Re: HTTP buffer error Reply with quote


"Paul" <paul.blommaerts (AT) telenet (DOT) be> wrote


Quote:
I'm trying to keep the connection open.

I realize that. However, the HTTP server itself has to support that. HTTP
clients are not in control of whether the connection remains open. The
server is. The client can only request whether the connection *SHOULD* stay
open, but it is the server that makes the actual decision. If the server
agrees, then it keeps its end of the connection open, and sends a particular
header value in the Response to let the client know that it can keep its end
of the connection open as well. If the server refuses, however, then it
always closes its end of the connection after sending the response data, and
there is nothing the client can do about that, it must close its end of the
connection as well.

Quote:
I have tried this also, but I got the error this way too.

Which specific line is producing the error? What is the full error message?


Gambit



Back to top
Paul
Guest





PostPosted: Thu Nov 18, 2004 10:59 pm    Post subject: Re: HTTP buffer error Reply with quote

Hi Gambit

I will remove the connection part, it is set 'Keep-alive'on the server also.
However, sending/receiving strings works perfect this way.

I've just found that the received streamsize = 0 and the error is generated
further in the program.
It's not an Indy generated exception
The streamsize on the server side however is approx 15k just before it is
transmitted.
I don't have a sniffer, so I don't know if the stream was really
transmitted.
Maybe the problem is on the server side.

This instruction is used on the server side.

AResponseInfo.ContentStream:= picStream;

Should I send more params and if so, what are these params and how to use
them?

Paul





Back to top
Remy Lebeau (TeamB)
Guest





PostPosted: Fri Nov 19, 2004 12:40 am    Post subject: Re: HTTP buffer error Reply with quote


"Paul" <paul.blommaerts (AT) telenet (DOT) be> wrote


Quote:
The received stream size is 0, so the problem is maybe on the server side.
This instruction is used on the server side. The stream size here is
approx.
15k

AResponseInfo.ContentStream:= picStream;

You did not show how you are setting up picStream. Please show a more
complete code snippet.


Gambit



Back to top
Remy Lebeau (TeamB)
Guest





PostPosted: Fri Nov 19, 2004 12:41 am    Post subject: Re: HTTP buffer error Reply with quote


"Robby Tanner" <robby.tanner-remove-this-part (AT) lightsource (DOT) ca> wrote in
message news:419d2652 (AT) newsgroups (DOT) borland.com...

Quote:
If you need to keep a connection open, use a different set
of components. HTTP is for atomic functions more or less.

When making repeated requests to the same server, it makes sense to keep the
connection open. That is why the HTTP protocol does allow for KeepAlive
connections. They have to be negotiated, though.


Gambit



Back to top
Paul
Guest





PostPosted: Fri Nov 19, 2004 5:21 pm    Post subject: Re: HTTP buffer error Reply with quote

This is the code on the server side

try
picStream:= TMemoryStream.Create;
bmp:= TBitmap.Create;
GetPic(bmp);
bmp.SaveToStream(picStream);
picStream.Position:= 0;
AResponseInfo.ContentStream:= picStream;
finally
picStream.free;
bmp.free;
end;


"Remy Lebeau (TeamB)" <no.spam (AT) no (DOT) spam.com> schreef in bericht
news:419d40a6 (AT) newsgroups (DOT) borland.com...
Quote:

"Paul" <paul.blommaerts (AT) telenet (DOT) be> wrote in message
news:419d267c (AT) newsgroups (DOT) borland.com...

The received stream size is 0, so the problem is maybe on the server
side.
This instruction is used on the server side. The stream size here is
approx.
15k

AResponseInfo.ContentStream:= picStream;

You did not show how you are setting up picStream. Please show a more
complete code snippet.


Gambit





Back to top
Paul
Guest





PostPosted: Fri Nov 19, 2004 5:24 pm    Post subject: Re: HTTP buffer error Reply with quote

I dont have a clue how to negotiate this.
Where can I find an example of a negotiation between a idHTTPclient and
idHTTPserver?
It would help me a lot.

Paul


"Remy Lebeau (TeamB)" <no.spam (AT) no (DOT) spam.com> schreef in bericht
news:419d40d7 (AT) newsgroups (DOT) borland.com...
Quote:

"Robby Tanner" <robby.tanner-remove-this-part (AT) lightsource (DOT) ca> wrote in
message news:419d2652 (AT) newsgroups (DOT) borland.com...

If you need to keep a connection open, use a different set
of components. HTTP is for atomic functions more or less.

When making repeated requests to the same server, it makes sense to keep
the
connection open. That is why the HTTP protocol does allow for KeepAlive
connections. They have to be negotiated, though.


Gambit





Back to top
Remy Lebeau (TeamB)
Guest





PostPosted: Fri Nov 19, 2004 6:50 pm    Post subject: Re: HTTP buffer error Reply with quote

"Paul" <paul.blommaerts (AT) telenet (DOT) be> wrote


Quote:
AResponseInfo.ContentStream:= picStream;
finally
picStream.free;

You cannot free the stream that you assign to ContentStream. TIdHTTP
requires it to remain in memory after the OnCommandGet event handler returns
control back to TIdHTTP. Otherwise it won't have the stream available to
transmit its data back to the client. You need to change your code to take
out the call to picStream.free, ie:

picStream := nil;
try
picStream := TMemoryStream.Create;
bmp := TBitmap.Create;
try
GetPic(bmp);
bmp.SaveToStream(picStream);
picStream.Position := 0;
finally
bmp.free;
end;
AResponseInfo.ContentStream := picStream;
except
picStream.Free;
AResponseInfo.ContentStream := nil;
AResponseInfo.ResponseCode := 500;
AResponseInfo.ResponseText := 'Unable to Retreive Image. ' +
E.Message;
end;


Gambit




Back to top
Remy Lebeau (TeamB)
Guest





PostPosted: Fri Nov 19, 2004 6:51 pm    Post subject: Re: HTTP buffer error Reply with quote


"Paul" <paul.blommaerts (AT) telenet (DOT) be> wrote


Quote:
I dont have a clue how to negotiate this.

You are already doing it. All you have to do is set the Connection property
to 'Keep-Alive' and everything else is automatically handled by TIdHTTP
internally.


Gambit



Back to top
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi Internet Winsock All times are GMT
Goto page 1, 2  Next
Page 1 of 2

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.