-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathHTTPClientSocket.xojo_code
776 lines (702 loc) · 21.8 KB
/
HTTPClientSocket.xojo_code
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
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
#tag Class
Protected Class HTTPClientSocket
#tag Method, Flags = &h0
Shared Function BuildQueryString(FormData As Dictionary) As String
#if XojoVersion >= 2019.02
Var Parts() As String
If (FormData Is Nil) = False Then
For Each Entry As DictionaryEntry In FormData
Parts.AddRow(EncodeURLComponent(Entry.Key.StringValue) + "=" + EncodeURLComponent(Entry.Value.StringValue))
Next
End If
Return String.FromArray(Parts, "&")
#else
Dim Parts() As String
If (FormData Is Nil) = False Then
Dim Keys() As Variant = FormData.Keys
For Each Key As Variant In Keys
Parts.Append(EncodeURLComponent(Key.StringValue) + "=" + EncodeURLComponent(FormData.Value(Key).StringValue))
Next
End If
Return Join(Parts, "&")
#endif
End Function
#tag EndMethod
#tag Method, Flags = &h0
Sub ClearRequestHeaders()
Self.mRequestHeaders = New Dictionary
End Sub
#tag EndMethod
#tag Method, Flags = &h0
Sub Constructor()
Self.mSocket = New CURLSMBS
Call Self.mSocket.UseSystemCertificates
Self.mSocket.YieldTime = True
Self.mSocket.OptionSSLVerifyHost = 2
Self.mSocket.OptionSSLVerifyPeer = 1
Self.mSocket.OptionSSLVersion = CURLSMBS.kSSLVersionTLSv10
Self.mSocket.OptionFollowLocation = True
Self.mSocket.OptionMaxRedirs = 10
Self.mSocket.OptionTransferEncoding = True
Self.mSocket.OptionAcceptEncoding = "gzip, deflate, identity"
AddHandler mSocket.Header, WeakAddressOf mSocket_Header
AddHandler mSocket.Progress, WeakAddressOf mSocket_Progress
Self.mWorkerThread = New Thread
AddHandler mWorkerThread.Run, WeakAddressOf mWorkerThread_Run
#if XojoVersion >= 2019.02
AddHandler mWorkerThread.UserInterfaceUpdate, WeakAddressOf mWorkerThread_UserInterfaceUpdate
#endif
Self.mRequestHeaders = New Dictionary
Self.mResponseHeaders = New Dictionary
#if XojoVersion < 2019.02
Self.mUpdateTimer = New Timer
Self.mUpdateTimer.Period = 20
Self.mUpdateTimer.Mode = Timer.ModeOff
AddHandler mUpdateTimer.Action, WeakAddressOf mUpdateTimer_Action
#endif
End Sub
#tag EndMethod
#tag Method, Flags = &h0
Sub Destructor()
Self.mSocket.Cancel = True
RemoveHandler mSocket.Header, WeakAddressOf mSocket_Header
RemoveHandler mSocket.Progress, WeakAddressOf mSocket_Progress
RemoveHandler mWorkerThread.Run, WeakAddressOf mWorkerThread_Run
#if XojoVersion >= 2019.02
RemoveHandler mWorkerThread.UserInterfaceUpdate, WeakAddressOf mWorkerThread_UserInterfaceUpdate
#else
RemoveHandler mUpdateTimer.Action, WeakAddressOf mUpdateTimer_Action
#endif
End Sub
#tag EndMethod
#tag Method, Flags = &h0
Sub Disconnect()
Self.mSocket.Cancel = True
End Sub
#tag EndMethod
#tag Method, Flags = &h0
Sub Get(URL As String)
Call Self.Send("GET", URL, Nil, -1)
End Sub
#tag EndMethod
#tag Method, Flags = &h0
Function Get(URL As String, Timeout As Integer) As String
Return Self.Send("GET", URL, Nil, Timeout)
End Function
#tag EndMethod
#tag Method, Flags = &h21
Private Sub HandleUpdateDictionary(Dict As Dictionary)
Dim EventName As String = Dict.Lookup("Event", "")
Select Case EventName
Case "Finished"
Dim ByteCount As Int64 = Self.mSocket.GetInfoContentLengthDownload
RaiseEvent ReceivingProgressed(ByteCount, ByteCount, "")
If Self.mSaveToFile <> Nil Then
RaiseEvent FileReceived(Dict.Value("URL"), Dict.Value("HTTPStatus"), Self.mSaveToFile)
Else
RaiseEvent ContentReceived(Dict.Value("URL"), Dict.Value("HTTPStatus"), Dict.Value("Content"))
End If
Case "HeadersReceived"
RaiseEvent HeadersReceived(Dict.Value("URL"), Dict.Value("HTTPStatus"))
Case "AuthenticationRequested"
Dim Username, Password As String
Dim Handled As Boolean = AuthenticationRequested(Dict.Value("Realm"), Username, Password)
If Handled Then
Self.mSocket.OptionUsername = Username
Self.mSocket.OptionPassword = Password
Self.mSocket.OptionHTTPAuth = Dict.Value("Type")
Self.mResponseHeaders = New Dictionary
#if XojoVersion >= 2019.02
Self.mWorkerThread.Start
#else
Self.mWorkerThread.Run
#endif
End If
Case "Error"
RaiseEvent Error(Dict.Value("Err"))
Case "ReceivingProgressed"
RaiseEvent ReceivingProgressed(Dict.Value("ReceivedBytes"), Dict.Value("TotalBytes"), "")
Case "SendingProgressed"
RaiseEvent SendingProgressed(Dict.Value("SentBytes"), Dict.Value("TotalBytes"))
End Select
End Sub
#tag EndMethod
#tag Method, Flags = &h21
Private Function mSocket_Header(Sender As CURLSMBS, Data As String, DataSize As Integer) As Integer
If Data = Encodings.ASCII.Chr(13) + Encodings.ASCII.Chr(10) Then
If Self.HTTPStatusCode = 401 Then
Dim Auth As String = Self.mResponseHeaders.Lookup("WWW-Authenticate", "")
Dim Realm As String
#if XojoVersion >= 2019.02
Dim RealmStart As Integer = Auth.IndexOf(" realm=")
If RealmStart > -1 Then
Realm = Auth.Middle(RealmStart + 7)
If Realm.Left(1) = """" Then
Realm = Realm.Middle(1)
Dim RealmEnd As Integer = Realm.IndexOf("""")
If RealmEnd > -1 Then
Realm = Realm.Left(RealmEnd)
End If
End If
End If
#else
Dim RealmStart As Integer = InStr(Auth, " realm=") - 1
If RealmStart > -1 Then
Realm = Mid(Auth, RealmStart + 8)
If Left(Realm, 1) = """" Then
Realm = Realm.Mid(2)
Dim RealmEnd As Integer = InStr(Realm, """") - 1
If RealmEnd > -1 Then
Realm = Left(Realm, RealmEnd)
End If
End If
End If
#endif
Sender.Cancel = True
Dim Dict As New Dictionary
Dict.Value("Event") = "AuthenticationRequested"
Dict.Value("Realm") = Realm
Dict.Value("URL") = Sender.OptionURL
#if XojoVersion >= 2019.02
Dim TypeLen As Integer = Auth.IndexOf(" ")
#else
Dim TypeLen As Integer = InStr(Auth, " ") - 1
#endif
Dim Type As String = Auth.Left(TypeLen)
Select Case Type
Case "Basic"
Dict.Value("Type") = CURLSMBS.kAUTH_BASIC
Case "Digest"
Dict.Value("Type") = CURLSMBS.kAUTH_DIGEST
End Select
If Dict.HasKey("Type") Then
Self.mSilenceResponse = True
Self.ScheduleUpdateDictionary(Dict)
Return DataSize
End If
End If
Dim Dict As New Dictionary
Dict.Value("Event") = "HeadersReceived"
Dict.Value("URL") = Sender.OptionURL
Dict.Value("HTTPStatus") = Self.HTTPStatusCode
#if XojoVersion >= 2019.02
Dict.Value("Headers") = Self.mResponseHeaders.Clone
#else
Dim Clone As New Dictionary
Dim Keys() As Variant = Self.mResponseHeaders.Keys
For Each Key As Variant In Keys
Clone.Value(Key) = Self.mResponseHeaders.Value(Key)
Next
Dict.Value("Headers") = Clone
#endif
Self.ScheduleUpdateDictionary(Dict)
Return DataSize
End If
#if XojoVersion >= 2019.02
Dim Pos As Integer = Data.IndexOf(":")
If Pos = -1 Then
Return DataSize
End If
Dim Header As String = Data.Left(Pos)
Dim Value As String = Data.Middle(Pos + 1).Trim
#else
Dim Pos As Integer = InStr(Data, ":")
If Pos = 0 Then
Return DataSize
End If
Dim Header As String = Left(Data, Pos - 1)
Dim Value As String = Trim(Mid(Data, Pos + 1))
#endif
Self.mResponseHeaders.Value(Header) = Value
Return DataSize
End Function
#tag EndMethod
#tag Method, Flags = &h21
Private Function mSocket_Progress(Sender As CURLSMBS, DownloadTotal As Int64, DownloadNow As Int64, UploadTotal As Int64, UploadNow As Int64, Percent As Double) As Boolean
#Pragma Unused Percent
// Terminates transfer
If Sender.Cancel Then
Return True
End If
If DownloadTotal > 0 Then
Dim Dict As New Dictionary
Dict.Value("Event") = "ReceivingProgressed"
Dict.Value("TotalBytes") = DownloadTotal
Dict.Value("ReceivedBytes") = DownloadNow
Self.ScheduleUpdateDictionary(Dict)
End If
If UploadTotal > 0 Then
Dim Dict As New Dictionary
Dict.Value("Event") = "SendingProgressed"
Dict.Value("TotalBytes") = UploadTotal
Dict.Value("SentBytes") = UploadNow
Self.ScheduleUpdateDictionary(Dict)
End If
End Function
#tag EndMethod
#tag Method, Flags = &h21
Private Sub mUpdateTimer_Action(Sender As Timer)
#if XojoVersion >= 2019.02
#Pragma Unused Sender
#else
While Self.mUpdateQueue.Ubound > -1
Dim Dict As Dictionary = Self.mUpdateQueue(0)
Self.mUpdateQueue.Remove(0)
Self.HandleUpdateDictionary(Dict)
Wend
Sender.Mode = Timer.ModeOff
#endif
End Sub
#tag EndMethod
#tag Method, Flags = &h21
Private Sub mWorkerThread_Run(Sender As Thread)
#Pragma Unused Sender
Call Self.Perform(True)
End Sub
#tag EndMethod
#tag Method, Flags = &h21
Private Sub mWorkerThread_UserInterfaceUpdate(Sender As Thread, Data() As Dictionary)
#Pragma Unused Sender
#if XojoVersion >= 2019.02
For Each Dict As Dictionary In Data
Self.HandleUpdateDictionary(Dict)
Next
#else
#Pragma Unused Data
#endif
End Sub
#tag EndMethod
#tag Method, Flags = &h21
Private Function Perform(FireEvents As Boolean) As String
Self.mSilenceResponse = False
Self.mResponseHeaders = New Dictionary
If Self.mSaveToFile <> Nil Then
If Not Self.mSocket.CreateMTOutputFile(Self.mSaveToFile) Then
Self.mSaveToFile = Nil
End If
End If
Dim Err As Integer = Self.mSocket.PerformMT
If Self.mSaveToFile <> Nil Then
Self.mSocket.CloseMTOutputFile
If Self.mSocket.Cancel Then
#if XojoVersion >= 2019.02
Self.mSaveToFile.Remove
#else
Self.mSaveToFile.Delete
#endif
End If
End If
If Self.mSilenceResponse Then
Return ""
End If
If Err = 0 Then
If FireEvents Then
Dim ResponseData As New Dictionary
ResponseData.Value("URL") = Self.mSocket.OptionURL
ResponseData.Value("Content") = Self.mSocket.OutputData
ResponseData.Value("HTTPStatus") = Self.HTTPStatusCode
#if XojoVersion >= 2019.02
ResponseData.Value("Headers") = Self.mResponseHeaders.Clone
#else
Dim Clone As New Dictionary
Dim Keys() As Variant = Self.mResponseHeaders.Keys
For Each Key As Variant In Keys
Clone.Value(Key) = Self.mResponseHeaders.Value(Key)
Next
ResponseData.Value("Headers") = Clone
#endif
ResponseData.Value("Event") = "Finished"
Self.ScheduleUpdateDictionary(ResponseData)
End If
Return Self.mSocket.OutputData
Else
Dim Except As New RuntimeException
Except.ErrorNumber = Err
Except.Message = Self.mSocket.LasterrorMessage
If FireEvents Then
Dim Dict As New Dictionary
Dict.Value("Event") = "Error"
Dict.Value("Err") = Except
Dict.Value("URL") = Self.mSocket.OptionURL
Self.ScheduleUpdateDictionary(Dict)
End If
Self.mLastError = Except
Return ""
End If
End Function
#tag EndMethod
#tag Method, Flags = &h0
Sub Post(URL As String, FormData As Dictionary)
Self.SetRequestContent(BuildQueryString(FormData), "application/x-www-form-urlencoded")
Call Self.Send("POST", URL, Nil, -1)
End Sub
#tag EndMethod
#tag Method, Flags = &h0
Function Post(URL As String, FormData As Dictionary, Timeout As Integer) As String
Self.SetRequestContent(BuildQueryString(FormData), "application/x-www-form-urlencoded")
Return Self.Send("POST", URL, Nil, Timeout)
End Function
#tag EndMethod
#tag Method, Flags = &h0
Sub Post(URL As String, ContentType As String, Content As String)
Self.SetRequestContent(Content, ContentType)
Call Self.Send("POST", URL, Nil, -1)
End Sub
#tag EndMethod
#tag Method, Flags = &h0
Function Post(URL As String, ContentType As String, Content As String, Timeout As Integer) As String
Self.SetRequestContent(Content, ContentType)
Return Self.Send("POST", URL, Nil, Timeout)
End Function
#tag EndMethod
#tag Method, Flags = &h0
Function RequestHeader(Name As String) As String
Return Self.mRequestHeaders.Lookup(Name, "")
End Function
#tag EndMethod
#tag Method, Flags = &h0
Sub RequestHeader(Name As String, Assigns Value As String)
Self.mRequestHeaders.Value(Name) = Value
End Sub
#tag EndMethod
#tag Method, Flags = &h0
Function ResponseHeader(Name As String) As String
Return Self.mResponseHeaders.Lookup(Name, "")
End Function
#tag EndMethod
#tag Method, Flags = &h0
Function ResponseHeaders() As Pair()
#if XojoVersion >= 2019.02
Var Pairs() As Pair
For Each Entry As DictionaryEntry In Self.mResponseHeaders
Pairs.AddRow(Entry.Key : Entry.Value)
Next
Return Pairs
#else
Dim Pairs() As Pair
Dim Keys() As Variant = Self.mResponseHeaders.Keys
For Each Key As Variant In Keys
Pairs.AddRow(Key : Self.mResponseHeaders.Value(Key))
Next
Return Pairs
#endif
End Function
#tag EndMethod
#tag Method, Flags = &h21
Private Sub ScheduleUpdateDictionary(Dict As Dictionary)
Dim CurrentThread As Thread = App.CurrentThread
If CurrentThread = Nil Then
Self.HandleUpdateDictionary(Dict)
Else
#if XojoVersion >= 2019.02
CurrentThread.AddUserInterfaceUpdate(Dict)
#else
Self.mUpdateQueue.Append(Dict)
If Self.mUpdateQueue.Ubound = 0 Then
Self.mUpdateTimer.Mode = Timer.ModeSingle
End If
#endif
End If
End Sub
#tag EndMethod
#tag Method, Flags = &h0
Sub Send(Method As String, URL As String, File As FolderItem = Nil)
Call Self.Send(Method, URL, File, -1)
End Sub
#tag EndMethod
#tag Method, Flags = &h21
Private Function Send(Method As String, URL As String, File As FolderItem, Timeout As Integer) As String
Self.mSocket.OptionCustomRequest = Method
Self.mSocket.OptionURL = URL
Dim Headers() As String
#if XojoVersion >= 2019.02
For Each Entry As DictionaryEntry In Self.mRequestHeaders
Headers.AddRow(Entry.Key.StringValue + ": " + Entry.Value.StringValue)
Next
#else
Dim Keys() As Variant = Self.mRequestHeaders.Keys
For Each Key As Variant In Keys
Headers.Append(Key.StringValue + ": " + Self.mRequestHeaders.Value(Key).StringValue)
Next
#endif
Self.mSocket.SetOptionHTTPHeader(Headers)
Self.mSaveToFile = File
If Timeout < 0 Then
Self.mSocket.OptionConnectionTimeout = 60
#if XojoVersion >= 2019.02
Self.mWorkerThread.Start
#else
Self.mWorkerThread.Run
#endif
Else
Self.mSocket.OptionConnectionTimeout = Timeout
Return Self.Perform(False)
End If
End Function
#tag EndMethod
#tag Method, Flags = &h0
Sub SendSync(Method As String, URL As String, File As FolderItem, Timeout As Integer)
Call Self.Send(Method, URL, File, Timeout)
End Sub
#tag EndMethod
#tag Method, Flags = &h0
Function SendSync(Method As String, URL As String, Timeout As Integer) As String
Return Self.Send(Method, URL, Nil, Timeout)
End Function
#tag EndMethod
#tag Method, Flags = &h0
Sub SetRequestContent(Content As String, MimeType As String)
Self.RequestHeader("Content-Type") = MimeType
Self.mSocket.OptionUpload = True
Self.mSocket.InputData = Content
End Sub
#tag EndMethod
#tag Hook, Flags = &h0
Event AuthenticationRequested(Realm As String, ByRef Name As String, ByRef Password As String) As Boolean
#tag EndHook
#tag Hook, Flags = &h0
Event ContentReceived(URL As String, HTTPStatus As Integer, Content As String)
#tag EndHook
#tag Hook, Flags = &h0
Event Error(E As RuntimeException)
#tag EndHook
#tag Hook, Flags = &h0
Event FileReceived(URL As String, HTTPStatus As Integer, File As FolderItem)
#tag EndHook
#tag Hook, Flags = &h0
Event HeadersReceived(URL As String, HTTPStatus As Integer)
#tag EndHook
#tag Hook, Flags = &h0
Event ReceivingProgressed(BytesReceived As Int64, TotalBytes As Int64, NewData As String)
#tag EndHook
#tag Hook, Flags = &h0
Event SendingProgressed(BytesSent As Int64, BytesLeft As Int64)
#tag EndHook
#tag ComputedProperty, Flags = &h0
#tag Getter
Get
Return Self.mSocket.OptionSSLVerifyHost = 2 And Self.mSocket.OptionSSLVerifyPeer = 1
End Get
#tag EndGetter
#tag Setter
Set
If Value Then
Self.mSocket.OptionSSLVerifyHost = 2
Self.mSocket.OptionSSLVerifyPeer = 1
Else
Self.mSocket.OptionSSLVerifyHost = 0
Self.mSocket.OptionSSLVerifyPeer = 0
End If
End Set
#tag EndSetter
AllowCertificateValidation As Boolean
#tag EndComputedProperty
#tag ComputedProperty, Flags = &h0
#tag Getter
Get
Return Self.mSocket.OptionFollowLocation
End Get
#tag EndGetter
#tag Setter
Set
Self.mSocket.OptionFollowLocation = Value
End Set
#tag EndSetter
FollowRedirects As Boolean
#tag EndComputedProperty
#tag ComputedProperty, Flags = &h0
#tag Getter
Get
Return Self.mSocket.GetInfoResponseCode
End Get
#tag EndGetter
HTTPStatusCode As Integer
#tag EndComputedProperty
#tag ComputedProperty, Flags = &h0
#tag Getter
Get
Return Self.mLastError
End Get
#tag EndGetter
LastError As RuntimeException
#tag EndComputedProperty
#tag ComputedProperty, Flags = &h0
#tag Getter
Get
Select Case Self.mSocket.OptionSSLVersion
Case CURLSMBS.kSSLVersionTLSv13
Return TLSVersions.v1_3
Case CURLSMBS.kSSLVersionTLSv12
Return TLSVersions.v1_2
Case CURLSMBS.kSSLVersionTLSv11
Return TLSVersions.v1_1
Case CURLSMBS.kSSLVersionTLSv10
Return TLSVersions.v1_0
Else
Return CType(Self.mSocket.OptionSSLVersion, TLSVersions)
End Select
End Get
#tag EndGetter
#tag Setter
Set
Select Case Value
Case TLSVersions.v1_3
Self.mSocket.OptionSSLVersion = CURLSMBS.kSSLVersionTLSv13
Case TLSVersions.v1_2
Self.mSocket.OptionSSLVersion = CURLSMBS.kSSLVersionTLSv12
Case TLSVersions.v1_1
Self.mSocket.OptionSSLVersion = CURLSMBS.kSSLVersionTLSv11
Else
Self.mSocket.OptionSSLVersion = CURLSMBS.kSSLVersionTLSv10
End Select
End Set
#tag EndSetter
MinTLSVersion As TLSVersions
#tag EndComputedProperty
#tag Property, Flags = &h21
Private mLastError As RuntimeException
#tag EndProperty
#tag Property, Flags = &h21
Private mRequestHeaders As Dictionary
#tag EndProperty
#tag Property, Flags = &h21
Private mResponseHeaders As Dictionary
#tag EndProperty
#tag Property, Flags = &h21
Private mSaveToFile As FolderItem
#tag EndProperty
#tag Property, Flags = &h21
Private mSilenceResponse As Boolean
#tag EndProperty
#tag Property, Flags = &h21
Private mSocket As CURLSMBS
#tag EndProperty
#tag Property, Flags = &h21
Private mUpdateQueue() As Dictionary
#tag EndProperty
#tag Property, Flags = &h21
Private mUpdateTimer As Timer
#tag EndProperty
#tag Property, Flags = &h21
Private mWorkerThread As Thread
#tag EndProperty
#tag ComputedProperty, Flags = &h0
#tag Getter
Get
Return Self.mSocket.OptionSSLVerifyStatus = 1
End Get
#tag EndGetter
#tag Setter
Set
Self.mSocket.OptionSSLVerifyStatus = If(Value, 1, 0)
End Set
#tag EndSetter
RequireOCSPStapling As Boolean
#tag EndComputedProperty
#tag ComputedProperty, Flags = &h0
#tag Getter
Get
Return Self.mSocket.OptionUserAgent
End Get
#tag EndGetter
#tag Setter
Set
Self.mSocket.OptionUserAgent = Value
End Set
#tag EndSetter
UserAgent As String
#tag EndComputedProperty
#tag Enum, Name = CommonErrors, Type = Integer, Flags = &h0
FunctionMissing = -1
UnsupportedProtocol = 1
MalformedURL = 3
HostResolutionError = 6
ConnectionFailed = 7
OutOfMemory = 27
SecureConnectionError = 35
TooManyRedirects = 47
RemoteCertificateRejected = 51
NoCommonCiphers = 59
CertificateAuthorityRejected = 60
#tag EndEnum
#tag Enum, Name = TLSVersions, Type = Integer, Flags = &h0
v1_0
v1_1
v1_2
v1_3
#tag EndEnum
#tag ViewBehavior
#tag ViewProperty
Name="Name"
Visible=true
Group="ID"
Type="String"
#tag EndViewProperty
#tag ViewProperty
Name="Index"
Visible=true
Group="ID"
InitialValue="-2147483648"
Type="Integer"
#tag EndViewProperty
#tag ViewProperty
Name="Super"
Visible=true
Group="ID"
Type="String"
#tag EndViewProperty
#tag ViewProperty
Name="Left"
Visible=true
Group="Position"
InitialValue="0"
Type="Integer"
#tag EndViewProperty
#tag ViewProperty
Name="Top"
Visible=true
Group="Position"
InitialValue="0"
Type="Integer"
#tag EndViewProperty
#tag ViewProperty
Name="AllowCertificateValidation"
Group="Behavior"
Type="Boolean"
#tag EndViewProperty
#tag ViewProperty
Name="HTTPStatusCode"
Group="Behavior"
Type="Integer"
#tag EndViewProperty
#tag ViewProperty
Name="MinTLSVersion"
Group="Behavior"
Type="TLSVersions"
EditorType="Enum"
#tag EnumValues
"0 - v1_0"
"1 - v1_1"
"2 - v1_2"
"3 - v1_3"
#tag EndEnumValues
#tag EndViewProperty
#tag ViewProperty
Name="RequireOCSPStapling"
Group="Behavior"
Type="Boolean"
#tag EndViewProperty
#tag ViewProperty
Name="FollowRedirects"
Group="Behavior"
Type="Boolean"
#tag EndViewProperty
#tag ViewProperty
Name="UserAgent"
Group="Behavior"
Type="String"
EditorType="MultiLineEditor"
#tag EndViewProperty
#tag EndViewBehavior
End Class
#tag EndClass