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加载网页的过程中如何加上进度提示.效果图如下: 主 ...
 
随机推荐
- eclipse——配置maven插件
			
Step 1 配置installations installations:指定Maven核心程序的位置 从本地磁盘中找到本地maven的位置 Step 2 配置user settings user ...
 - hdu 4681 String(转载)
			
#include <stdio.h> #include <string.h> #include <algorithm> #include <iostream& ...
 - c#事务的使用、示例及注意事项
			
什么是数据库事务 数据库事务是指作为单个逻辑工作单元执行的一系列操作. 设想网上购物的一次交易,其付款过程至少包括以下几步数据库操作: · 更新客户所购商品的库存信息 · 保存客户付款信息--可能 ...
 - 理解 RESTful WebService
			
RESTful 服务遵循REST(Representational State Transfer)的架构风格,中文翻译为:表现层状态转化 对于所有的CRUD(Read/Create/Update/De ...
 - Mybaties核心配置文件
			
<?xml version="1.0" encoding="UTF-8" ?><!DOCTYPE configurationPUBLIC &q ...
 - Position Independent Code (PIC) in shared libraries on x64
			
E原文地址:http://eli.thegreenplace.net/2011/11/11/position-independent-code-pic-in-shared-libraries-on-x ...
 - 编写高质量代码改善C#程序的157个建议——建议39:了解委托的实质
			
建议39:了解委托的实质 理解C#中的委托需要把握两个要点: 1)委托是方法指针. 2)委托是一个类,当对其进行实例化的时候,要将引用方法作为它的构造方法的参数. 设想这样一个场景:在点对点文件传输过 ...
 - delphi7和XE下  获取路径
			
XE里没有Application.Exename所以用paramstr(0); Str:=ParamStr(0); //自己全路径c:\555\qq.exe,可用于控制台Str:=ExpandFile ...
 - fabric Clone
			
记录下: var newObj = fabric.util.object.clone(obj); decDoc.dropCanvas.add(newObj., top: }));
 - sql server  简单语句整合
			
1.去重distinct , group by select distinct userid,username from 表名 select userid,username from 表名 group ...