我使用IdHttp1+IdSSLIOHandlerSocketOpenSSL1的方式来访问HTTPS网站。如果使用GET则可以返回页面内容,但是如果使用POST则提示Connection Closed Gracefully.不知道问题出在何处。

解决方案 »

  1.   

    就是要模拟登录啊。POST不行,我先试一下GET,GET能返回页面,但POST就提示温和关闭。
      

  2.   

    我贴一下我的代码:  PostData := TStringStream.Create('');
      Outt := TMemoryStream.Create;  PostData.WriteString(Format('username=%s', [Account]));
      PostData.WriteString(Format('&password=%s', [Password]));
      PostData.WriteString(Format('&service=%s', ['miniblog']));
      PostData.WriteString(Format('&encoding=%s', ['utf-8']));
      PostData.WriteString(Format('&gateway=%s', ['1']));
      PostData.WriteString('&url='+httpapp.HTTPEncode('http://t.sina.com.cn/ajaxlogin.php?framelogin=1&callback=parent.sinaSSOController.feedBackUrlCallBack'));
      PostData.WriteString(Format('&returntype=%s', ['META']));
      PostData.WriteString(Format('&savestate=%s', ['7']));
      PostData.WriteString(Format('&useticket=%s', ['0']));
      m_http.HTTPOptions := [];  m_http.Request.ContentType := 'application/x-www-form-urlencoded';
      m_http.Request.Referer := 'http://t.sina.com.cn/login.php?url=http%3A%2F%2Ft.sina.com.cn%2F';
      m_http.Post('https://login.sina.com.cn/sso/login.php', PostData, outt);
    执行这段代码后,提示“Connection Closed Gracefully.”。
      

  3.   

    这个很简单只要截好POST的数据直接POST就行,看好网站表单是以什么方式传输