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 特别需求的更多相关文章

  1. 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 ...

  2. 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 问题:调用第三 ...

  3. [Android]异步加载图片,内存缓存,文件缓存,imageview显示图片时增加淡入淡出动画

    以下内容为原创,欢迎转载,转载请注明 来自天天博客:http://www.cnblogs.com/tiantianbyconan/p/3574131.html  这个可以实现ImageView异步加载 ...

  4. String Matching Content Length

    hihocoder #1059 :String Matching Content Length 时间限制:10000ms 单点时限:1000ms 内存限制:256MB 描述 We define the ...

  5. 定时器setInterval, innerText获取文本, charAt()获取单个字符串, substring(1, content.length)获取范围内的字符串, 实现字符串的滚动效果

    <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...

  6. 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- ...

  7. PHP为fopen,file_get_contents等函数请求web地址时增加Http头的方法

    我们在使用fsockopen时可以方便的自定义自己请求的http头内容来访问某些对客户端请求头有特殊限制的网站,但是使用fopen,file_get_contents等函数请求web地址时怎么来灵活定 ...

  8. digital ocean 内存不足时增加swap文件的方法

    买了比较低配的digitalocean 云主机,在执行composer update的时候出现内存不足的问题,但是内存大小已经固定了,除非加钱,还有别的方法吗? 有,增加swap分区,这样就可以弥补内 ...

  9. WebView之加载网页时增加进度提示

    上一节讲了一些webview的基本使用以及在记载网页时如何屏蔽掉第三方浏览器,使我们自己开发的程序成为一个微型浏览器.那么这一节将一下在webView加载网页的过程中如何加上进度提示.效果图如下: 主 ...

随机推荐

  1. WCF把书读薄(2)——消息交换、服务实例、会话与并发

    上一篇:WCF把书读薄(1)——终结点与服务寄宿 八.消息交换模式 WCF服务的实现是基于消息交换的,消息交换模式一共有三种:请求回复模式.单向模式与双工模式. 请求回复模式很好理解,比如int Ad ...

  2. [GO]将随机生成的四位数字拆分后放到一个切片里

    package main import ( "math/rand" "time" "fmt" ) func InitData(p *int) ...

  3. 分享一个好用的功能强大的节点树jQuery插件

    http://www.treejs.cn/

  4. Introduction to Partial View

    By Jignesh Trivedi on May 14, 2015 http://www.c-sharpcorner.com/UploadFile/ff2f08/partial-view-in-mv ...

  5. razor自定义函数 @helper 和@functions小结

    from:http://www.cnblogs.com/jiagoushi/p/3904995.html asp.net Razor 视图具有.cshtml后缀,可以轻松的实现c#代码和html标签的 ...

  6. Deep Residual Learning for Image Recognition

    Kaiming He, Xiangyu Zhang, Shaoqing Ren, Jian Sun           Microsoft Research {kahe, v-xiangz, v-sh ...

  7. 关于VBS的一个怪现象

    今天一个同学让我帮忙写一个程序,要求是: 输入一个n,返回从0到n中任意个数的组合,返回取异或结果为0的组合.来看VBS代码 n = p = "" ^n - s = s = s ) ...

  8. C#ADO.NET基础一

    简介 使用SQLite进行讲解 1.基础类: SQLiteConnection 连接数据库 SQLiteCommand 执行命令(增,删,改,查),或存储过程 SQLiteDataReader 读取查 ...

  9. sqlite数据库文件查看

  10. 20165219 《Java程序设计》实验三(敏捷开发与XP实践)实验报告

    20165219 <Java程序设计>实验三(敏捷开发与XP实践)实验报告 一.实验报告封面 课程:Java程序设计 班级:1652班 姓名:王彦博 学号:20165219 成绩: 指导教 ...