Bjr à vous,
La fonction TFPHTTPClient.Get() sous Linux ne fonctionne pas (AV)
Aucun problème sous Windows
Franchement pénible ++++
A quand des libs unifiées, testées et avec des exemples ?
Bjr à vous,
La fonction TFPHTTPClient.Get() sous Linux ne fonctionne pas (AV)
Aucun problème sous Windows
Franchement pénible ++++
A quand des libs unifiées, testées et avec des exemples ?
Hello,
Franchement pénible de ne pas avoir d'infos quand il y a un problème.
- Code (en particulier les uses)
- Version de Lazarus
- O.S ( si linux distribution )
- Message d'erreur
Sous linux les bibliothèques nécessaires à faire fonctionner le ssl sont libcrypto et libssl
Ami calmant, J.P
Jurassic computer : Sinclair ZX81 - Zilog Z80A à 3,25 MHz - RAM 1 Ko - ROM 8 Ko
Rhôôôô...
Même si je suis d'accord avec toi, en cherchant un peu, on en trouve : en général, quand j'ai un souci avec un mot-clé, je le google et bien souvent ça mord !
En l'espèce, "TFPHTTPClient.Get() linux" --> https://wiki.lazarus.freepascal.org/fphttpclient et hop !
Il y a plein d'exemples, j'ai testé à la va-vite le program dl_fphttp_d; et j'en suis le premier surpris, sans y avoir fait aucune correction ni retouche, un simple copier/coller dans le squelette de Nouveau projet / Programme simple a fonctionné du premier coup.
Ceci étant dit, je suis entièrement en phase avec la remarque de l'ami J.P
Il a à vivre sa vie comme ça et il est mûr sur ce mur se creusant la tête : peut–être qu'il peut être sûr, etc.
Oui, je milite pour l'orthographe et le respect du trait d'union à l'impératif.
Après avoir posté, relisez-vous ! Et en cas d'erreur ou d'oubli, il existe un bouton « Modifier », à utiliser sans modération
On a des lois pour protéger les remboursements aux faiseurs d’argent. On n’en a pas pour empêcher un être humain de mourir de misère.
Mes 2 cts,
--
jp
Salut
Peut-être lui manque-t-il un point so, l'équivalent d'une dll sous Windows.
Il est difficile de t'aider si nous n'avons pas plus d'info sur la façon dont c'est programmé et le message exact de l'erreur
Blaise PascalNous souhaitons la vérité et nous trouvons qu'incertitude. [...]
Nous sommes incapables de ne pas souhaiter la vérité et le bonheur, et sommes incapables ni de certitude ni de bonheur.
PS : n'oubliez pas le tag
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 function TMyIGNWebService.Get(const UseHTTPS: boolean; const MyUrl: string): string; var QUrl: String; begin QUrl := MyURL; if (UseHTTPS) then QUrl += format(':%d', [HTTPS_PORT]); AfficherMessageErreur(format('-- %s.Get(%s)', [ClassName, QUrl])); result := ''; QUrl := 'https://wxs.ign.fr/essentiels/alti/rest/elevation.xml?lon=-0.02500000&lat=43.08600000&zonly=false:443'; FHTTP.AllowRedirect := True; try try result := FHTTP.Get(QUrl); // OK sous Windows, segfault sous Linux except on E: exception do AfficherMessageErreur(E.Message); end; finally end; end;
Hello,
Cela ne sert à rien de balancer un code sans ce qu'il y a autour ( voir dans mon message précédent les infos demandées en particuliers les uses du code) !
pour voir si les bibliothèques ssl sont présentes sous linux :
Ami calmant, J.P
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3 ldconfig -r | grep crypto ldconfig -r | grep ssl
Jurassic computer : Sinclair ZX81 - Zilog Z80A à 3,25 MHz - RAM 1 Ko - ROM 8 Ko
Yep !
Cela doit dépendre des Linux... Chez moi Debian 11.5,
Au final je ne me fais plus insulter en passant 3 params de plus :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6 $ ldconfig -r | grep crypto ldconfig : l''option requiert un argument -- r Pour en savoir davantage, faites : «ldconfig --help » ou «ldconfig --usage». $ ldconfig -r | grep ssl ldconfig : l''option requiert un argument -- r Pour en savoir davantage, faites : «ldconfig --help » ou «ldconfig --usage».
Mais comme je ne sais pas ce qu'on doit voir, recevoir, etc., je ne dirai rien de plus.
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4 $ ldconfig -rNi . | grep crypto ldconfig: chemin relatif '.' utilisé pour construire le cache $ ldconfig -rNi . | grep ssl ldconfig: chemin relatif '.' utilisé pour construire le cache
Il a à vivre sa vie comme ça et il est mûr sur ce mur se creusant la tête : peut–être qu'il peut être sûr, etc.
Oui, je milite pour l'orthographe et le respect du trait d'union à l'impératif.
Après avoir posté, relisez-vous ! Et en cas d'erreur ou d'oubli, il existe un bouton « Modifier », à utiliser sans modération
On a des lois pour protéger les remboursements aux faiseurs d’argent. On n’en a pas pour empêcher un être humain de mourir de misère.
Mes 2 cts,
--
jp
OS:Linux Mint
Dans le Uses: fphttpclient
Les libs sont dans le dossier de mon application
Les commandes ldconfig spécifiées ne fonctionnent pas chez moi:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5 #ldconfig -r | grep crypto /sbin/ldconfig.real*: l'option requiert un argument -- r Pour en savoir davantage, faites*:*«ldconfig.real --help » ou «ldconfig.real --usage».
sous Ubuntu qui est une debian comme mint il faut utiliser :
ou avec sudo si il y a des problèmes de droits
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2 ldconfig -p | grep crypto ldconfig -p | grep ssl
Jurassic computer : Sinclair ZX81 - Zilog Z80A à 3,25 MHz - RAM 1 Ko - ROM 8 Ko
Retour de ces commandes:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11 ldconfig -p | grep crypto libk5crypto.so.3 (libc6) => /usr/lib/i386-linux-gnu/libk5crypto.so.3 libhcrypto.so.4 (libc6) => /usr/lib/i386-linux-gnu/libhcrypto.so.4 libcrypto.so.1.1 (libc6) => /lib/i386-linux-gnu/libcrypto.so.1.1 libcrypto.so.1.1 (libc6) => /usr/lib/i386-linux-gnu/libcrypto.so.1.1 libcrypto.so.1.1 (libc6) => /usr/local/lib/libcrypto.so.1.1 libcrypto.so.1.0.0 (libc6) => /usr/lib/i386-linux-gnu/libcrypto.so.1.0.0 libcrypto.so (libc6) => /usr/lib/i386-linux-gnu/libcrypto.so libcrypto.so (libc6) => /usr/local/lib/libcrypto.so libbd_crypto.so.2 (libc6) => /usr/lib/i386-linux-gnu/libbd_crypto.so.2
Je n'ai pas de problème avec ce code sous Ubuntu 20.04 Lazarus 2.2 - 64 bits :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14 implementation uses fphttpclient,opensslsockets, {$R *.lfm} { TForm1 } procedure TForm1.Button1Click(Sender: TObject); begin With TFPHttpClient.Create(Nil) do try AllowRedirect := true; Memo1.Text := Get('https://mdn.github.io/beginner-html-site/'); finally Free; end; end;ubuntu$ldconfig -p | grep ssl
libwolfssl.so.24 (libc6,x86-64) => /lib/x86_64-linux-gnu/libwolfssl.so.24
libssl3.so (libc6,x86-64) => /lib/x86_64-linux-gnu/libssl3.so
libssl.so.1.1 (libc6,x86-64) => /lib/x86_64-linux-gnu/libssl.so.1.1
ubuntu$ldconfig -p | grep crypto
libmbedcrypto.so.3 (libc6,x86-64) => /lib/x86_64-linux-gnu/libmbedcrypto.so.3
libk5crypto.so.3 (libc6,x86-64) => /lib/x86_64-linux-gnu/libk5crypto.so.3
libhcrypto.so.4 (libc6,x86-64) => /lib/x86_64-linux-gnu/libhcrypto.so.4
libcrypto.so.1.1 (libc6,x86-64) => /lib/x86_64-linux-gnu/libcrypto.so.1.1
libbd_crypto.so.2 (libc6,x86-64) => /lib/x86_64-linux-gnu/libbd_crypto.so.2
Jurassic computer : Sinclair ZX81 - Zilog Z80A à 3,25 MHz - RAM 1 Ko - ROM 8 Ko
Voilà un bête exemple qui ne fonctionne pas en https mais aucun pb en http:
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 procedure TdlgTestsUnitaires.Button5Click(Sender: TObject); var FHTTPS: TFPHTTPClient; URL, S: String; begin //URL := 'http://www.google.fr'; // Fonctionne URL := 'https://www.google.fr'; // Ne fonctionne pas //URL := 'https://wxs.ign.fr/essentiels/alti/rest/elevation.xml?lon=-0.02500000&lat=43.08600000&zonly=false'; FHTTPS := TFPHttpClient.Create(Nil); try S := FHTTPS.Get(URL); finally FHTTPS.Free; end; Writeln('Content: ', S); end;
on a pas vu ton ldconfig pour le ssl
Jurassic computer : Sinclair ZX81 - Zilog Z80A à 3,25 MHz - RAM 1 Ko - ROM 8 Ko
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 root@jpcassou3-LIFEBOOK-T730:~# ldconfig -p | grep crypto libk5crypto.so.3 (libc6) => /usr/lib/i386-linux-gnu/libk5crypto.so.3 libhcrypto.so.4 (libc6) => /usr/lib/i386-linux-gnu/libhcrypto.so.4 libcrypto.so.1.1 (libc6) => /lib/i386-linux-gnu/libcrypto.so.1.1 libcrypto.so.1.1 (libc6) => /usr/lib/i386-linux-gnu/libcrypto.so.1.1 libcrypto.so.1.1 (libc6) => /usr/local/lib/libcrypto.so.1.1 libcrypto.so.1.0.0 (libc6) => /usr/lib/i386-linux-gnu/libcrypto.so.1.0.0 libcrypto.so (libc6) => /usr/lib/i386-linux-gnu/libcrypto.so libcrypto.so (libc6) => /usr/local/lib/libcrypto.so libbd_crypto.so.2 (libc6) => /usr/lib/i386-linux-gnu/libbd_crypto.so.2 root@jpcassou3-LIFEBOOK-T730:~# ldconfig -p | grep ssl libssl3.so (libc6) => /usr/lib/i386-linux-gnu/libssl3.so libssl.so.1.1 (libc6) => /lib/i386-linux-gnu/libssl.so.1.1 libssl.so.1.1 (libc6) => /usr/lib/i386-linux-gnu/libssl.so.1.1 libssl.so.1.1 (libc6) => /usr/local/lib/libssl.so.1.1 libssl.so.1.0.0 (libc6) => /usr/lib/i386-linux-gnu/libssl.so.1.0.0 libssl.so (libc6) => /usr/lib/i386-linux-gnu/libssl.so libssl.so (libc6) => /usr/local/lib/libssl.so root@jpcassou3-LIFEBOOK-T730:~# ldconfig -p | grep ssl libssl3.so (libc6) => /usr/lib/i386-linux-gnu/libssl3.so libssl.so.1.1 (libc6) => /lib/i386-linux-gnu/libssl.so.1.1 libssl.so.1.1 (libc6) => /usr/lib/i386-linux-gnu/libssl.so.1.1 libssl.so.1.1 (libc6) => /usr/local/lib/libssl.so.1.1 libssl.so.1.0.0 (libc6) => /usr/lib/i386-linux-gnu/libssl.so.1.0.0 libssl.so (libc6) => /usr/lib/i386-linux-gnu/libssl.so libssl.so (libc6) => /usr/local/lib/libssl.so root@jpcassou3-LIFEBOOK-T730:~# cp /usr/local/lib/libssl.so ~/Bureau/0_GHTopoFPC/ root@jpcassou3-LIFEBOOK-T730:~# cp /usr/local/lib/libcrypto.so ~/Bureau/0_GHTopoFPC
Hello,
ton problème vient du fait que tu utilises une version ancienne de Lazarus 2.0.6 qui utilise le fpc 3.0.4 et dans celui-ci la version 1.1 de openssl n'est pas prise en compte. Tu as bien une version 1.0.0 de openssl mais je crois que celle-ci ne gère pas le TLS 1.2 :
Alors comme solution :Les principaux développeurs de navigateurs web ont annoncé mettre fin à leur support de TLS 1.1 et versions précédentes à partir du printemps 2020
1 - changer de version de Lazarus (le SSL fonctionne dans la 2.2)
ou créer un lien symbolique de la dernière version prise en compte dans le fpc 3.0.4 (openssl et cryto 1.0.6) vers la 1.1.
ou changer le fichier openssl.pas dans fpcsrc pour qu'il prenne en compte les version 1.1 et recompiler le fpc.
Ami calmant, J.P
Jurassic computer : Sinclair ZX81 - Zilog Z80A à 3,25 MHz - RAM 1 Ko - ROM 8 Ko
Bjr à vous,
Depuis les changements intervenus dans les services web et REST de l'IGN, beaucoup de problèmes dans l'extraction de données via les nouveaux paramètres fournis par l'IGN
La version de TLS requise est maintenant la 1.2
La requête suivante fonctionne dans un navigateur:
https://data.geopf.fr/altimetrie/1.0...ld&zonly=false
La même requête via TMyIGNWebService, qui contient un objet FHTTP de type TFCLHTTPClient, me retourne un timeout
Pour être poli: franchement pète-couilles
Sortie de cette fonction:
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 function TMyIGNWebService.GetAltitudeByLatLon(const QLat, QLon: double; out QAltitude, QAccuracy: double): boolean; const IGN_DATA_GEOPF_FR = 'data.geopf.fr'; IGN_ALTIMETRIE = 'altimetrie'; IGN_VERSION = '1.0'; IGN_CALCUL = 'calcul'; IGN_RESOURCE = 'ign_rge_alti_wld'; var MyURL, QResponse: String; MyXML: TXMLDocument; LastError: integer; MyStringStream: TStringStream; SectionElevations, MyElevation: TDOMNode; LesElevations, LesAttributs: TDOMNodeList; i, Nb: LongWord; begin // TODO: Sous Linux, installer éventuellement la lib ssl: sudo apt install libssl-dev result := False; LastError := 0; QResponse := ''; QAltitude := -6666; QAccuracy := 0.00; MyXML := Nil; (* Calcul altimétrique /*Obsolete: https://wxs.ign.fr/{cle}/alti/... */ https://data.geopf.fr/altimetrie/resources https://data.geopf.fr/private/altimetrie/resources https://data.geopf.fr/altimetrie/resources //MyURL := Format('https://%s/%s/%s/%s/%s?lon=%.8f&lat=%.8f&zonly=%s', // [IGN_WXS, IGN_KEY, IGN_ALTI, IGN_REST, IGN_ELEVATION, // QLon, QLat, BoolToStr(false, 'true', 'false')]); // view-source:https://data.geopf.fr/altimetrie/1.0/calcul/alti/rest/elevation.xml?lon=1.48&lat=43.54&resource=ign_rge_alti_wld&zonly=false //*) MyURL := Format('https://%s/%s/%s/%s/'+ '%s/%s/%s?lon=%.8f&lat=%.8f&resource=%s&zonly=%s', [IGN_DATA_GEOPF_FR, IGN_ALTIMETRIE, IGN_VERSION, IGN_CALCUL, IGN_ALTI, IGN_REST, IGN_ELEVATION, QLon, QLat, IGN_RESOURCE, BoolToStr(false, 'true', 'false')]); AfficherMessageErreur(MyURL); MyXML := TXMLDocument.Create; try // XML try QResponse := self.Get(True, MyURL); // self.get appelle le FHTTP.Get() en ajoutant ':443' en fin d'URL if (trim(QResponse) = '') then begin QAfficherMessageErreur(Format('Reponse vide: "%s"', [QResponse])); exit(false); end; except on E: Exception do begin LastError := -1; raise; // Redéclenche l'exception pour affichage: dans ce cas, la cause de l'erreur est mise en évidence end; end; if (LastError <> 0) then exit(false); // Création du XML QAfficherMessageErreur('-- Creation du XML'); MyStringStream := TStringStream.Create(QResponse); Try //TStringStream MyStringStream.Position := 0; QAfficherMessageErreur(' -- Parse du XML'); ReadXMLFile(MyXML, MyStringStream); // Document XML complet // Ancien format de réponse (* <elevations> <elevation> <lon>-0.025</lon> <lat>43.086</lat> <z>554.11</z> <acc>2.5</acc> </elevation> </elevations> //*) // Nouveau format: (* <elevations> <elevation> <lon>1.48</lon> <lat>43.54</lat> <z>164.34</z> <acc>Variable suivant la source de mesure</acc> </elevation> </elevations> //*) Finally FreeAndNil(MyStringStream); end; // TStringStream QAfficherMessageErreur(' -- Extraction des data'); SectionElevations := MyXML.FindNode(XML_IGN_SECTION_ELEVATIONS); QAfficherMessageErreur('---- 01: ' + SectionElevations.NodeName); if (SectionElevations <> Nil) then begin LesElevations := SectionElevations.ChildNodes; Nb := LesElevations.Count; QAfficherMessageErreur(format('-- Section [%s] trouvee: %d items', [XML_IGN_SECTION_ELEVATIONS, Nb])); if (Nb > 0) then begin for i := 0 to Nb - 1 do begin MyElevation := LesElevations.Item[i]; // attributs de la forme <key>value</key> = ce sont des noeuds if (XML_IGN_ELEVATION_ITEM = MyElevation.NodeName) then begin LesAttributs := MyElevation.ChildNodes; QAfficherMessageErreur(format('%d attributs', [LesAttributs.Count])); QAltitude := ConvertirEnNombreReel(LesAttributs.Item[2].TextContent, 0.00); // Attr: 2: z = 554.11 QAccuracy := ConvertirEnNombreReel(LesAttributs.Item[3].TextContent, 0.00); // Attr: 3: acc = 2.5 end; end; end; end; Result := true; finally // XML FreeAndNil(MyXML); end; end;
Code de tgfclhttpclientbroker, qui remplace l'unité foireuse TFpHTTPCLient
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5 17:05:08 | TMyIGNWebService.Get(): https://data.geopf.fr/altimetrie/1.0/calcul/alti/rest/elevation.xml?lon=-0.41449998&lat=44.71568003&resource=ign_rge_alti_wld&zonly=false https://data.geopf.fr/altimetrie/1.0/calcul/alti/rest/elevation.xml?lon=-0.41449998&lat=44.71568003&resource=ign_rge_alti_wld&zonly=false Connection to data.geopf.fr:443 timed out. HTTPSService: Reponse vide: ""
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.
Salut
C'est plus dans le SSL qu'il faut chercher
justement ce fameux TLS ... Effectivement toutes ces sécurité sont un casse tête
Blaise PascalNous souhaitons la vérité et nous trouvons qu'incertitude. [...]
Nous sommes incapables de ne pas souhaiter la vérité et le bonheur, et sommes incapables ni de certitude ni de bonheur.
PS : n'oubliez pas le tag
Tellement casse-pieds que ces sécurités sont désactivées. Et pas que dans l'informatique.
Le cas-type de sécurité illusoire est le frein de chariot sur les téléphériques, qui expose à des dangers plus graves et surtout plus probables:
* Déraillement de cabine au droit d'un pylône (Télémétro)
* Désengagement de câbles porteurs suite à un déclenchement intempestif (Cauterets), avec en prime le déraillement complet des deux câbles de traction
* Un frein de chariot ne retient pas une cabine chargée au-delà de 70% de pente
Téléphérique du Pic de Bure: Le frein de chariot déclenchait sans arrêt et à l'opposé, ne fonctionnait pas dans certaines circonstances. Retiré en 1994. On connaît le désastre de 1999: 20 morts
Téléphérique Stresa-Alpino-Mottarone: Le frein de chariot déclenchait sans arrêt et les effets dynamiques ont fragilisé les attaches du câble tracteur. Neutralisé, bilan: 14 morts en 2021
Avec les nouvelles configurations IGN:
En GET, c'est OK maintenant (traitement de points individuels)
Le service WPS n'est plus disponible, donc on passe maintenant par POST. C'est plus facile effectivement, mais IGN ne documente pas l'envoi de séries de points. Donc: bloqué. L'intérêt du POST est d'envoyer de nombreux points dans une seule requête
https://geoservices.ign.fr/documenta...timetrie#72673
Vous avez un bloqueur de publicités installé.
Le Club Developpez.com n'affiche que des publicités IT, discrètes et non intrusives.
Afin que nous puissions continuer à vous fournir gratuitement du contenu de qualité, merci de nous soutenir en désactivant votre bloqueur de publicités sur Developpez.com.
Partager