我有在Delphi 2007实现与印10 HTTP服务器麻烦。

我已经设置了一个简单的事件处理程序事件CommandGet

当使用GET方法答复数据发送我可以解析PARAMS和没有问题发送XML数据返回。 (见下面的代码)

    Download := ARequestInfo.Params.Values['dld'];
    Config := ARequestInfo.Params.Values['config'];
    Flash := ARequestInfo.Params.Values['flash'];
    Employees := ARequestInfo.Params.Values['employees'];
    Schedule := ARequestInfo.Params.Values['schedules'];
    AppTables := ARequestInfo.Params.Values['apptables'];

    Heartbeat :=  NewHeartbeat;

    Heartbeat.Version.Dld := Download;
    Heartbeat.Version.Config := Config;
    Heartbeat.Version.Flash := Flash;
    Heartbeat.Version.Employee := Employees;
    Heartbeat.Version.Schedule := Schedule;
    Heartbeat.Version.AppTables := AppTables;

    AResponseInfo.ContentType := 'application/xml';
    AResponseInfo.ResponseNo := 200;
    AResponseInfo.ContentText := '<?xml version="1.0" encoding="utf-8"?>' +
      #13+#10 + FormatXMLData(Heartbeat.XML);

当我尝试回复到使用一个POST的响应发送的数据从不被印发送,而不是一个,EIdConnClosedGracefully是由TIdIOHandler.WriteDirect凸起形成CheckForDisconnect(TRUE,TRUE)线。这里是如何我处理输入的POST数据

    XMLDocument1.xml.Clear;
    XMLDocument1.Active := True;
    XMLDocument1.XML.text := ARequestInfo.FormParams;

    SynMemo1.Lines.Add(ARequestInfo.FormParams);
    SynMemo1.Lines.Add(#13+#10);

    if XMLDocument1.XML.Count > 0 then
    begin
      XMLDocument1.XML.Delete(0);
      XMLDocument1.XML.Delete(0);

      for i := pred(xmldocument1.xml.count) downto 0 do
      begin
        stmp := XMLDocument1.XML.Strings[i];

        if Length(stmp) > 0 then
        begin
          if Copy(stmp,1,1) = '<' then
            break
          else
            XMLDocument1.XML.Delete(i);
        end
        else
          XMLDocument1.XML.Delete(i);

      end;

      XMLDocument1.XML.Text := StringReplace(XMLDocument1.XML.Text,
        '<Punches ', '<Punches xmlns="http://ats/punch" ', [rfReplaceAll]);



    end;

    Punch := GetPunches(XMLDocument1);

    PunchReply := NewOperationStatus;
    PunchReply.Uid := Punch.Uid;
    PunchReply.NodeValue := 'OK';

    stmp := '<?xml version="1.0" encoding="utf-8"?>' +
      #13+#10 + FormatXMLData(PunchReply.XML);
    SynMemo1.Lines.Add(stmp);
    SynMemo1.Lines.Add(#13+#10);

    AResponseInfo.ContentType := 'text/html';
    AResponseInfo.ContentStream := TStringStream.Create(stmp);

我已经使用Wireshark来查看发生的情况和它看起来像印正在发送回ACK响应发送之前以及使所述客户端断开。

要测试这个我设置了的Apache和PHP写了PHP脚本,做同样的工作,一切工作正常,所不同的是POST数据回复到与响应内容不是一个ACK。

这是如何解决这个,所以我来响应POST数据以及得到任何建议。


我坚持了现在这个样子,因为你可以从这个Wireshark的跟踪看(点击链接,图片)我已经超时增加到20秒。和它仍然没有工作。我会做一些更多的调查。 ,看看我能找到。它看起来像印地认为它有

在发生断开

按此图片

有帮助吗?

解决方案

看起来像HTTP被发送作为

Transfer-Encoding: chunked

因此,不存在内容长度。但印我的版本我使用的是不支持这种模式。

其他提示

的ACK没有被印自己发送的,而是由下面的插座相反,甚至那么只有在回答从另一方接收到的分组。引发EIdConnClosedGracefully异常意味着客户端有意断开其末端插座您的服务器可以前发送答复数据。到ACK的存在,这有助于证明(断开期间将插座可能ACK'ing客户端的FIN包)。

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top