IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

Lazarus Pascal Discussion :

TFPHttpClient : méthode get() ne fonctionne pas sous Linux. Irritant [Lazarus]


Sujet :

Lazarus Pascal

  1. #1
    Membre confirmé

    Homme Profil pro
    Développeur informatique
    Inscrit en
    Novembre 2013
    Messages
    346
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Gironde (Aquitaine)

    Informations professionnelles :
    Activité : Développeur informatique
    Secteur : Administration - Collectivité locale

    Informations forums :
    Inscription : Novembre 2013
    Messages : 346
    Points : 538
    Points
    538
    Billets dans le blog
    2
    Par défaut TFPHttpClient : méthode get() ne fonctionne pas sous Linux. Irritant
    Bsr à tous,

    Mon application doit interroger un serveur de l'IGN en utilisant TFPHTTPClient.

    Sous Windows,aucun problème

    Sous Linux, AV au droit de TFPHTTPClient;Get()

    J'ai mis à jour les libssl et consorts

    Agaçant +++ ces outils fondamentaux insuffisamment testés, et consommateurs de temps.

    Linux Mint 19

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
     
     
    function TMyIGNWebService.Get(const UseHTTPS: boolean; const MyUrl: string): string;
    var
      QUrl: String;
      {$IFDEF LINUX}
      LS: TStringList;
      {$ENDIF LINUX}
    begin
      QUrl := MyURL;
      //if (UseHTTPS) then QUrl += format(':%d', [HTTPS_PORT]);
      //https://wxs.ign.fr/essentiels/alti/rest/elevation.xml?lon=-0.02500000&lat=43.08600000&zonly=false
      AfficherMessageErreur('-- %s.Get(%s)', [ClassName, QUrl]);
      result := '';
      {$IFDEF MSWINDOWS}
      try
        result := FHTTP.Get(QUrl);  // OK sous Windows, segfault sous Linux
      except
        on E: exception do AfficherMessageErreur(E.Message);
      end;
      {$ENDIF MSWINDOWS}
     
      {$IFDEF LINUX}
      AfficherMessageErreur('0044');
      LS := TStringList.Create;
      try
        try
          FHTTP.Get(QUrl, LS);
          result := LS.Text;
        except
          on E: exception do AfficherMessageErreur(E.Message);
        end;
      finally
        FreeandNil(LS);
      end;
      {$ENDIF LINUX}
     
    end;

  2. #2
    Expert éminent
    Avatar de jurassic pork
    Homme Profil pro
    Bidouilleur
    Inscrit en
    Décembre 2008
    Messages
    3 958
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations professionnelles :
    Activité : Bidouilleur
    Secteur : Industrie

    Informations forums :
    Inscription : Décembre 2008
    Messages : 3 958
    Points : 9 298
    Points
    9 298
    Par défaut
    Hello,
    Citation Envoyé par JP CASSOU Voir le message
    [FPHttpClient : méthode get() ne fonctionne pas sous Linux. Irritant
    Agaçant +++ ces outils fondamentaux insuffisamment testés, et consommateurs de temps.
    On ne lance pas de telles affirmations sans demander car Linux ce n'est pas que Linux Mint 19
    Moi je n'ai pas de soucis avec ce code sous Ubuntu 20.04 Lazarus 2.2 :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    implementation
    uses fphttpclient,opensslsockets;
    {$R *.lfm}
    { TForm1 }
    procedure TForm1.Button1Click(Sender: TObject);
    var S : String;
     begin
      With TFPHttpClient.Create(Nil) do
        try
          AllowRedirect := true;
    //      S :=  Get('https://mdn.github.io/beginner-html-site/');
          S:= Get('https://wxs.ign.fr/essentiels/alti/rest/elevation.xml?lon=-0.02500000&lat=43.08600000&zonly=false');
          Memo1.Append(S);
        finally
          Free;
        end;
      end;
    Nom : httpsIGN.gif
Affichages : 149
Taille : 42,0 Ko

    Et puis quand il y a un problème, on explique clairement ce qui ne fonctionne pas et les messages d'erreurs qui apparaissent et à quel endroit. On fournit aussi un code complet et pas seulement un bout de code. On dit ce qui est est installé (version de Lazarus, version des librairies soupçonnées de ne pas fonctionner). une piste : les certificats.

    Agaçant ces gens qui critiquent parce qu'ils ne savent pas paramétrer leur O.S

    Ami calmant, J.P
    Jurassic computer : Sinclair ZX81 - Zilog Z80A à 3,25 MHz - RAM 1 Ko - ROM 8 Ko

  3. #3
    Membre confirmé

    Homme Profil pro
    Développeur informatique
    Inscrit en
    Novembre 2013
    Messages
    346
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Gironde (Aquitaine)

    Informations professionnelles :
    Activité : Développeur informatique
    Secteur : Administration - Collectivité locale

    Informations forums :
    Inscription : Novembre 2013
    Messages : 346
    Points : 538
    Points
    538
    Billets dans le blog
    2
    Par défaut Problème résolu avec ces unités tgbasehttpclient et tgfclhttpclientbroker.
    Problème résolu avec ces unités tgbasehttpclient et tgfclhttpclientbroker, disponibles sur https://github.com/Al-Muhandis/fp-telegram

    Note: TBaseHTTPClient s'utilise exactement comme TFpHTTPClient

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
     
    // Remplace la classe TFpHTTPCLient
    // OK pour Windows et Linux
    // Unité de petite taille = on la met dans le dossier de mes applis
     
     
    unit tgbasehttpclient;
     
    {$mode objfpc}{$H+}
     
    interface
     
    uses
      Classes, SysUtils;
     
    type
     
      EHTTPClient = class(Exception);
     
      TBaseClientClass = class of TBaseHTTPClient;
     
      { TBaseHTTPClient }
     
      TBaseHTTPClient=class(TComponent)
      private
        FUserAgent: String;
      protected
        function GetAllowRedirect: Boolean; virtual; abstract;
        function GetCookies: TStrings; virtual; abstract;
        function GetHTTPProxyHost: String; virtual; abstract;
        function GetHTTPProxyPassword: String; virtual; abstract;
        function GetHTTPProxyPort: Word; virtual; abstract;
        function GetHTTPProxyUsername: String; virtual; abstract;
        function GetInternalHTTPClient: TObject; virtual; abstract;
        function GetRequestBody: TStream; virtual; abstract;
        function GetRequestHeaders: TStrings; virtual; abstract;
        function GetResponseHeaders: TStrings; virtual; abstract;
        function GetResponseStatusCode: Integer; virtual; abstract;
        function GetResponseStatusText: String; virtual; abstract;
        function GetIOTimeout: Integer; virtual; abstract;
        procedure SetAllowRedirect(AValue: Boolean); virtual; abstract;
        procedure SetCookies(AValue: TStrings); virtual; abstract;
        procedure SetHTTPProxyHost(AValue: String); virtual; abstract;
        procedure SetHTTPProxyPassword(AValue: String); virtual; abstract;
        procedure SetHTTPProxyPort(AValue: Word); virtual; abstract;
        procedure SetHTTPProxyUsername(AValue: String); virtual; abstract;
        procedure SetRequestBody(AValue: TStream); virtual; abstract;
        procedure SetRequestHeaders(AValue: TStrings); virtual; abstract;
        procedure SetIOTimeout(AValue: Integer); virtual; abstract;
      public
        procedure AddHeader(Const AHeader,AValue : String); virtual; abstract;
        class function EncodeUrlElement(S: String): String; virtual; abstract;
        procedure FileFormPost(const AURL: string; FormData: TStrings; AFieldName, AFileName: string;
          const Response: TStream); virtual; abstract;
        function FilesFormPost(const AURL: string; FormData: TStrings; const AFiles: TStrings): String; virtual; abstract;
        function FormPost(const URL: string; FormData : TStrings): String; virtual; abstract;
        function Get(const AUrl: String): String; virtual; abstract;
        function Post(const URL: string) : String; virtual; abstract;
        procedure StreamFormPost(const AURL: string; FormData: TStrings;
          const AFieldName, AFileName: string; const AStream: TStream;
          const Response: TStream); virtual; abstract;
        class function GetClientClass: TBaseClientClass;
        class procedure RegisterClientClass;
        class procedure UnregisterClientClass;
        property AllowRedirect: Boolean read GetAllowRedirect write SetAllowRedirect;
        property Cookies: TStrings read GetCookies write SetCookies;
        property RequestBody: TStream read GetRequestBody write SetRequestBody;
        property RequestHeaders: TStrings read GetRequestHeaders write SetRequestHeaders;
        property ResponseHeaders: TStrings read GetResponseHeaders;
        property ResponseStatusCode: Integer read GetResponseStatusCode;
        property ResponseStatusText: String read GetResponseStatusText;
        property HTTPProxyHost: String read GetHTTPProxyHost write SetHTTPProxyHost;
        property HTTPProxyPort: Word read GetHTTPProxyPort write SetHTTPProxyPort;
        property HTTPProxyUsername: String read GetHTTPProxyUsername write SetHTTPProxyUsername;
        property HTTPProxyPassword: String read GetHTTPProxyPassword write SetHTTPProxyPassword;
        Property IOTimeout : Integer read GetIOTimeout write SetIOTimeout;
        property InternalHTTPClient: TObject read GetInternalHTTPClient;
        property UserAgent: String read FUserAgent write FUserAgent;
      end;
     
    implementation
     
    var
      _BaseHTTPClientClass: TBaseClientClass = nil;
     
    { TBaseHTTPClient }
     
    class procedure TBaseHTTPClient.RegisterClientClass;
    begin
      if Assigned(_BaseHTTPClientClass) then
        raise EHTTPClient.Create('HTTP client class already registered!');
      _BaseHTTPClientClass := Self;
    end;
     
    class procedure TBaseHTTPClient.UnregisterClientClass;
    begin
      _BaseHTTPClientClass := nil;
    end;
     
    class function TBaseHTTPClient.GetClientClass: TBaseClientClass;
    begin
      if not Assigned(_BaseHTTPClientClass) then
        raise EHTTPClient.Create('No HTTP client class registered! Please use RegisterClientClass procedure');
      Result:=_BaseHTTPClientClass;
    end;
     
    end.
    et tgfclhttpclientbroker:
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
    177
    178
    179
    180
    181
    182
    183
    184
    185
    186
    187
    188
    189
    190
    191
    192
    193
    194
    195
    196
    197
    198
    199
    200
    201
    202
    203
    204
    205
    206
    207
    208
    209
    210
    211
    212
    213
    214
    215
    216
    217
    218
    219
    220
    221
    222
    223
    224
    225
    226
    227
    228
    229
    230
    231
    232
    233
    234
    235
    236
    237
    238
    239
    240
    241
    242
    243
    244
    245
    246
    247
    248
    249
    250
    251
    252
    253
    254
    255
    256
    257
    258
    259
    260
    261
    262
    263
    264
    265
    266
    267
    268
    269
    270
    271
    272
    273
    274
    275
    276
    277
    278
    279
    280
    281
    282
    283
    284
    285
    286
    287
    288
    289
    290
    291
    292
    293
    294
    295
    296
    297
    298
    299
    300
    301
    302
    303
    304
    305
    306
    307
    308
    309
    310
    311
    312
    313
    314
    315
    316
    317
    318
    319
    320
    321
    322
    323
    324
    325
    326
    327
    328
    329
    330
    331
    332
    333
    334
    335
    336
    337
    338
    339
    340
    341
    342
    343
    344
    345
    346
    347
    348
    349
    350
    351
    352
    353
    354
    355
    356
    357
    358
    359
    360
    361
    362
    363
    364
    365
    366
    367
    368
    369
    370
     
    // Remplace la classe TFpHTTPCLient
    // OK pour Windows et Linux
    // Unité de petite taille = on la met dans le dossier de mes applis
     
    unit tgfclhttpclientbroker;
     
    {$mode objfpc}{$H+}
     
    interface
     
    {$IF FPC_FULLVERSION < 30200}{$DEFINE ExplSSL}{$else}{$DEFINE SSLOpenSockets}{$ENDIF}
     
    uses
      Classes, SysUtils{$IFDEF ExplSSL}, ssockets{$ENDIF}, tgbasehttpclient, fphttpclient;
     
    type
     
      { TFCLHTTPClient }
     
      TFCLHTTPClient=class(TBaseHTTPClient)
      private
        FHTTPClient: TFPHTTPClient;
        procedure PrepareHeaders;   {$IFDEF ExplSSL}
        procedure HttpClientGetSocketHandler(Sender: TObject; const {%H-}UseSSL: Boolean;
          out {%H-}AHandler: TSocketHandler);{$ENDIF}
      protected
        function GetAllowRedirect: Boolean; override;
        function GetCookies: TStrings; override;
        function GetHTTPProxyHost: String; override;
        function GetHTTPProxyPassword: String; override;
        function GetHTTPProxyPort: Word; override;
        function GetHTTPProxyUsername: String; override;
        function GetInternalHTTPClient: TObject; override;
        function GetIOTimeout: Integer; override;
        function GetRequestBody: TStream; override;
        function GetRequestHeaders: TStrings; override;
        function GetResponseHeaders: TStrings; override;
        function GetResponseStatusCode: Integer; override;
        function GetResponseStatusText: String; override;
        procedure SetAllowRedirect(AValue: Boolean); override;
        procedure SetCookies(AValue: TStrings); override;
        procedure SetHTTPProxyHost(AValue: String); override;
        procedure SetHTTPProxyPassword(AValue: String); override;
        procedure SetHTTPProxyPort(AValue: Word); override;
        procedure SetHTTPProxyUsername(AValue: String); override;
        procedure SetIOTimeout(AValue: Integer); override;
        procedure SetRequestBody(AValue: TStream); override;
        procedure SetRequestHeaders(AValue: TStrings); override;
      public
        procedure AddHeader(const AHeader, AValue: String); override;
        constructor Create(AOwner: TComponent); override;
        destructor Destroy; override;
        class function EncodeUrlElement(S: String): String; override;
        procedure FileFormPost(const AURL: string; FormData: TStrings; AFieldName, AFileName: string;
          const Response: TStream); override;
        function FilesFormPost(const AURL: string; FormData: TStrings; const AFiles: TStrings): String; override;
        function FormPost(const URL: string; FormData: TStrings): String; override;
        function Get(const AUrl: String): String; override;
        function Post(const URL: string): String; override;
        procedure StreamFormPost(const AURL: string; FormData: TStrings; const AFieldName,
          AFileName: string; const AStream: TStream; const Response: TStream); override;
      end;
     
    {$IF FPC_FULLVERSION <= 30004}
    { TRawByteStringStream }
     
      TRawByteStringStream = Class(TBytesStream)
      public
        Constructor Create (const aData : RawByteString); overload;
        function DataString: RawByteString;
     
        function ReadString(Count: Longint): RawByteString;
        procedure WriteString(const AString: RawByteString);
      end;
    {$ENDIF}
     
    implementation
     
    uses
      {$IFDEF ExplSSL}sslsockets, fpopenssl{$ENDIF}
      {$IFDEF SSLOpenSockets}opensslsockets{$endif}
      ;
     
    Const
      CRLF = #13#10;
     
    {$IF FPC_FULLVERSION <= 30004}
    { TRawByteStringStream }
     
    constructor TRawByteStringStream.Create(const aData: RawByteString);
    begin
      Inherited Create;
      If Length(aData)>0 then
        begin
        WriteBuffer(aData[1],Length(aData));
        Position:=0;
        end;
    end;
     
    function TRawByteStringStream.DataString: RawByteString;
    begin
      Result:='';
      SetLength(Result,Size);
      if Size>0 then
        Move(Memory^, Result[1], Size);
    end;
     
    function TRawByteStringStream.ReadString(Count: Longint): RawByteString;
    Var
      NewLen : Longint;
     
    begin
      NewLen:=Size-Position;
      If NewLen>Count then NewLen:=Count;
      Result:='';
      if NewLen>0 then
        begin
        SetLength(Result, NewLen);
        Move(Bytes[Position],Result[1],NewLen);
        Position:=Position+Newlen;
        end;
    end;
     
    procedure TRawByteStringStream.WriteString(const AString: RawByteString);
    begin
      if Length(AString)>0 then
        WriteBuffer(AString[1],Length(AString));
    end;
    {$ENDIF}
     
    { TFCLHTTPClient }
     
    function TFCLHTTPClient.FilesFormPost(const AURL: string; FormData: TStrings; const AFiles: TStrings): String;
    Var
      S, Sep : string;
      SS : TRawByteStringStream;
      I: Integer;
      N,V, aFieldName, aFileName: String;
      F: TFileStream;
    begin
      Sep:=Format('%.8x_multipart_boundary',[Random($ffffff)]);
      AddHeader('Content-Type','multipart/form-data; boundary='+Sep);
      SS:=TRawByteStringStream.Create();
      try
        if (FormData<>Nil) then
          for I:=0 to FormData.Count -1 do
            begin
            // not url encoded
            FormData.GetNameValue(I,N,V);
            S :='--'+Sep+CRLF;
            S:=S+Format('Content-Disposition: form-data; name="%s"'+CRLF+CRLF+'%s'+CRLF,[N, V]);
            SS.WriteBuffer(S[1],Length(S));
            end;
        if (AFiles<>Nil) then
          for I:=0 to AFiles.Count-1 do
            begin
              AFiles.GetNameValue(I,aFieldName,aFileName);
              S:='--'+Sep+CRLF;
              s:=s+Format('Content-Disposition: form-data; name="%s"; filename="%s"'+CRLF,
                [aFieldName,ExtractFileName(aFileName)]);
              s:=s+'Content-Type: application/octet-string'+CRLF+CRLF;
              SS.WriteBuffer(S[1],Length(S));
              F:=TFileStream.Create(aFileName,fmOpenRead or fmShareDenyWrite);
              try
                F.Seek(0, soFromBeginning);
                SS.CopyFrom(F,F.Size);
                S:=CRLF;
                SS.WriteBuffer(S[1],Length(S));
              finally
                F.Free;
              end;
            end;
     
        S:='--'+Sep+'--'+CRLF;
        SS.WriteBuffer(S[1],Length(S));
        SS.Position:=0;
        RequestBody:=SS;
        Result:=Post(AURL);
      finally
        RequestBody:=Nil;
        SS.Free;
      end;
    end;
     
    procedure TFCLHTTPClient.PrepareHeaders;
    begin
      FHTTPClient.AddHeader('User-Agent', UserAgent);
    end;
    {$IFDEF ExplSSL}
    procedure TFCLHTTPClient.HttpClientGetSocketHandler(Sender: TObject;
      const UseSSL: Boolean; out AHandler: TSocketHandler);
    begin
      {$IFDEF LINUX}
        if UseSSL then begin
          AHandler:=TSSLSocketHandler.Create;
          TSSLSocketHandler(AHandler).SSLType:=stTLSv1_2;  // <--
        end;
      {$ENDIF}
    end;
    {$ENDIF}
    function TFCLHTTPClient.GetAllowRedirect: Boolean;
    begin
      Result:=FHTTPClient.AllowRedirect;
    end;
     
    function TFCLHTTPClient.GetCookies: TStrings;
    begin
      Result:=FHTTPClient.Cookies;
    end;
     
    function TFCLHTTPClient.GetHTTPProxyHost: String;
    begin
      Result:=FHTTPClient.Proxy.Host;
    end;
     
    function TFCLHTTPClient.GetHTTPProxyPassword: String;
    begin
      Result:=FHTTPClient.Proxy.Password;
    end;
     
    function TFCLHTTPClient.GetHTTPProxyPort: Word;
    begin
      Result:=FHTTPClient.Proxy.Port;
    end;
     
    function TFCLHTTPClient.GetHTTPProxyUsername: String;
    begin
      Result:=FHTTPClient.Proxy.UserName;
    end;
     
    function TFCLHTTPClient.GetInternalHTTPClient: TObject;
    begin
      Result:=FHTTPClient;
    end;
     
    function TFCLHTTPClient.GetIOTimeout: Integer;
    begin
      Result:=FHTTPClient.IOTimeout;
    end;
     
    function TFCLHTTPClient.GetRequestBody: TStream;
    begin
      Result:=FHTTPClient.RequestBody;
    end;
     
    function TFCLHTTPClient.GetRequestHeaders: TStrings;
    begin
      Result:=FHTTPClient.RequestHeaders;
    end;
     
    function TFCLHTTPClient.GetResponseHeaders: TStrings;
    begin
      Result:=FHTTPClient.ResponseHeaders;
    end;
     
    function TFCLHTTPClient.GetResponseStatusCode: Integer;
    begin
      Result:=FHTTPClient.ResponseStatusCode;
    end;
     
    function TFCLHTTPClient.GetResponseStatusText: String;
    begin
      Result:=FHTTPClient.ResponseStatusText;
    end;
     
    procedure TFCLHTTPClient.SetAllowRedirect(AValue: Boolean);
    begin
      FHTTPClient.AllowRedirect:=AValue;
    end;
     
    procedure TFCLHTTPClient.SetCookies(AValue: TStrings);
    begin
      FHTTPClient.Cookies:=AValue;
    end;
     
    procedure TFCLHTTPClient.SetHTTPProxyHost(AValue: String);
    begin
      FHTTPClient.Proxy.Host:=AValue;
    end;
     
    procedure TFCLHTTPClient.SetHTTPProxyPassword(AValue: String);
    begin
      FHTTPClient.Proxy.Password:=AValue;
    end;
     
    procedure TFCLHTTPClient.SetHTTPProxyPort(AValue: Word);
    begin
      FHTTPClient.Proxy.Port:=AValue;
    end;
     
    procedure TFCLHTTPClient.SetHTTPProxyUsername(AValue: String);
    begin
      FHTTPClient.Proxy.UserName:=AValue;
    end;
     
    procedure TFCLHTTPClient.SetIOTimeout(AValue: Integer);
    begin
      FHTTPClient.IOTimeout:=AValue;
    end;
     
    procedure TFCLHTTPClient.SetRequestBody(AValue: TStream);
    begin
      FHTTPClient.RequestBody:=AValue;
    end;
     
    procedure TFCLHTTPClient.SetRequestHeaders(AValue: TStrings);
    begin
      FHTTPClient.RequestHeaders:=AValue;
    end;
     
    procedure TFCLHTTPClient.AddHeader(const AHeader, AValue: String);
    begin
      FHTTPClient.AddHeader(AHeader, AValue);
    end;
     
    constructor TFCLHTTPClient.Create(AOwner: TComponent);
    begin
      inherited Create(AOwner);
      FHTTPClient:=TFPHTTPClient.Create(AOwner);
      {$IFDEF ExplSSL}FHTTPClient.OnGetSocketHandler:=@HttpClientGetSocketHandler;{$ENDIF}
    end;
     
    destructor TFCLHTTPClient.Destroy;
    begin
      FreeAndNil(FHTTPClient);
      inherited Destroy;
    end;
     
    class function TFCLHTTPClient.EncodeUrlElement(S: String): String;
    begin
      Result:=fphttpclient.EncodeURLElement(S);
    end;
     
    procedure TFCLHTTPClient.FileFormPost(const AURL: string; FormData: TStrings; AFieldName,
      AFileName: string; const Response: TStream);
    begin
      FHTTPClient.FileFormPost(AURL, FormData, AFieldName, AFileName, Response);
    end;
     
    function TFCLHTTPClient.FormPost(const URL: string; FormData: TStrings
      ): String;
    begin
      PrepareHeaders;
      Result:=FHTTPClient.FormPost(URL, FormData);
    end;
     
    function TFCLHTTPClient.Get(const AUrl: String): String;
    begin
      PrepareHeaders;
      Result:=FHTTPClient.Get(AUrl);
    end;
     
    function TFCLHTTPClient.Post(const URL: string): String;
    begin
      PrepareHeaders;
      Result:=FHTTPClient.Post(URL);
    end;
     
    procedure TFCLHTTPClient.StreamFormPost(const AURL: string; FormData: TStrings; const AFieldName,
      AFileName: string; const AStream: TStream; const Response: TStream);
    begin
      FHTTPClient.StreamFormPost(AURL, FormData, AFieldName, AFileName, AStream, Response);
    end;
     
    initialization
      TFCLHTTPClient.UnregisterClientClass;
      TFCLHTTPClient.RegisterClientClass;
     
    end.

  4. #4
    Expert éminent
    Avatar de jurassic pork
    Homme Profil pro
    Bidouilleur
    Inscrit en
    Décembre 2008
    Messages
    3 958
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations professionnelles :
    Activité : Bidouilleur
    Secteur : Industrie

    Informations forums :
    Inscription : Décembre 2008
    Messages : 3 958
    Points : 9 298
    Points
    9 298
    Par défaut
    je rappelle qu'il y avait déja eu cette discussion tfphttpclient-ssl-sous-linux-ne-fonctionne traitant de la même chose et c'est la version de Lazarus et de fpc qui étaient en cause. D'ailleurs au début du fichier tgfclhttpclientbroker il y a :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    {$IF FPC_FULLVERSION < 30200}{$DEFINE ExplSSL}{$else}{$DEFINE SSLOpenSockets}{$ENDIF}
     
     
    uses
      Classes, SysUtils{$IFDEF ExplSSL}, ssockets{$ENDIF}, tgbasehttpclient, fphttpclient;
    Jurassic computer : Sinclair ZX81 - Zilog Z80A à 3,25 MHz - RAM 1 Ko - ROM 8 Ko

+ Répondre à la discussion
Cette discussion est résolue.

Discussions similaires

  1. Réponses: 0
    Dernier message: 20/06/2022, 13h44
  2. ssh sans mot de passe ne fonctionne pas sous linux debian
    Par michel.semal dans le forum Sécurité
    Réponses: 18
    Dernier message: 01/12/2021, 14h34
  3. [Prob] code qui fonctionne sous windows mais pas sous linux
    Par hannibal.76 dans le forum Multimédia
    Réponses: 3
    Dernier message: 07/02/2011, 17h46
  4. Mon fichier gtkrc fonctionne sous windows mais pas sous Linux !
    Par Kicker dans le forum GTK+ avec C & C++
    Réponses: 2
    Dernier message: 24/04/2009, 12h54
  5. Réponses: 15
    Dernier message: 01/05/2007, 00h54

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo