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加载网页的过程中如何加上进度提示.效果图如下: 主 ...
随机推荐
- C/C++预处理指令常见的预处理指令
C/C++预处理指令常见的预处理指令如下: #空指令,无任何效果 #include包含一个源代码文件 #define定义宏 #undef取消已定义的宏 #if如果给定条件为真,则编译下面代码 #ifd ...
- css总结5:px、em、rem区别介绍
1 PX px像素(Pixel).相对长度单位.像素px是相对于显示器屏幕分辨率而言的. PX特点 1. 浏览器无法调整px单位的字体,以em或rem为字体单位可调整字体. 2 EM em是相对长度单 ...
- (转)Asp.net页面生命周期详解任我行(1)-小试牛刀,编写页面代码
原文地址:http://www.cnblogs.com/xuyubing/archive/2013/10/01/3348344.html 前言 很久很久以前,还是我在学校的时候,我就看了传智里面视频, ...
- do_gettimeofday使用方法
1.简介: 在Linux中可以使用函数do_gettimeofday()函数来得到精确时间.它的精度可以达到微妙,是与C标准库中gettimeofday()用发相同的函数.在Linux内核中获得时间的 ...
- Python&Django学习系列之-激活管理界面
1.创建你个人的项目与APP 2.填写你的数据库名称与数据库类型,这里使用内置的sqllite3 3.修改setting文件 a.将'django.contrib.admin'加入setting的IN ...
- smartUpload上传下载
上传 file_upload_smart_form.jsp文件代码 <%@ page contentType="text/html;charset=gb2312" langu ...
- 简单接触oracle数据库nvl函数decode函数
SQL语句的DECODE()和NVL()函数用法 SELECT DECODE(choose_tool,0,'宝马',1,'电动车',2,'自行车','步行') AS my_tool FROM dat ...
- mysql索引及多表查询
注意where,group by ,having,order by, limit 等的顺序. 主表是被绑定的表,子表是添加了外键了的表,注意,在创建表的时候可以添加外键,也可以创建完了以后添加外键. ...
- Mysql避免重复插入记录方法
一.mysql replace用法 1.replace into replace into table (id,name) values('1','aa'),('2','bb') 此语句的作用是向 ...
- Vue Vuex state mutations
Vuex 解决不同组件的数据共享,与数据持久化 1.npm install vuex --save 2.新建store.js 并引入vue vuex ,Vue.use(Vuex) 3.state在vu ...