标签:highlight serve ifd lse phi hold ons enc 发送
indy10的idhttpServer应答字符串
先看应答字符串的代码:
procedure TIdIOHandler.Write(const AOut: string; AByteEncoding: IIdTextEncoding = nil {$IFDEF STRING_IS_ANSI}; ASrcEncoding: IIdTextEncoding = nil{$ENDIF} ); begin if AOut <> ‘‘ then begin AByteEncoding := iif(AByteEncoding, FDefStringEncoding); {$IFDEF STRING_IS_ANSI} ASrcEncoding := iif(ASrcEncoding, FDefAnsiEncoding, encOSDefault); {$ENDIF} Write( ToBytes(AOut, -1, 1, AByteEncoding {$IFDEF STRING_IS_ANSI}, ASrcEncoding{$ENDIF} ) ); end; end;
从代码可以看出,发送字符串,最终是将字符串转为TidBytes,发送的。
再跟一下发送TidBytes的代码:
procedure TIdIOHandler.Write(const ABuffer: TIdBytes; const ALength: Integer = -1; const AOffset: Integer = 0); var LLength: Integer; begin LLength := IndyLength(ABuffer, ALength, AOffset); if LLength > 0 then begin if FWriteBuffer = nil then begin WriteDirect(ABuffer, LLength, AOffset); end else begin // Write Buffering is enabled FWriteBuffer.Write(ABuffer, LLength, AOffset); if (FWriteBuffer.Size >= WriteBufferThreshold) and (WriteBufferThreshold > 0) then begin repeat WriteBufferFlush(WriteBufferThreshold); until FWriteBuffer.Size < WriteBufferThreshold; end; end; end; end;
大的BUF,会分成N次陆续发送。所以INDY发送大字符串无须担心什么。
标签:highlight serve ifd lse phi hold ons enc 发送
原文地址:https://www.cnblogs.com/hnxxcxg/p/10265227.html