ics httpDELETE 时增加 content,length 特别需求
unit: OverbyteIcsHttpProt.pas
procedure THttpCli.SendRequest(const Method, Version: String);
var
Headers : TStrings;
N : Integer;
begin
{$IFDEF UseBandwidthControl}
FBandwidthCount := ; // Reset byte counter
if httpoBandwidthControl in FOptions then begin
if not Assigned(FBandwidthTimer) then
FBandwidthTimer := TIcsTimer.Create(Self);
FBandwidthTimer.Enabled := FALSE;
FBandwidthTimer.Interval := FBandwidthSampling;
FBandwidthTimer.OnTimer := BandwidthTimerTimer;
FBandwidthTimer.Enabled := TRUE;
// Number of bytes we allow during a sampling period
FBandwidthMaxCount := Int64(FBandwidthLimit) * FBandwidthSampling div ;
FBandwidthPaused := FALSE;
FCtrlSocket.ComponentOptions := FCtrlSocket.ComponentOptions + [wsoNoReceiveLoop];
end;
{$ENDIF}
Headers := TStringList.Create;
try
FReqStream.Clear;
TriggerRequestHeaderBegin;
{* OutputDebugString(method + ' ' + FPath + ' HTTP/' + Version); *}
if Method = 'CONNECT' then
Headers.Add(Method + ' ' + FTargetHost + ':' + FTargetPort +
' HTTP/' + Version)
else begin
Headers.Add(method + ' ' + FPath + ' HTTP/' + Version);
if FSender <> '' then
Headers.Add('From: ' + FSender);
if FAccept <> '' then
Headers.Add('Accept: ' + FAccept);
if FReference <> '' then
Headers.Add('Referer: ' + FReference);
if FCurrConnection <> '' then
Headers.Add('Connection: ' + FCurrConnection);
if FAcceptLanguage <> '' then
Headers.Add('Accept-Language: ' + FAcceptLanguage);
{$IFDEF UseContentCoding}
if (FContentCodingHnd.HeaderText <> '') and (FRequestType <> httpHEAD) then
Headers.Add('Accept-Encoding: ' + FContentCodingHnd.HeaderText);
{$ENDIF}
if (FRequestType in [httpPOST, httpPUT, httpPATCH]) and { V8.06 }
(FContentPost <> '') then
Headers.Add('Content-Type: ' + FContentPost);
{if ((method = 'PUT') or (method = 'POST')) and (FContentPost <> '') then
Headers.Add('Content-Type: ' + FContentPost);}
end;
if FAgent <> '' then
Headers.Add('User-Agent: ' + FAgent);
if (FTargetPort = '') or (FTargetPort = '') or (FTargetPort = '') then { V8.05 }
Headers.Add('Host: ' + FTargetHost)
else
Headers.Add('Host: ' + FTargetHost + ':' + FTargetPort);
if FNoCache then
Headers.Add('Pragma: no-cache');
if FCurrProxyConnection <> '' then
Headers.Add('Proxy-Connection: ' + FCurrProxyConnection);
if (Method = 'CONNECT') then // <= 12/29/05 AG
Headers.Add('Content-Length: 0') // <= 12/29/05 AG}
else begin { V7.05 begin }
if FRequestType in [httpPOST, httpPUT, httpPATCH] then begin { V8.06 }
{$IFDEF UseNTLMAuthentication}
if (FAuthNTLMState = ntlmMsg1) or
(FProxyAuthNTLMState = ntlmMsg1) then
Headers.Add('Content-Length: 0')
else
{$ENDIF}
Headers.Add('Content-Length: ' +
IntToStr(SendStream.Size - SendStream.Position));
end
{gavin.chen 2014.05.07 ++++++ 加了对于 delete 参数的,content length}
else if (FRequestType = httpDELETE) AND (Assigned(SendStream)) then
begin
Headers.Add('Content-Length: ' +
IntToStr(SendStream.Size - SendStream.Position));
end;
{+++++++++++++++++++++}
end; { V7.05 end }
{ if (method = 'PUT') or (method = 'POST') then
Headers.Add('Content-Length: ' + IntToStr(SendStream.Size));}
if FModifiedSince <> then
Headers.Add('If-Modified-Since: ' +
RFC1123_Date(FModifiedSince) + ' GMT'); if not FProxyConnected then begin
{ We did not call SetReady while in relocation, adjust }
{ ProxyAuthNtlmState if we got disconnected from proxy }
{$IFDEF UseNTLMAuthentication}
if FProxyAuthNtlmState = ntlmDone then
FProxyAuthNtlmState := ntlmMsg1;
{$ENDIF}
end; {$IFDEF UseNTLMAuthentication}
if (FProxyAuthNTLMState <> ntlmMsg1) then begin
if (FAuthNTLMState = ntlmMsg1) then
Headers.Add(GetNTLMMessage1(FALSE))
else if (FAuthNTLMState = ntlmMsg3) then
Headers.Add(GetNTLMMessage3(Method, FALSE))
{$IFDEF UseDigestAuthentication}
else if (FAuthDigestState = digestMsg1) then
Headers.Add(GetDigestAuthorizationHeader(Method, FALSE))
{$ENDIF}
else if (FAuthBasicState = basicMsg1) then
Headers.Add(GetBasicAuthorizationHeader(Method, FALSE))
else begin
// Maybe an event to add a preemptive Authorization header?
end;
end;
{$ELSE}
{$IFDEF UseDigestAuthentication}
if (FAuthDigestState = digestMsg1) then
Headers.Add(GetDigestAuthorizationHeader(Method, FALSE))
else
{$ENDIF}
if (FAuthBasicState = basicMsg1) then
Headers.Add(GetBasicAuthorizationHeader(Method, FALSE))
else begin
// Maybe an event to add a preemptive Authorization header?
end;
{$ENDIF}
{$IFDEF UseNTLMAuthentication}
if (FProxyAuthNTLMState = ntlmMsg1) then
Headers.Add(GetNTLMMessage1(TRUE))
else if (FProxyAuthNTLMState = ntlmMsg3) then
Headers.Add(GetNTLMMessage3(Method, TRUE))
else
{$ENDIF}
{$IFDEF UseDigestAuthentication}
if (FProxyAuthDigestState = digestMsg1) then
Headers.Add(GetDigestAuthorizationHeader(Method, TRUE))
else
{$ENDIF}
if (FProxyAuthBasicState = basicMsg1) then
Headers.Add(GetBasicAuthorizationHeader(Method, TRUE))
else if Length(FProxy) > then begin
// Maybe an event to add a preemptive Authorization header?
end; if FCookie <> '' then
Headers.Add('Cookie: ' + FCookie);
if (FContentRangeBegin <> '') or (FContentRangeEnd <> '') then begin {JMR!! Added this line!!!}
Headers.Add('Range: bytes=' + FContentRangeBegin + '-' + FContentRangeEnd); {JMR!! Added this line!!!}
if (Method <> 'CONNECT') then { V7.21 }
begin
FContentRangeBegin := ''; {JMR!! Added this line!!!}
FContentRangeEnd := ''; {JMR!! Added this line!!!}
end;
end; {JMR!! Added this line!!!}
FAcceptRanges := ''; {SendCommand('UA-pixels: 1024x768'); }
{SendCommand('UA-color: color8'); }
{SendCommand('UA-OS: Windows 95'); }
{SendCommand('UA-CPU: x86'); }
{SendCommand('Proxy-Connection: Keep-Alive'); }
{$IFNDEF NO_DEBUG_LOG}
if CheckLogOptions(loProtSpecInfo) then { V1.91 } { replaces $IFDEF DEBUG_OUTPUT }
DebugLog(loProtSpecInfo, IntToStr(Headers.Count) +
' header lines to send'## + Headers.Text);
{$ENDIF}
TriggerBeforeHeaderSend(Method, Headers);
for N := to Headers.Count - do
SendCommand(Headers[N]);
TriggerRequestHeaderEnd;
SendCommand('');
FCtrlSocket.PutDataInSendBuffer(FReqStream.Memory, FReqStream.Size);
FReqStream.Clear;
FCtrlSocket.Send(nil, );
finally
Headers.Free;
{$IFNDEF NO_DEBUG_LOG}
if CheckLogOptions(loProtSpecInfo) then { V1.91 } { replaces $IFDEF DEBUG_OUTPUT }
DebugLog(loProtSpecInfo, 'SendRequest Done');
{$ENDIF}
end;
end;
ics httpDELETE 时增加 content,length 特别需求的更多相关文章
- The maximum string content length quota (8192) has been exceeded while reading XML data
原文:The maximum string content length quota (8192) has been exceeded while reading XML data 问题场景:在我们W ...
- WCF常见异常-The maximum string content length quota (8192) has been exceeded while reading XML data
异常信息:The maximum string content length quota (8192) has been exceeded while reading XML data 问题:调用第三 ...
- [Android]异步加载图片,内存缓存,文件缓存,imageview显示图片时增加淡入淡出动画
以下内容为原创,欢迎转载,转载请注明 来自天天博客:http://www.cnblogs.com/tiantianbyconan/p/3574131.html 这个可以实现ImageView异步加载 ...
- String Matching Content Length
hihocoder #1059 :String Matching Content Length 时间限制:10000ms 单点时限:1000ms 内存限制:256MB 描述 We define the ...
- 定时器setInterval, innerText获取文本, charAt()获取单个字符串, substring(1, content.length)获取范围内的字符串, 实现字符串的滚动效果
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...
- Hihocoder 1059 String Matching Content Length
预处理下连续相等的字符个数其实主要是看是否满3个 后面递推的时候特判下+1上次递推[i-1,j-1]不是来自[i-2,j-1]也不是来自[i-1,j-2]其实就是只来自[i-4,j-4]+3,和[i- ...
- PHP为fopen,file_get_contents等函数请求web地址时增加Http头的方法
我们在使用fsockopen时可以方便的自定义自己请求的http头内容来访问某些对客户端请求头有特殊限制的网站,但是使用fopen,file_get_contents等函数请求web地址时怎么来灵活定 ...
- digital ocean 内存不足时增加swap文件的方法
买了比较低配的digitalocean 云主机,在执行composer update的时候出现内存不足的问题,但是内存大小已经固定了,除非加钱,还有别的方法吗? 有,增加swap分区,这样就可以弥补内 ...
- WebView之加载网页时增加进度提示
上一节讲了一些webview的基本使用以及在记载网页时如何屏蔽掉第三方浏览器,使我们自己开发的程序成为一个微型浏览器.那么这一节将一下在webView加载网页的过程中如何加上进度提示.效果图如下: 主 ...
随机推荐
- 在slam_gmapping中使用Log数据创建地图
本文介绍使用机器人记录的tf变换和激光扫描数据来建立2D地图.并在ROS的图形化模拟环境rviz中通过重新回放记录的数据作为机器人真实传感器采集的输入,来观测地图动态创建过程. 1.ROS gmapp ...
- 金融卡IC卡知识50问
1.什么是金融IC卡? 金融IC卡又称为芯片银行卡,是以芯片作为介质的银行卡.芯片卡容量大,可以存储密钥.数字证书.指纹等信息,其工作原理类似于微型计算机,能够同时处理多种功能,为持卡人提供一卡多用的 ...
- 编写高质量代码改善C#程序的157个建议——建议18:foreach不能代替for
建议18:foreach不能代替for 上一个建议中提到了foreach的两个优点:语法更简单,默认调用Dispose方法,所有我们强烈建议在实际的代码编写中更多的使用foreach.但是,该建议也有 ...
- jeecms如何迭代list集合
[@cms_channel_list][#list tag_list as a ]${a.name} [/#list][/@cms_channel_list]使用[XXX_list] 参数为 tag_ ...
- XE下 SVG格式的图标使用方法
下载一个SVG格式的图标,千图网,http://tool.58pic.com/tubiaobao/ 用txt文本打开SVG图标 拖一个PathLabel控件 在PathLabel控件的Data属性添加 ...
- Spring中的用到的设计模式
应该说设计模式是我们在写代码时候的一种被承认的较好的模式.好的设计模式就像是给代码造了一个很好的骨架,在这个骨架里,你可以知道心在哪里,肺在哪里,因为大多数人都认识这样的骨架,就有了很好的传播性.这是 ...
- Invoke()的使用
(最近在看协程) Invoke()方法是一种委托机制 Invoke ( "SendMsg", 3 ), 意思是3秒之后调用 SendMsg() 方法 使用时应该注意以下几点: 1. ...
- [译] 关于 SPA,你需要掌握的 4 层 (2)
此文已由作者张威授权网易云社区发布. 欢迎访问网易云社区,了解更多网易技术产品运营经验. 视图层 现在我们有了一个可执行且不依赖于框架的应用程序,React 已经准备投入使用. 视图层由 presen ...
- 教你如何选择BI数据可视化工具
本文来自网易云社区. 关于如何选择BI数据可视化工具,总体而言,主流BI产品在选择的时候要除了需要考虑从数据到展现.从公司内到公司外等各种场景,结合前面朋友的回答,还需要考虑以下几点:1:以后的数据处 ...
- kafka启动报错Cannot allocate memory;There is insufficient memory for the Java Runtime Environment to continue.
kafka启动过程报错,配置没有问题,这就懵了!! Java HotSpot(TM) 64-Bit Server VM warning: INFO: os::commit_memory(0x00000 ...