0
我正在使用以下Delphi代碼來下載JIRA問題的附件內容。發送請求引發拒絕訪問異常。是任何安全證書相關的問題:XMLHTTPRequest.Send中的拒絕訪問錯誤
class function TnsXmlHttpReq.GetRequestForStream(const p_Url, p_UsrName,
p_Password: String; out p_Status: Integer): TMemoryStream;
var
LBody : OleVariant;
Stream: IStream;
OleStream: TOleStream;
begin
Result:= nil;
p_Status:= 0;
if FHttpRequest = nil then
FHttpRequest:= CoXMLHTTPRequest.Create;
FHttpRequest.open('GET', p_Url, false, p_UsrName, p_Password);
FHttpRequest.setRequestHeader('X-Atlassian-Token', 'no-check');
FHttpRequest.setRequestHeader('Authorization','Basic '+EncodeBase64(p_UsrName+':'+p_Password));
FHttpRequest.setRequestHeader('Cache-Control', 'no-cache');
//send request
FHttpRequest.send('');
p_Status:= FHttpRequest.status;
if FHttpRequest.status <> 200 then
Exit;
Result:= TMemoryStream.Create;
Stream := IUnknown(FHttpRequest.ResponseStream) as IStream;
OleStream := TOleStream.Create(Stream);
try
OleStream.Position := 0;
Result.CopyFrom(OleStream, OleStream.Size);
finally
OleStream.Free;
end;//try..finally...
end;