发布Indy TIdHTTP的问题 [英] Post problems with Indy TIdHTTP
问题描述
我使用Indy的TIdHTTP向亚马逊的 SES 服务发布问题。
以下是我使用的代码示例:
程序TMainFrm.btnAmazonSESClick (发件人:TObject);
var
SSLHandler:TIdSSLIOHandlerSocket;
HttpClient:TIdHTTP;
参数:TStringStream;
begin
SSLHandler:= TIdSSLIOHandlerSocket.Create(Self);
HttpClient:= TIdHTTP.Create(Self);
参数:= TStringStream.create('');
尝试
与SSLHandler做
SSLOptions.Method:= sslvSSLv3
与HttpClient做
开始
IOHandler:= SSLHandler;
AllowCookies:= True;
HandleRedirects:= True;
HTTPOptions:= [hoForceEncodeParams];
Request.ContentType:='application / x-www-form-urlencoded';
结束
PageMemo.Text:= HttpClient.Post('https://email.us-east-1.amazonaws.com?Action=VerifyEmailAddress&AWSAccessKeyId=012Some123Key46&EmailAddress=test@test%2Ecom' ,Params);
finally
SSLHandler.Free;
HttpClient.Free;
Params.Free;
结束
结束
结果
-
在Indy 10.5.7下,我得到错误:HTTP / 1.1 404未找到
-
在Indy 9.0下。 14我得到错误:套接字错误#11004
调试试验
-
同样的演示可以从HTTPS网页上成功获取HTML。
-
如果我将上面的URL粘贴到浏览器中,则会显示预期的XML结果。
这篇文章是只是一个不完整的野性猜测。
也许Remy可能会帮助您纠正它。使用以下代码,我得到HTTP / 1.1 400错误请求,但我不知道因为 API参考
谈论 常见查询参数
至少要求您为请求创建的数字签名,我不知道该怎么做
我无法测试,因为我没有帐户。但我认为
procedure TForm1.Button1Click(Sender:TObject);
var
HTTPClient:TIdHTTP;
参数:TStrings;
SSLHandler:TIdSSLIOHandlerSocketOpenSSL;
begin
SSLHandler:= TIdSSLIOHandlerSocketOpenSSL.Create(nil);
HTTPClient:= TIdHTTP.Create(nil);
参数:= TStringList.Create;
try
SSLHandler.SSLOptions.Method:= sslvSSLv3;
SSLHandler.SSLOptions.Mode:= sslmUnassigned;
HTTPClient.IOHandler:= SSLHandler;
HTTPClient.HTTPOptions:= [hoForceEncodeParams];
HTTPClient.Request.ContentType:='application / x-www-form-urlencoded';
Parameters.Add('Action = VerifyEmailAddress');
Parameters.Add('EmailAddress=test@test.com');
Parameters.Add('AWSAccessKeyId = 012Some123Key46');
Parameters.Add('SignatureVersion = 2');
Parameters.Add('Expires ='); // ???
Parameters.Add('Signature ='); // ???
PageMemo.Text:= HTTPClient.Post('https://email.us-east-1.amazonaws.com',参数);
finally
SSLHandler.Free;
HTTPClient.Free;
参数.Free;
结束
结束
I am having issues posting to Amazon's SES Service using Indy's TIdHTTP.
Here is an example of the code i am using:
procedure TMainFrm.btnAmazonSESClick(Sender: TObject);
var
SSLHandler: TIdSSLIOHandlerSocket;
HttpClient: TIdHTTP;
Params: TStringStream;
begin
SSLHandler := TIdSSLIOHandlerSocket.Create(Self);
HttpClient := TIdHTTP.Create(Self);
Params := TStringStream.create('');
try
with SSLHandler do
SSLOptions.Method := sslvSSLv3
with HttpClient do
begin
IOHandler := SSLHandler;
AllowCookies := True;
HandleRedirects := True;
HTTPOptions := [hoForceEncodeParams];
Request.ContentType := 'application/x-www-form-urlencoded';
end;
PageMemo.Text := HttpClient.Post('https://email.us-east-1.amazonaws.com?Action=VerifyEmailAddress&AWSAccessKeyId=012Some123Key46&EmailAddress=test@test%2Ecom', Params);
finally
SSLHandler.Free;
HttpClient.Free;
Params.Free;
end;
end;
Result
Under Indy 10.5.7 I get the error: HTTP/1.1 404 Not Found
Under Indy 9.0.14 I get the error: Socket Error # 11004
Debugging Trials
This same demo can successfully GET the HTML from an HTTPS web page.
If i paste the URL above into a browser it displays the expected XML result.
I would appreciate any advice on the cause.
This post is just an incomplete wild guess.
Maybe Remy might help you to correct it. With the following code I'm getting HTTP/1.1 400 Bad Request but I'm not wondering because the API reference
talks about Common Query Parameters
where is at least required the digital signature you'll create for the request what I don't know how to do.
I can't test this at all because I have no account there. But I think the
procedure TForm1.Button1Click(Sender: TObject);
var
HTTPClient: TIdHTTP;
Parameters: TStrings;
SSLHandler: TIdSSLIOHandlerSocketOpenSSL;
begin
SSLHandler := TIdSSLIOHandlerSocketOpenSSL.Create(nil);
HTTPClient := TIdHTTP.Create(nil);
Parameters := TStringList.Create;
try
SSLHandler.SSLOptions.Method := sslvSSLv3;
SSLHandler.SSLOptions.Mode := sslmUnassigned;
HTTPClient.IOHandler := SSLHandler;
HTTPClient.HTTPOptions := [hoForceEncodeParams];
HTTPClient.Request.ContentType := 'application/x-www-form-urlencoded';
Parameters.Add('Action=VerifyEmailAddress');
Parameters.Add('EmailAddress=test@test.com');
Parameters.Add('AWSAccessKeyId=012Some123Key46');
Parameters.Add('SignatureVersion=2');
Parameters.Add('Expires='); // ???
Parameters.Add('Signature='); // ???
PageMemo.Text := HTTPClient.Post('https://email.us-east-1.amazonaws.com', Parameters);
finally
SSLHandler.Free;
HTTPClient.Free;
Parameters.Free;
end;
end;
这篇关于发布Indy TIdHTTP的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!