indy10的idHttpServer发送流

先看源码:

procedure TIdIOHandler.Write(AStream: TStream; ASize: TIdStreamSize = 0;
AWriteByteCount: Boolean = FALSE);
var
LBuffer: TIdBytes;
LStreamPos: TIdStreamSize;
LBufSize: Integer;
// LBufferingStarted: Boolean;
begin
if ASize < 0 then begin //"-1" All from current position
LStreamPos := AStream.Position;
ASize := AStream.Size - LStreamPos; AStream.Position := LStreamPos;
end
else if ASize = 0 then begin //"0" ALL
ASize := AStream.Size;
AStream.Position := 0;
end;
//else ">0" number of bytes // RLebeau 3/19/2006: DO NOT ENABLE WRITE BUFFERING IN THIS METHOD!
//
// When sending large streams, especially with LargeStream enabled,
// this can easily cause "Out of Memory" errors. It is the caller's
// responsibility to enable/disable write buffering as needed before
// calling one of the Write() methods.
//
// Also, forcing write buffering in this method is having major
// impacts on TIdFTP, TIdFTPServer, and TIdHTTPServer. if AWriteByteCount then begin
if LargeStream then begin
Write(Int64(ASize));
end else begin
{$IFDEF STREAM_SIZE_64}
if ASize > High(Integer) then begin
raise EIdIOHandlerRequiresLargeStream.Create(RSRequiresLargeStream);
end;
{$ENDIF}
Write(Int32(ASize));
end;
end; BeginWork(wmWrite, ASize);
try
SetLength(LBuffer, FSendBufferSize);
while ASize > 0 do begin
LBufSize := IndyMin(ASize, Length(LBuffer));
// Do not use ReadBuffer. Some source streams are real time and will not
// return as much data as we request. Kind of like recv()
// NOTE: We use .Size - size must be supported even if real time
LBufSize := TIdStreamHelper.ReadBytes(AStream, LBuffer, LBufSize);
if LBufSize <= 0 then begin
raise EIdNoDataToRead.Create(RSIdNoDataToRead);
end;
Write(LBuffer, LBufSize);
// RLebeau: DoWork() is called in WriteDirect()
//DoWork(wmWrite, LBufSize);
Dec(ASize, LBufSize);
end;
finally
EndWork(wmWrite);
LBuffer := nil;
end;
end;

  

const
GRecvBufferSizeDefault = 32 * 1024;
GSendBufferSizeDefault = 32 * 1024;

  如果流数据大于32K,会分成多包发送,每包最大32K。

indy10的idHttpServer发送流的更多相关文章

  1. INDY10的IDHttpServer应答客户端

    INDY10的IDHttpServer应答客户端 首先贴源码: procedure TIdHTTPResponseInfo.WriteContent; begin if not HeaderHasBe ...

  2. indy10的idhttpServer应答字符串

    indy10的idhttpServer应答字符串 先看应答字符串的代码: procedure TIdIOHandler.Write(const AOut: string; AByteEncoding: ...

  3. NC凭证接口(Java发送流和处理返回结果)

    问题描述: 金融行业在系统模块分为财务和业务两个系统,我公司是负责业务模块系统,NC公司负责财务系统.但是财务有时候需要生成凭证,这时候就涉及业务模块了,我方就需要写NC凭证接口.这时候就需要三方交互 ...

  4. php发送 与接收流文件

    PHP 发送与接收流文件 sendStreamFile.php 把文件以流的形式发送 receiveStreamFile.php 接收流文件并保存到本地 sendStreamFile.php < ...

  5. java 模拟http请求,通过流(stream)的方式,发送json数据和文件

    发送端: /** * 以流的方式 * 发送文件和json对象 * * @return */ public static String doPostFileStreamAndJsonObj(String ...

  6. RENIX 软件RAW流发送——网络测试仪实操

    本文主要介绍了RENIX软件如何进行RAW流发送操作.文章通过预约端口.添加RAW流.修改负载.发送流量.查看流统计.数据包捕获六个步骤详细介绍了操作过程. 步骤一:预约端口.1.先安装RENIX软件 ...

  7. C#开源实现MJPEG流传输

    本文为 Dennis Gao 原创技术文章,发表于博客园博客,未经作者本人允许禁止任何形式的转载. 许久以前写了篇文章<基于.NET打造IP智能网络视频监控系统>,记录和介绍了自己几年来积 ...

  8. RTSP RTSP(Real Time Streaming Protocol),RFC2326,实时流传输协议,是TCP/IP协议体系中的一个应用层协议

    RTSP 编辑 RTSP(Real Time Streaming Protocol),RFC2326,实时流传输协议,是TCP/IP协议体系中的一个应用层协议,由哥伦比亚大学.网景和RealNetwo ...

  9. storm 随机发送字符串

    Storm的程序叫做Topology,类似MapReduce job 一个Topolog应该有Spout,代表数据源,和若干个bolt 首先写一个Spout public class RandomSp ...

随机推荐

  1. JVM指令详解(上)

    指令码    助记符                            说明 0x00         nop                                什么都不做 0x01  ...

  2. java 异常使用指南

    应该在以下情况使用异常: 1.)在恰当的级别处理问题.(在知道如何处理的情况下才捕获异常) 2.)解决问题并且重新调用异常的方法 3.)进行少许的修补,然后绕过异常发生的地方继续执行 4.)用别的数据 ...

  3. 有没有 linux 命令可以获取我的公网 ip, 类似 ip138.com 上获取的 ip?

    curl ipinfo.iocurl ifconfig.me 阿里云 :139.129.242.131赤峰:   219.159.38.197开平:   221.194.113.146定州:  121 ...

  4. Connect to DB2 database in eclipse via jdbc

    https://stackoverflow.com/questions/23801841/connect-to-db2-database-in-eclipse-via-jdbc

  5. day10--协成\异步IO\缓存

       协成(Gevent) 协程,又称微线程,纤程.英文名Coroutine.一句话说明什么是线程:协程是一种用户态的轻量级线程.CPU只认识线程. 协程拥有自己的寄存器上下文和栈.协程调度切换时,将 ...

  6. 家庭房产L2-007

    较为麻烦的并查集 主要是我的模板是错的检查了好久.... 先是输入 把每个家庭连在一起 输出的家庭编号为该家庭所有编号的最小值  在并查集里面完成 第一次 0~n-1遍历储存好 家庭编号 和房子面积和 ...

  7. SpringBoot的Controller使用

    一: 1.注解 2.control注解 3.效果 4.RespomseBody package com.caojun.springboot; import org.springframework.be ...

  8. vue在生产环境清除console.log

    在开发环境中我们喜欢用console.log测试代码,但是部署到生产环境我们不可能一个一个把console.log给手动删除了. 在build/webpack.prod.conf.js文件里加上这样一 ...

  9. scrollIntoView将指定元素定位到浏览器顶部,底部,中间

    var element = document.getElementById("box"); element.scrollIntoView();//顶部 element.scroll ...

  10. CSS选择器优先级(转)

    原文:http://www.cnblogs.com/wangfupeng1988/p/4285251.html 另外,w3c有文章介绍了CSS选择器的特定性,见https://www.w3.org/T ...