开源的版本也一样会。
rtcinfo.pas ,以下的解析 StatusCode 有问题,如果服务器返回的是 “HTTP/1.1 200” 后面没有状态文本。会解析不到 状态码,这里应该按标准格式来,协议 空格 状态码 空格 状态文本
一个一个解析才对,但是RTC 认为状态码、文本是要一起有的。
例子:同一个请求用RTC的话,状态码是0 而用POSMAN 是200
procedure TRtcResponse.SetHeaderText(const pValue: AnsiString); var MyPos:integer; StatusLine, HeadStr, left:AnsiString; begin if pValue='' then Exit; HeadStr:=pValue+CRLF; if length(HeadStr)>6 then begin if ((HeadStr[5]='/') and (Upper_Case(Copy(HeadStr,1,4))='HTTP')) or ((HeadStr[6]='/') and (Upper_Case(Copy(HeadStr,1,5))='HTTPS')) then begin MyPos:=Pos(CRLF,HeadStr); StatusLine:=Copy(HeadStr,1,MyPos-1); Delete(HeadStr,1,MyPos+Length(CRLF)-1); { Our line probably looks like this: HTTP/1.1 200 OK } MyPos:=PosEx(' ',StatusLine); // first space before StatusCode if MyPos>0 then begin StatusCode:=0; StatusText:=''; Delete(StatusLine,1,MyPos); MyPos:=PosEx(' ',StatusLine); // space after StatusCode if MyPos>0 then begin left:=Copy(StatusLine,1,MyPos-1); // StatusCode Delete(StatusLine,1,MyPos); // StatusText if (left<>'') and (StatusLine<>'') then begin try StatusCode:=Str2Int64(left); StatusText:=StatusLine; except // if there is something wrong with this, just ignore the exception end; end; end; end; end; end; inherited SetHeaderText(HeadStr); end;
标签:begin,end,statucode,RTC,delphi,HeadStr,StatusCode,StatusLine,MyPos From: https://www.cnblogs.com/BTag/p/17422497.html