加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 大数据 > 正文

[delphi]indy10 idhttp get方法

发布时间:2020-12-15 09:59:10 所属栏目:大数据 来源:网络整理
导读:idhttp中对于get方法的定义: [delphi] ? view plain copy print ? procedure ?Get(AURL:? string ;?AResponseContent:?TStream);?overload;?? string ;?AResponseContent:?TStream;?AIgnoreReplies:? array ? of ?SmallInt);?? ?overload;?? function ?Get(

idhttp中对于get方法的定义:

[delphi]? view plain copy print ?
  1. procedure?Get(AURL:?string;?AResponseContent:?TStream);?overload;??
  2. string;?AResponseContent:?TStream;?AIgnoreReplies:?array?of?SmallInt);??
  3. ?overload;??
  4. function?Get(AURL:?string):?string;?overload;??
  5. string;?AIgnoreReplies:?of?SmallInt):?string;?overload;??

其中的最基本的方法是过程类方法
?
    of?SmallInt);??
  1. ?????overload;??
其他的几个get方法重载都是基于嵌套的此方法。

参数:

[python]? ?
    AURL:?string;???//?get操作的目标URL??
  1. AResponseContent:?TStream;??//?返回流??
  2. AIgnoreReplies:?array?of?SmallInt;??//?忽略掉出现这些http状态码的错误??

示例代码:

?
    unit?UMain;??
  1. ??
  2. interface??
  3. uses??
  4. ??Windows,?Messages,?SysUtils,?Variants,?Classes,?Graphics,?Controls,?Forms,??
  5. ??Dialogs,?IdBaseComponent,?IdComponent,?IdTCPConnection,?IdTCPClient,??
  6. ??IdHTTP,?StdCtrls;??
  7. ??
  8. type??
  9. ??TForm1?=?class(TForm)??
  10. ????IdHTTP1:?TIdHTTP;??
  11. ????Memo1:?TMemo;??
  12. ????btnGetOne:?TButton;??
  13. ????btnGetTwo:?TButton;??
  14. ????btnGetThree:?TButton;??
  15. ????btnGetFour:?TButton;??
  16. ????procedure?btnGetOneClick(Sender:?TObject);??
  17. procedure?btnGetTwoClick(Sender:?TObject);??
  18. procedure?btnGetThreeClick(Sender:?TObject);??
  19. procedure?btnGetFourClick(Sender:?TObject);??
  20. ??private??
  21. ????{?Private?declarations?}??
  22. public??
  23. {?Public?declarations?}??
  24. end;??
  25. var??
  26. ??Form1:?TForm1;??
  27. implementation??
  28. {$R?*.dfm}??
  29. const??
  30. ??Cgeturl?=?'http://www.soso.com/';??
  31. ??C302url?=?'http://soso.com/';??
  32. var??
  33. ??RespData?:?TStringStream;??
  34. procedure?TForm1.btnGetOneClick(Sender:?TObject);??
  35. begin??
  36. ??RespData?:=?TStringStream.Create('');??
  37. ??IdHTTP1.Get(Cgeturl,?RespData);??
  38. ??Memo1.Text?:=?RespData.DataString;??
  39. end;??
  40. procedure?TForm1.btnGetTwoClick(Sender:?TObject);??
  41. begin??
  42. '');??
  43. ??IdHTTP1.Get(C302url,?RespData,?[302]);??
  44. ??Memo1.Text?:=?RespData.DataString;??
  45. procedure?TForm1.btnGetThreeClick(Sender:?TObject);??
  46. ??Memo1.Text?:=?IdHTTP1.Get(Cgeturl);??
  47. procedure?TForm1.btnGetFourClick(Sender:?TObject);??
  48. ??Memo1.Text?:=?IdHTTP1.Get(C302url,?[302]);??
  49. end. ?

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读