gpt4 book ai didi

delphi - HTTPRIO After执行问题

转载 作者:行者123 更新时间:2023-12-03 15:31:26 25 4
gpt4 key购买 nike

我想HTTPRio组件收到数据后,会解析数据。我这样说是因为在程序离开 AfterExecute 过程之后,需要很长时间才能继续执行下一行代码。

我想要的是清除已经到达AfterExecute过程的数据。这可能吗?

procedure TEventHandlers.thhoptAfterExecute(const MethodName: string;
SOAPResponse: TStream);
var
fs : TFileStream;
begin
fs := TFileStream.Create('F:\Lixosam\LixoSMS'+
IntToStr(ThCampanha),
fmCreate, fmShareDenyNone);
SOAPResponse.Position := 0;
fs.CopyFrom(SOAPResponse, SOAPResponse.Size);
fs.Free;
end;

如何清除数据以便组件不必进行任何解析?

最佳答案

您可以在 SOAPResponse 中写入任何您想要的内容。你可以清除它,编辑它,等等。如果完全空的响应导致反序列化出现问题(有关“文档必须在第 0 行处具有顶级元素”的提示),您可以坚持提供最小结构的“骨架”响应。如果您编辑响应,则应相应地设置大小。这是我的一些代码:

var
sl : TStringList;

begin
sl := TStringList.Create;
try
SOAPResponse.Position := 0;
sl.LoadFromStream(SOAPResponse); // Load the response into a stringlist so we can work on it.

// some manipulation to the lines in sl occur here, such as stringreplaces and such.


// Now write out edits back out to the stream.
SOAPResponse.Position := 0; // Now overwrite the crappy response with our good one.
SOAPResponse.size := length(sl.Text); // Important - set new length before saving. Otherwise, the old
sl.SaveToStream(SOAPResponse); // leftover crud is still there, at the end, and the XML will blow up on it.

finally
FreeAndNil(sl);
end;
end;

关于delphi - HTTPRIO After执行问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6061850/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com