INDY10的IDHttpServer应答客户端
INDY10的IDHttpServer应答客户端
首先贴源码:
procedure TIdHTTPResponseInfo.WriteContent;
begin
if not HeaderHasBeenWritten then begin
WriteHeader;
end; // RLebeau 11/23/2014: Per RFC 2616 Section 4.3:
//
// For response messages, whether or not a message-body is included with
// a message is dependent on both the request method and the response
// status code (section 6.1.1). All responses to the HEAD request method
// MUST NOT include a message-body, even though the presence of entity-
// header fields might lead one to believe they do. All 1xx
// (informational), 204 (no content), and 304 (not modified) responses
// MUST NOT include a message-body. All other responses do include a
// message-body, although it MAY be of zero length. if not (
(FRequestInfo.CommandType = hcHEAD) or
((ResponseNo div 100) = 1) or
(ResponseNo = 204) or
(ResponseNo = 304)
) then
begin
// Always check ContentText first
if ContentText <> '' then begin
FConnection.IOHandler.Write(ContentText, CharsetToEncoding(CharSet));
end
else if Assigned(ContentStream) then begin
ContentStream.Position := 0;
FConnection.IOHandler.Write(ContentStream);
end
else begin
FConnection.IOHandler.WriteLn('<HTML><BODY><B>' + IntToStr(ResponseNo) + ' ' + ResponseText {Do not Localize}
+ '</B></BODY></HTML>', CharsetToEncoding(CharSet)); {Do not Localize}
end;
end; // Clear All - This signifies that WriteConent has been called.
ContentText := ''; {Do not Localize}
ReleaseContentStream;
end;
一共可以应答客户端3种内容:
1)ContentText不为空字串,则发送字符串
2)ContentStream对象存在,则发送流
3)不是上面2种情况,则发送的是HTML。
最后会自动清空应答的字串或释放流,这也是为什么我们手动释放流反而会报“非法访问”错误:
ContentText := '';
ReleaseContentStream;
INDY10的IDHttpServer应答客户端的更多相关文章
- indy10的idhttpServer应答字符串
indy10的idhttpServer应答字符串 先看应答字符串的代码: procedure TIdIOHandler.Write(const AOut: string; AByteEncoding: ...
- indy10的idHttpServer发送流
indy10的idHttpServer发送流 先看源码: procedure TIdIOHandler.Write(AStream: TStream; ASize: TIdStreamSize = 0 ...
- 【Hadoop学习】中:HDFS、shell操作、客户端API操作、数据流、1NN、2NN原理、DataNode配置
一.概述 1.背景.定义.使用场景(一次写入.不支持修改) 2.优(容错)缺点(延迟.不支持小文件.不支持修改) 3.组成架构 NameNode:Master,管理命名空间.配置策略 DataNode ...
- redis.conf配置详细解析
# redis 配置文件示例 # 当你需要为某个配置项指定内存大小的时候,必须要带上单位, # 通常的格式就是 1k 5gb 4m 等酱紫: # # 1k => 1000 bytes # 1kb ...
- [个人翻译]Redis 集群教程(上)
官方原文地址:https://redis.io/topics/cluster-tutorial 水平有限,如果您在阅读过程中发现有翻译的不合理的地方,请留言,我会尽快修改,谢谢. 这是 ...
- HDFS 与 GFS 的设计差异
后端分布式系列」前面关于 HDFS 的一些文章介绍了它的整体架构和一些关键部件的设计实现要点. 我们知道 HDFS 最早是根据 GFS(Google File System)的论文概念模型来设计实现的 ...
- TCP协议
TCP是一个面向连接的协议,在发送数据之前,必须在双方之间建立一条连接. TCP首部 TCP数据封装在IP数据报中 TCP包首部 下面简单说明部分字段的作用: 端口号:通讯双方由IP地址和端口号标识. ...
- redis.conf配置详细翻译解析
# redis 配置文件示例 # 当你需要为某个配置项指定内存大小的时候,必须要带上单位, # 通常的格式就是 1k 5gb 4m 等酱紫: # # 1k => 1000 bytes # 1kb ...
- (转)Web性能优化方案
第一章 打开网站慢现状分析 在公司访问部署在IDC机房的VIP网站时会感觉很慢.是什么原因造成的?为了缩短页面的响应时间,改进我们的用户体验,我们需要知道用户的时间花在等待什么东西上. 可以跟踪一下我 ...
随机推荐
- Dhaka2011
Dhaka2011 A - Binary Matrix 题目描述:有一个\(n \times m\)的\(01\)矩阵,这一矩阵第一行和最后一行是相邻的,第一列和最后一列是相邻的,现在每次可以交换相邻 ...
- Shiro:授权控制
对容易忽略的地方记录如下: 1.需要引入下面2个依赖,具体版本根据自身环境修改: <dependency> <groupId>org.apache.geronimo.bundl ...
- 更改jupyter notebook的主题颜色(theme) 包括pycharm
https://blog.csdn.net/Techmonster/article/details/73382535
- 解决tomcat 启动 一闪而过
有的朋友在启动Tomcat的时候会出现问题. 1例如: 手动点击startup.bat 后 ,一闪而过 2例如:在cmd下 进到tomcat的bin目录 运行 startup.bat ,然后输出 了J ...
- 常用的 Windows 键
常用的 Windows 键 Windows 键 + 空格键 功能:透明化所有窗口,快速查看桌面.使用此快捷键可以立即将目前所有打开的窗口透明化,以便查看桌面. Windows 键 + 字母键“D” ...
- HBase0.99.2集群的搭建步骤(在hadoop2.6.4集群和zookeeper3.4.5集群上)
HBase介绍(NoSql,不是关系型数据库) HBase是一个高可靠性.高性能.面向列.可伸缩的分布式存储系统,利用HBASE技术可在廉价PC Server上搭建起大规模结构化存储集群. HBase ...
- CSS------如何让div中的div处于右下角
如图: 代码: <div style="width:300px;height:300px"> <div style="position:absolute ...
- Spark中hashshuffle与sortshuffle
在spark1.2以上的版本中,默认shuffle的方式已经变成了sortshuffle(在spark.shuffle.manager修改org.apache.spark.shuffle.sort.H ...
- Python中collections.defaultdict()使用
一个小示例 from collections import defaultdict import json def tree(): return defaultdict(tree) users = t ...
- 002.Git日常基础使用
一 获取git仓库 1.1 初始化仓库 [root@git ~]# cd /mystudy/ [root@git mystudy]# git init [root@git mystudy]# git ...