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网站时会感觉很慢.是什么原因造成的?为了缩短页面的响应时间,改进我们的用户体验,我们需要知道用户的时间花在等待什么东西上. 可以跟踪一下我 ...
随机推荐
- MySQL安装与初步操作
MySQL是一款出色的中小型关系数据库,做Java Web开发时,要做到数据持久化存储,选择一款数据库软件自然必不可少. 由于MySQL社区版开元免费,功能比较强大,在此以MySQL为例,演示MySQ ...
- java.util.concurrent.RejectedExecutionException
java.util.concurrent.RejectedExecutionException: Task java.util.concurrent.FutureTask@59f1ca76 rejec ...
- Android 6.0 API
Android 6.0 (M) 为用户和应用开发者提供了新功能.本文旨在介绍其中最值得关注的 API. 着手开发 要着手开发 Android 6.0 应用,您必须先获得 Android SDK,然后使 ...
- 使用html+css+js实现弹球游戏
使用html+css+js实现弹球游戏 效果图: 代码如下,复制即可使用: <!doctype html> <head> <style type="text/c ...
- hdu 1856 求集合里元素的个数 输出最大的个数是多少
求集合里元素的个数 输出最大的个数是多少 Sample Input41 23 45 61 641 23 45 67 8 Sample Output42 # include <iostream&g ...
- Jupyter Notebook 入门
参考 Jupyter Notebook 快速入门 进阶 可看: Jupyter Notebook 的 27 个窍门,技巧和快捷键 Jupyter Notebook(此前被称为 IPython ...
- vue1.0到2.0
vue1.0到2.0 vue2.0 新手教程(一) 想想自己写vue的项目也写了一年了,从vue1.0到2.0,走过不少路,填过不少坑, 下面记录一下新手从0到1的过程,本文“应该”会持续更新 首 ...
- thinkphp中order方法
order方法属于模型的连贯操作方法之一,用于对操作的结果排序. 用法 $Model->where('status=1')->order('id desc')->limit(5)-& ...
- Java NIO-3
http://itindex.net/detail/55603-java-nio-%E6%8A%80%E6%9C%AF
- 51nod 1584加权约数和
学到了好多东西啊这题... https://blog.csdn.net/sdfzyhx/article/details/72968468 #include<bits/stdc++.h> u ...