[英]How To Read Stream From IdHTTP.Get
HTTP.Request.Connection:= 'Keep-Alive';
HTTP.Request.CacheControl:= 'no-cache';
HTTP.Request.ContentType:= 'application/x-www-form-urlencoded';
HTTP.Get('jpip://192.168.1.71:3312/cb.jp2?len=4000&type=jpp-stream&cnew=http&tid=0 HTTP/1.1', response);
我想讀取響應(我定義為TStream)。 但是我不知道idHttp.Get用法嗎?
我如何從服務器獲取響應(字節字節)。
您只需要在TIdHTTP.Get()
的第二個參數中提供流。 如果要保存到文件,請使用文件流:
var
Stream: TFileStream;
....
Stream := TFileStream.Create(FileName, fmCreate);
try
HTTP.Get(..., Stream);
finally
Stream.Free;
end;
或者,如果您想要這樣的內存流:
var
Stream: TMemoryStream;
....
Stream := TMemoryStream.Create;
try
HTTP.Get(..., Stream);
Stream.Position := 0; // seek to the beginning of the stream
// do something with the stream
finally
Stream.Free;
end;
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.