来自服务器的XML响应idhttp

问题描述:

获取发送请求到服务器并收到错误409,程序被暂停,使用try除了忽略她,我也有一个错误409和XML响应,我怎么读它?来自服务器的XML响应idhttp

HTTP.Response.gettext - 它不给我,只有服务器

http.response.rawheaders.commatext的信息 - 只有服务器的信息

内容lenght匹配

答案可以在嗅探器中看到

我在程序中得到答案?

+0

如何得到答案? – user1748535

+0

获取什么答案?响应内容?你如何获取代码中的内容?你甚至试过从我的(现在删除)文章中的代码? – TLama

+0

HTTP/1.1 409冲突 Content-Type:text/xml; charset = utf-8 服务器:Jetty(6.1.x) 内容长度:160 连接:保持活动 user1748535

TIdHTTP从服务器接收到一个HTTP错误,如409,它提出了一个EIdHTTPProtocolException例外,错误的内容文本将在其ErrorMessage属性,如:

try 
    IdHTTP1.Get(...); 
except 
    on E: EIdHTTPProtocolException do 
    begin 
    // HTTP-specific error 
    ShowMessage(Format('HTTP Error'#13'Response: %d %s'#13'Content: %s', [E.ErrorCode, E.Message, E.ErrorMessage])); 
    end; 
    on E: Exception do 
    begin 
    // any other error 
    ShowMessage(Format('Exception'#13'Class: %s'#13'%s', [E.ClassName, E.Message])); 
    end; 
end; 

当您遇到密码错误,它应该显示一个弹出消息框说如下:

HTTP Error 
Response: 409 Conflict 
Content: <?xml version="1.0" encoding="UTF-8" standalone="yes"?><error code="10003" appid="1"><failure cause="INVALID_PASSWORD" field="password" value="******"/></error>