delphi - 在 Delphi XE 中使用 Indy IdHttp Digest 身份验证的 401

delphi - 在 Delphi XE 中使用 Indy IdHttp Digest 身份验证的 401

尝试使用 Digest 对合作伙伴的使用 Delphi XE 的 Web 服务执行 get()。

我已将IdAuthenticationDigestuses 子句包含在我所阅读的内容中,该子句应该会自动起作用-但我一定遗漏了一些东西,因为我得到了401 Unauthorized。

代码:

begin

// Init request:

IdHttp := TIdHttp.Create(nil);

try

idHttp.Request.ContentType := self.inputType; // 'application/xml'

idHttp.Request.Accept := self.outputType; //'application/json';

// Set request method:

idHttp.Request.Method := Method; // 'Get'

// Set username and password:

idHttp.Request.BasicAuthentication := False;

// IdHttp.Request.Username/Password also fails

IdHttp.Request.Authentication.Username := 'xx';

IdHttp.Request.Authentication.password := 'xx';

IdHttp.Request.ContentLength := Length(Body);

// Send request:

if Method = 'GET' then

Result := idHttp.Get(self.ServiceHost + URI)

else

if Method = 'POST' then

Result := idHttp.Post(self.ServiceHost + URI, SendStream);

finally

idHttp.Free;

end;

end;

相关推荐

java主流中间件有哪些
网彩365平台下载

java主流中间件有哪些

🕒 07-01 👁️ 6792
表 - SQL Server
365bet注册送35元

表 - SQL Server

🕒 07-11 👁️ 8163
牡丹花蕊茶价格多少,小瓶装20瓶,品质与性价比解析
网彩365平台下载

牡丹花蕊茶价格多少,小瓶装20瓶,品质与性价比解析

🕒 07-14 👁️ 3807