简体   繁体   English

发布Indy TIdHTTP的问题

[英]Post problems with Indy TIdHTTP

I am having issues posting to Amazon's SES Service using Indy's TIdHTTP. 我在使用Indy的TIdHTTP向亚马逊的SES服务发布问题时遇到了问题。

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 在Indy 10.5.7下我收到错误:HTTP / 1.1 404 Not Found

  • Under Indy 9.0.14 I get the error: Socket Error # 11004 在Indy 9.0.14下我得到错误:套接字错误#11004

Debugging Trials 调试试验

  • This same demo can successfully GET the HTML from an HTTPS web page. 这个演示可以从HTTPS网页成功获取HTML。

  • If i paste the URL above into a browser it displays the expected XML result. 如果我将上面的URL粘贴到浏览器中,它会显示预期的XML结果。

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. 使用以下代码我得到HTTP / 1.1 400错误请求,但我不想知道,因为API reference讨论了Common Query Parameters ,其中至少需要您为请求创建的数字签名,我不知道怎么做。

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;

Basically, you need to use the right library, ie: 基本上,您需要使用正确的库,即:

For Indy 10.5.7 use openssl-1.0.1e-i386-win32 or openssl-1.0.1e-x64_86-win64 from http://indy.fulgan.com/SSL/ You may want to download an ssl demo from: http://indy.fulgan.com/ZIP/ 对于印10.5.7使用OpenSSL-1.0.1e-I386-win32的或的OpenSSL 1.0.1e-x64_86-Win64上从http://indy.fulgan.com/SSL/您可能希望从下载SSL演示: HTTP: //indy.fulgan.com/ZIP/

Regards 问候

Jose 何塞

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM