indy10的idHttpServer发送流
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发送流的更多相关文章
- INDY10的IDHttpServer应答客户端
INDY10的IDHttpServer应答客户端 首先贴源码: procedure TIdHTTPResponseInfo.WriteContent; begin if not HeaderHasBe ...
- indy10的idhttpServer应答字符串
indy10的idhttpServer应答字符串 先看应答字符串的代码: procedure TIdIOHandler.Write(const AOut: string; AByteEncoding: ...
- NC凭证接口(Java发送流和处理返回结果)
问题描述: 金融行业在系统模块分为财务和业务两个系统,我公司是负责业务模块系统,NC公司负责财务系统.但是财务有时候需要生成凭证,这时候就涉及业务模块了,我方就需要写NC凭证接口.这时候就需要三方交互 ...
- php发送 与接收流文件
PHP 发送与接收流文件 sendStreamFile.php 把文件以流的形式发送 receiveStreamFile.php 接收流文件并保存到本地 sendStreamFile.php < ...
- java 模拟http请求,通过流(stream)的方式,发送json数据和文件
发送端: /** * 以流的方式 * 发送文件和json对象 * * @return */ public static String doPostFileStreamAndJsonObj(String ...
- RENIX 软件RAW流发送——网络测试仪实操
本文主要介绍了RENIX软件如何进行RAW流发送操作.文章通过预约端口.添加RAW流.修改负载.发送流量.查看流统计.数据包捕获六个步骤详细介绍了操作过程. 步骤一:预约端口.1.先安装RENIX软件 ...
- C#开源实现MJPEG流传输
本文为 Dennis Gao 原创技术文章,发表于博客园博客,未经作者本人允许禁止任何形式的转载. 许久以前写了篇文章<基于.NET打造IP智能网络视频监控系统>,记录和介绍了自己几年来积 ...
- RTSP RTSP(Real Time Streaming Protocol),RFC2326,实时流传输协议,是TCP/IP协议体系中的一个应用层协议
RTSP 编辑 RTSP(Real Time Streaming Protocol),RFC2326,实时流传输协议,是TCP/IP协议体系中的一个应用层协议,由哥伦比亚大学.网景和RealNetwo ...
- storm 随机发送字符串
Storm的程序叫做Topology,类似MapReduce job 一个Topolog应该有Spout,代表数据源,和若干个bolt 首先写一个Spout public class RandomSp ...
随机推荐
- 06 Go 1.6 Release Notes
Go 1.6 Release Notes Introduction to Go 1.6 Changes to the language Ports Tools Cgo Compiler Toolcha ...
- (原创)关于viewpager嵌套listview居中显示的问题
今天折腾了半天自定义控件的问题,如下图所示,我们UI设计了一种可以左右滑动的列表,而列表中又包含了listview.而且要居中显示listview 我一看UI,心想简单,不就是根据datas的数目进行 ...
- 浅谈js设计模式 — 享元模式
享元(flyweight)模式是一种用于性能优化的模式,“fly”在这里是苍蝇的意思,意为蝇量级.享元模式的核心是运用共享技术来有效支持大量细粒度的对象. 假设有个内衣工厂,目前的产品有 50种男式内 ...
- Java编程的逻辑 (55) - 容器类总结
本系列文章经补充和完善,已修订整理成书<Java编程的逻辑>,由机械工业出版社华章分社出版,于2018年1月上市热销,读者好评如潮!各大网店和书店有售,欢迎购买,京东自营链接:http:/ ...
- springcloud hystrix 部分参数整理
hystrix.command.default和hystrix.threadpool.default中的default为默认CommandKey Command Properties Executio ...
- word2vec中的数学原理一 目录和前言
最近在看词向量了,因为这个概念对于语言模型,nlp都比较重要,要好好的学习一下.把网上的一些资料整合一下,搞个系列. 主要参考: word2vec 中的数学原理详解 ...
- vue-cli的工程模板与构建工具
vue-cli的工程模板与构建工具 https://www.cnblogs.com/yinn/p/9712480.html 脚手架vue-cli系列二:vue-cli的工程模板与构建工具 上篇文章我们 ...
- selenium自动测试
import requestsimport sysimport iofrom selenium import webdriverfrom selenium.webdriver.common.actio ...
- sqlite读写
#coding=utf-8 import sqlite3 import os #创建数据库和游标 if os.path.exists(' test.db'): conn=sqlite3.connect ...
- 高能天气——团队Scrum冲刺阶段-Day 7 总结
高能天气--团队Scrum冲刺阶段-Day 7 总结 今日完成任务 于欣月:修改项目说明书,帮助修改应用 余坤澎:进行应用整合的收尾工作 康皓越:进行应用整合的收尾工作 范雯琪:修改项目说明书,完成项 ...